摘要: Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array.Find it.NoteThere is only one majorit... 阅读全文
posted @ 2014-12-27 23:17 LiBlog 阅读(278) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it.ExampleFor [1, 1, 1, 1, 2, ... 阅读全文
posted @ 2014-12-27 22:55 LiBlog 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the l... 阅读全文
posted @ 2014-12-27 22:46 LiBlog 阅读(607) 评论(0) 推荐(0) 编辑
摘要: Given an array "nums" of integers and an int "k", Partition the array (i.e move the elements in "nums") such that, * All elements = k are moved to th... 阅读全文
posted @ 2014-12-27 22:22 LiBlog 阅读(379) 评论(0) 推荐(0) 编辑
摘要: Using O(1) time to check whether an integer n is a power of 2.ExampleFor n=4, return trueFor n=5, return falseChallengeO(1) timeAnalysis:Use bit manip... 阅读全文
posted @ 2014-12-27 05:13 LiBlog 阅读(1258) 评论(0) 推荐(0) 编辑
摘要: Given an array with integers.Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest.Return the largest difference.NoteThe ... 阅读全文
posted @ 2014-12-27 05:00 LiBlog 阅读(1966) 评论(0) 推荐(1) 编辑
摘要: Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.ExampleGiven [-3, 1, 1, -3, 5... 阅读全文
posted @ 2014-12-27 04:37 LiBlog 阅读(2748) 评论(0) 推荐(0) 编辑
摘要: The size of the hash table is not determinate at the very beginning. If the total size of keys is too large (e.g. size >= capacity / 10), we should do... 阅读全文
posted @ 2014-12-27 03:53 LiBlog 阅读(903) 评论(0) 推荐(0) 编辑
摘要: Given an integer array with no duplicates. A max tree building on this array is defined as follow:The root is the maximum number in the arrayThe left ... 阅读全文
posted @ 2014-12-27 01:40 LiBlog 阅读(3771) 评论(1) 推荐(0) 编辑
摘要: Given an array with positive and negative integers. Re-range it to interleaving with positive and negative integers.NoteYou are not necessary to keep ... 阅读全文
posted @ 2014-12-27 00:52 LiBlog 阅读(293) 评论(0) 推荐(0) 编辑
摘要: Given an directed graph, a topological order of the graph nodes is defined as follow:For each directed edge A-->B in graph, A must before B in the ord... 阅读全文
posted @ 2014-12-27 00:01 LiBlog 阅读(2136) 评论(3) 推荐(0) 编辑