Skip to content

Commit b128847

Browse files
committed
feat: add typescript solution to lc problem: No.2148
No.2148.Count Elements With Strictly Smaller and Greater Elements
1 parent eb88a78 commit b128847

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

solution/2100-2199/2148.Count Elements With Strictly Smaller and Greater Elements/README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,17 @@ func countElements(nums []int) int {
127127
<!-- 这里可写当前语言的特殊实现逻辑 -->
128128

129129
```ts
130-
130+
function countElements(nums: number[]): number {
131+
const min = Math.min(...nums), max = Math.max(...nums);
132+
let ans = 0;
133+
for (let i = 0; i < nums.length; ++i) {
134+
let cur = nums[i];
135+
if (cur < max && cur > min) {
136+
++ans;
137+
}
138+
}
139+
return ans;
140+
};
131141
```
132142

133143
### **...**

solution/2100-2199/2148.Count Elements With Strictly Smaller and Greater Elements/README_EN.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,17 @@ func countElements(nums []int) int {
117117
### **TypeScript**
118118

119119
```ts
120-
120+
function countElements(nums: number[]): number {
121+
const min = Math.min(...nums), max = Math.max(...nums);
122+
let ans = 0;
123+
for (let i = 0; i < nums.length; ++i) {
124+
let cur = nums[i];
125+
if (cur < max && cur > min) {
126+
++ans;
127+
}
128+
}
129+
return ans;
130+
};
121131
```
122132

123133
### **...**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function countElements(nums: number[]): number {
2+
const min = Math.min(...nums), max = Math.max(...nums);
3+
let ans = 0;
4+
for (let i = 0; i < nums.length; ++i) {
5+
let cur = nums[i];
6+
if (cur < max && cur > min) {
7+
++ans;
8+
}
9+
}
10+
return ans;
11+
};

0 commit comments

Comments
 (0)