摘要: Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2016-11-27 12:02 lettuan 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2016-11-27 10:05 lettuan 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Brute Force算法,时间复杂度 O(mn 阅读全文
posted @ 2016-11-27 09:32 lettuan 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Reverse a singly linked list.一般,reverse list, reverse list by pair 等都需要三个指针,cur = head, prev, 和当前的下一个temp. 这里在head到达边界之后,还会再走一步,所以对应新的表头的是prev. 1 class Solution(object): 2 def reverseList(self,... 阅读全文
posted @ 2016-11-27 09:26 lettuan 阅读(194) 评论(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-11-27 09:24 lettuan 阅读(145) 评论(0) 推荐(0) 编辑