随笔分类 -  lintCode

1 2 3 4 5 6 下一页

[LeetCode] 252. Meeting Rooms
摘要:这道题可以直接暴力解决,看看每个interval是不是和剩余的interval有重复。但是还有一种更优化的方法,先对起始时间排序,然后看每一个end的时间是不是比前一个的start时间早。 python笔记, 1. sorted function会create一个新的list,但是<my_list> 阅读全文

posted @ 2019-03-14 11:21 codingEskimo 阅读(114) 评论(0) 推荐(0)

[LeetCode] Merge K Sorted Lists
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 时间复杂度 O(nlogk)思路: 这道题其实有三种做法,第一种是priorityQueue,第二种是 阅读全文

posted @ 2018-03-27 09:02 codingEskimo 阅读(113) 评论(0) 推荐(0)

[LeetCode][LintCode] Add Two Numbers
摘要:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai 阅读全文

posted @ 2018-02-21 12:50 codingEskimo 阅读(127) 评论(0) 推荐(0)

[LeetCode][LintCode] Two Sum
摘要:思路: 这道题因为只有一对,所以可以用hashmap,需要注意的是,数字可能有重复, eg.[1,2,2,3,4] target = 4. 所以最好的办法就是把剩下的放进去。 这样如果有重复,没关系,把现在的index和已经放进去的index返回即可。 阅读全文

posted @ 2018-02-21 11:44 codingEskimo 阅读(95) 评论(0) 推荐(0)

[LintCode] Swap Bits
摘要:Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are s 阅读全文

posted @ 2018-02-14 11:48 codingEskimo 阅读(158) 评论(0) 推荐(0)

[LintCode] Drop Eggs II
摘要:There is a building of n floors. If an egg drops from the k th floor or above, it will break. If it's dropped from any floor below, it will not break. 阅读全文

posted @ 2018-02-02 12:35 codingEskimo 阅读(404) 评论(0) 推荐(0)

[LintCode] Frog Jump
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文

posted @ 2018-02-02 12:08 codingEskimo 阅读(258) 评论(0) 推荐(0)

[LintCode] Jump Game
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文

posted @ 2018-02-01 12:29 codingEskimo 阅读(106) 评论(0) 推荐(0)

[LintCode] Knight Shortest Path II
摘要:Given a knight in a chessboard n * m (a binary matrix with 0 as empty and 1 as barrier). the knight initialze position is (0, 0) and he wants to reach 阅读全文

posted @ 2018-02-01 11:54 codingEskimo 阅读(335) 评论(0) 推荐(0)

[LintCode] 汇总 summary
摘要:76. Longest Increasing Subsequence 116. Jump Game 603. Largest Divisible Subset 611. Knight Shortest Path 630. Knight Shortest Path II 116. Jump Game 阅读全文

posted @ 2018-02-01 11:44 codingEskimo 阅读(114) 评论(0) 推荐(0)

[LintCode] Knight Shortest Path
摘要:This question is standard level BSF. From this question, we can see the best time to mark a node is the time when it is added to a queue. 阅读全文

posted @ 2017-06-16 07:36 codingEskimo 阅读(121) 评论(0) 推荐(0)

Zombie in Matrix
摘要:Note: This is to count the level. At beginning, since there are so many zombies, we need to add all of them to the Queue to start with. It is differen 阅读全文

posted @ 2017-06-15 11:22 codingEskimo 阅读(124) 评论(0) 推荐(0)

Number of Islands
摘要:This is Matrix Problem which can be converted to BSF: Loop through each node, if it is island, find the edge. Inside the mark them all as sea. So it w 阅读全文

posted @ 2017-06-15 07:46 codingEskimo 阅读(88) 评论(0) 推荐(0)

Sequence Reconstruction
摘要:Only Path :判断是否只存在一个拓扑排序的序列 只需要保证队列中一直最多只有1个元素即可 tricky part:1) org has all the nodes. That is why each time there should only be 1 element in the que 阅读全文

posted @ 2017-06-15 06:17 codingEskimo 阅读(208) 评论(0) 推荐(0)

Course Schedule II
摘要:The same as I: 阅读全文

posted @ 2017-06-14 08:50 codingEskimo 阅读(76) 评论(0) 推荐(0)

Course Schedule
摘要:Note: 1) For integer node 0~n, we don't need a hashmap, we can just use array to act like a map; 2) How to initial List[] is very important 3) We need 阅读全文

posted @ 2017-06-14 08:38 codingEskimo 阅读(120) 评论(0) 推荐(0)

Topological Sorting
摘要:Topological Sorting is very important, almost every company has a question related to it. Goal: To find an proper order making the front nodes are ind 阅读全文

posted @ 2017-06-14 06:52 codingEskimo 阅读(176) 评论(0) 推荐(0)

Search Graph Nodes
摘要:Note: BSF: if it needs to check the value, should check it when it is coming from Queue. The logic is most clear to do it there. This question is to a 阅读全文

posted @ 2017-06-14 06:06 codingEskimo 阅读(191) 评论(0) 推荐(0)

Convert Binary Tree to Linked Lists by Depth
摘要:This question is the same as Binary Tree Treverse in Level Order. Instead of a list, we need ListNode to remeber the result. The tricky part is that w 阅读全文

posted @ 2017-06-13 09:36 codingEskimo 阅读(424) 评论(0) 推荐(0)

Binary Tree Zigzag Level Order Traversal
摘要:Similar to Binary Tree Level Order Travel, just need to add a flag to remeber the order. Change the order to opposite after the level is over. 阅读全文

posted @ 2017-06-13 09:18 codingEskimo 阅读(99) 评论(0) 推荐(0)

1 2 3 4 5 6 下一页

导航