Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers. Example 1: Input: nums = [2,5,6,9,10] Output: 2 Explanation: The...
参考资料: https://leetcode.com/problems/find-permutation/ https://leetcode.com/problems/find-permutation/discuss/96644/c-simple-solution-in-72ms-and-9-lines https://leetcode.com/problems/find-permutation/discuss/96663/greedy-on-java-solution-with-explanation https://leetcode.com/problems/find-p...
Kth Smallest Number in Multiplication Table K-th Smallest Prime Fraction 参考资料: https://leetcode.com/problems/find-k-th-smallest-pair-distance/solution/ https://leetcode.com/problems/find-k-th-smallest-pair-distance/discuss/109077/C++-counting-sort-O(n2)-and-binary-search-O(nlogn) https:...
287. Find the Duplicate Number containingn+1integerswhereeachintegerisbetween1andn(inclusive),provethatatleastoneduplicatenumbermustexist.Assumethatthereisonlyoneduplicatenumber,findtheduplicateone leetcode之Find the Duplicate Number 问题 问题描述:Givenanarraynumscontainingn+1integerswhereeachintegerisbetween1...
Given asortedinteger arrayarr, two integerskandx, return thekclosest integers toxin the array. The result should also be sorted in ascending order. An integerais closer toxthan an integerbif: |a - x| < |b - x|, or |a - x| == |b - x|anda < b ...
leetcode-222-Counter Complete Binary Tree Nodes - binary search 2 0 10:00 App leetcode-852. Peak Index in a Mountain Array -binary-search 94 0 10:30 App leetcode-1973-Count Nodes Equal to Sum of Descendants - Recursion 3 0 15:08 App leetcode-111. Minimum Depth of Binary Tree -...
代码# Go packageleetcodefuncfindAnagrams(sstring,pstring)[]int{varfreq[256]intresult:=[]int{}iflen(s)==0||len(s)<len(p){returnresult}fori:=0;i<len(p);i++{freq[p[i]-'a']++}left,right,count:=0,0,len(p)forright<len(s){iffreq[s[right]-'a']>=1{count--}freq[s[right...
There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold. Return the city with the smallest number of cities that are reachab...
0230-kth-smallest-element-in-a-bst.py 0235-lowest-common-ancestor-of-a-binary-search-tree.py 0238-product-of-array-except-self.py 0239-sliding-window-maximum.py 0242-valid-anagram.py 0253-meeting-rooms.py 0261-graph-valid-tree.py 0268-missing-number.py 0269-alien-d...
45 changes: 45 additions & 0 deletions 45 2102-find-the-middle-index-in-array/README.md Original file line numberDiff line numberDiff line change @@ -0,0 +1,45 @@ <h2><a href="https://leetcode.com/problems/find-the-middle-index-in-array">Find the Middle Index in Array</a><...