Rakesh Reddy Peddamallu Posted on Jan 26 Leetcode - 274. H-Index #leetcode LeetCode Diary (42 Part Series) 1 Leetcode - 796. Rotate String 2 Leetcode - 845. Longest Mountain in Array ... 38 more parts... 3 Leetcode - 725. Split Linked List in Parts 4 Leetcode - 645. Set Mismatch 5 Leetcode - 70. Climbing Stairs 6 Leetcode - 1. Two Sum 7 Leetcode - 133. Clone Graph 8 Leetcode - 1768. Merge Strings Alternately 9 Leetcode - 1071. Greatest Common Divisor of Strings 10 Leetcode - 1431. Kids With the Greatest Number of Candies 11 Leetcode - 605. Can Place Flowers 12 Leetcode - 345. Reverse Vowels of a String 13 Leetcode - 151. Reverse Words in a String 14 Leetcode - 238. Product of Array Except Self 15 Leetcode - 334. Increasing Triplet Subsequence 16 Leetcode - 443. String Compression 17 Leetcode - 283. Move Zeroes 18 Leetcode - 392. Is Subsequence 19 Leetcode - 26. Remove Duplicates from Sorted Array 20 Leetcode - 80. Remove Duplicates from Sorted Array II 21 Leetcode - 169. Majority Element 22 Leetcode - 189. Rotate Array 23 Leetcode - 121. Best Time to Buy and Sell Stock 24 Leetcode - 55. Jump Game 25 Leetcode - 45. Jump Game II 26 Leetcode - 274. H-Index 27 Leetcode - 380. Insert Delete GetRandom O(1) 28 Leetcode - 134. Gas Station 29 Leetcode - 135. Candy 30 Leetcode - 42. Trapping Rain Water 31 Leetcode - 13. Roman to Integer 32 Leetcode - 12. Integer to Roman 33 Leetcode - 58. Length of Last Word 34 Leetcode - 14. Longest Common Prefix 35 Leetcode - 6. Zigzag Conversion 36 Leetcode - 28. Find the Index of the First Occurrence in a String 37 Leetcode - 68. Text Justification 38 Leetcode - 125. Valid Palindrome 39 Leetcode - 167. Two Sum II - Input Array Is Sorted 40 Leetcode - 11. Container With Most Water 41 Leetcode - 15. 3Sum 42 Leetcode - 209. Minimum Size Subarray Sum /** * @param {number[]} citations * @return {number} */ var hIndex = function(citations) { for(let h = citations.length ; h>0;h-- ){ let count = 0 for(let i= 0 ; i <citations.length;i++){ if(citations[i]-h >=0){ count++; } } if(count >= h){ return h } } return 0 }; Enter fullscreen mode Exit fullscreen mode With Sorting var hIndex = function(citations) { citations = citations.sort((a,b)=>b-a); for(i=citations.length; i>0; i--) if(citations[i-1]>=i) return i return 0 } Enter fullscreen mode Exit fullscreen mode Top comments (0) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)