摘要: 题意:数组长度为N,找出数组中元素出现个数大于N/2 的众数 法一:先排序,再来一次遍历硬数一下 法二:Moore Voting Algorithm算法,动画在这里:http://www.cs.utexas.edu/~moore/best-ideas/mjrty/example.html#step1 阅读全文
posted @ 2017-10-12 23:26 799 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 题意:在排序的数组,找到两个元素和为target,返回其下标index1 和 index2 (1<=index1 < index2),只有一种答案,每个元素不能用两次。 分析: 阅读全文
posted @ 2017-10-12 23:12 799 阅读(103) 评论(0) 推荐(0) 编辑