File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
solution/2100-2199/2148.Count Elements With Strictly Smaller and Greater Elements Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff 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### ** ...**
Original file line number Diff line number Diff 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 number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments