File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,424 LeetCode solutions in JavaScript
1
+ # 1,425 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1248
1248
1615|[ Maximal Network Rank] ( ./solutions/1615-maximal-network-rank.js ) |Medium|
1249
1249
1616|[ Split Two Strings to Make Palindrome] ( ./solutions/1616-split-two-strings-to-make-palindrome.js ) |Medium|
1250
1250
1617|[ Count Subtrees With Max Distance Between Cities] ( ./solutions/1617-count-subtrees-with-max-distance-between-cities.js ) |Hard|
1251
+ 1619|[ Mean of Array After Removing Some Elements] ( ./solutions/1619-mean-of-array-after-removing-some-elements.js ) |Easy|
1251
1252
1657|[ Determine if Two Strings Are Close] ( ./solutions/1657-determine-if-two-strings-are-close.js ) |Medium|
1252
1253
1668|[ Maximum Repeating Substring] ( ./solutions/1668-maximum-repeating-substring.js ) |Easy|
1253
1254
1669|[ Merge In Between Linked Lists] ( ./solutions/1669-merge-in-between-linked-lists.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1619. Mean of Array After Removing Some Elements
3
+ * https://leetcode.com/problems/mean-of-array-after-removing-some-elements/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an integer array arr, return the mean of the remaining integers after removing the
7
+ * smallest 5% and the largest 5% of the elements.
8
+ *
9
+ * Answers within 10-5 of the actual answer will be considered accepted.
10
+ */
11
+
12
+ /**
13
+ * @param {number[] } arr
14
+ * @return {number }
15
+ */
16
+ var trimMean = function ( numbers ) {
17
+ const sortedNumbers = numbers . sort ( ( a , b ) => a - b ) ;
18
+ const trimSize = numbers . length * 0.05 ;
19
+ const trimmedNumbers = sortedNumbers . slice ( trimSize , - trimSize ) ;
20
+ const sum = trimmedNumbers . reduce ( ( acc , num ) => acc + num , 0 ) ;
21
+
22
+ return sum / trimmedNumbers . length ;
23
+ } ;
You can’t perform that action at this time.
0 commit comments