06 2016 档案

摘要:给定一组数,有一个数在这组数里的出现次数超过n/2次。 求出这是哪个数 https://leetcode.com/problems/majority-element/ 一开始考虑的方是将所有数转化为二进制,那么对于这些二进制数来说。 其每一位上必然是出现次数最多的数决定了它是1还是0。 例如,将每个 阅读全文
posted @ 2016-06-29 11:27 ElNinoT 阅读(201) 评论(0) 推荐(0)
摘要:这道题目是,给你一组乱序非负整数,求排好序后,这组数的连续两个数的最大差值。 例如,3,9,10,2,8,4,1。则最大差值是4。 一开始就考虑到可能要使用桶排序,但是最开始的思路是按照数的最高位的值大小来排序,这个思路并不行。 后来上网查了下答案。一开始没看懂。 大概思路是: 另max,min分别 阅读全文
posted @ 2016-06-27 14:24 ElNinoT 阅读(153) 评论(0) 推荐(0)
摘要:题目: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get 阅读全文
posted @ 2016-06-22 16:57 ElNinoT 阅读(246) 评论(0) 推荐(0)
摘要:这道题目本身没什么特色。 但是涉及到一个问题,即快慢指针的问题。 犹记得面试微软的那道快慢指针找链表环的问题。 这里快慢指针还有个妙用。即求一个链表的中点。 记之 阅读全文
posted @ 2016-06-21 17:35 ElNinoT 阅读(118) 评论(0) 推荐(0)
摘要:先上题目 Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endW 阅读全文
posted @ 2016-06-03 10:03 ElNinoT 阅读(226) 评论(0) 推荐(0)
摘要:题目 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transact 阅读全文
posted @ 2016-06-01 10:48 ElNinoT 阅读(194) 评论(0) 推荐(0)