摘要:
Description: Count the number of prime numbers less than a non-negative number, n. 刷了一周的python, 希望明天把blackjack和最后的游戏做出来。 思路: 比较巧妙,用inner loop从头开始mark不 阅读全文
posted @ 2016-10-08 17:14
Machelsky
阅读(91)
评论(0)
推荐(0)
摘要:
1. Two sum: map解决,扫一遍记录位置为key,值为剩下值。 2. Add Two Numbers: 链表扫一遍, dummy node接算出来的node,跑完一个跑另一个,最后接上多出的node1 136. Single Number: 可以用map也可以用bit manipulati 阅读全文
posted @ 2016-10-08 16:42
Machelsky
阅读(83)
评论(0)
推荐(0)
摘要:
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed n 阅读全文
posted @ 2016-10-08 15:23
Machelsky
阅读(105)
评论(0)
推荐(0)
摘要:
Sort a linked list using insertion sort. 思路:插入排序,就是把node插入到左边的链表中。用一个dummynode来构造左边的链表。要是比最左边的数还小,就插到最左边也就是dummy.next。如果不是,则linear search左边的链表插入。 阅读全文
posted @ 2016-10-08 15:13
Machelsky
阅读(113)
评论(0)
推荐(0)
摘要:
Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a 阅读全文
posted @ 2016-10-08 14:39
Machelsky
阅读(117)
评论(0)
推荐(0)
摘要:
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2016-10-08 14:26
Machelsky
阅读(172)
评论(0)
推荐(0)
摘要:
Implement int sqrt(int x). 二分法,找中值。注意不能用low<high来判断。举例:sqrt(5),low<high的话一直在2的右边搜索,最后low=3 high=3是不正确的,要再进入循环去得到最后的结果。 阅读全文
posted @ 2016-10-08 14:04
Machelsky
阅读(123)
评论(0)
推荐(0)