Non-Leetcode Questions: Two Closest Points to a Given Point
Two Closest Points to a Given Point
Two Closest Points to a Given Point
Find the 2 points from a list that are closest to a given point. Distance is calculated using Euclidean distance.
Find the 2 points from a list that are closest to a given point. Distance is calculated using Euclidean distance.
Naive Thinking:具体题目不详,是我根据题意总结出来的。等等,这不是跟上一题k-Nearest Points to Origin是一样的吗。现在k=2,原点变成了给定点。干脆把它扩展成k-Nearest Points to a Given Point 好了。但是也没什么大变化,没什么可说的。
就这题而言,如果用两个变量....说着说着,好好地glassdoor居然维护了!看不了题目了。
就这题而言,如果用两个变量分别存当前最小距离的两个点,然后遍历一遍不就可以直接得到结果吗,O(n)的时间复杂度,很傻喔,就跟求一个数组的最小值一样,这是什么题目,这些人真是瞎贴面试题目。
就这题而言,如果用两个变量....说着说着,好好地glassdoor居然维护了!看不了题目了。
就这题而言,如果用两个变量分别存当前最小距离的两个点,然后遍历一遍不就可以直接得到结果吗,O(n)的时间复杂度,很傻喔,就跟求一个数组的最小值一样,这是什么题目,这些人真是瞎贴面试题目。
Read full article from Non-Leetcode Questions: Two Closest Points to a Given Point
No comments:
Post a Comment