摘要: 类似于find kth small element in sorted matrix, 另外数组是个好东西,在构造heap 的元素的时候 Some observations: For every numbers in nums1, its best partner(yields min sum) a 阅读全文
posted @ 2017-11-07 22:41 apanda009 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Analysis: Solution 1: The greedy algorithm is that in each step, select the char with highest remaining count if possible (if it is not in the waiting 阅读全文
posted @ 2017-11-07 21:37 apanda009 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 方法1:Time Complexity O(NK) 暂时只有两个Heap的做法,缺点:In this problem, it is necessary to be able remove elements that are not necessarily at the top of the heap 阅读全文
posted @ 2017-11-07 12:24 apanda009 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find 阅读全文
posted @ 2017-11-07 06:02 apanda009 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 这道题就是根据条件老老实实的做 阅读全文
posted @ 2017-11-07 05:30 apanda009 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrenc 阅读全文
posted @ 2017-11-07 05:06 apanda009 阅读(482) 评论(0) 推荐(0) 编辑
摘要: Better idea is to maintain a hashset that contains at most k numbers 阅读全文
posted @ 2017-11-07 04:52 apanda009 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 阅读全文
posted @ 2017-11-07 04:46 apanda009 阅读(98) 评论(0) 推荐(0) 编辑
摘要: This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2. Given a list of words and two words word1 阅读全文
posted @ 2017-11-07 04:38 apanda009 阅读(142) 评论(0) 推荐(0) 编辑
摘要: This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly ma 阅读全文
posted @ 2017-11-07 04:33 apanda009 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example,Assume that words = 阅读全文
posted @ 2017-11-07 04:32 apanda009 阅读(136) 评论(0) 推荐(0) 编辑