摘要: 1、 Partition an integers array into odd number first and even number second. Given [1, 2, 3, 4], return [1, 3, 2, 4] 2、思路 1、通过两次遍历,不合算。 2、一次遍历,一个从头,一个 阅读全文
posted @ 2016-03-29 17:54 自朗活 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1、 Using O(1) time to check whether an integer n is a power of 2. Example For n=4, return true; For n=5, return false; 2、思路 1、通过二进制,2的power,只有一个1, 3、 阅读全文
posted @ 2016-03-29 16:51 自朗活 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1、 Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Given a List 3->2->1->5->null and n = 2, return nod 阅读全文
posted @ 2016-03-29 15:52 自朗活 阅读(166) 评论(0) 推荐(0) 编辑