摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2016-03-03 09:27 哥布林工程师 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Partition an integers array into odd number first and even number second. Given [1, 2, 3, 4], return [1, 3, 2, 4] public class Solution { /** * @param 阅读全文
posted @ 2016-03-03 08:12 哥布林工程师 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Using O(1) time to check whether an integer n is a power of 2. For n=4, return true; For n=5, return false; 这道题就是看一下这个int二进制各位上总共是否只有一个1,如果只有一个1则是2的n次 阅读全文
posted @ 2016-03-03 07:49 哥布林工程师 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given a boolean 2D matrix, find the number of islands. Given graph: [ [1, 1, 0, 0, 0], [0, 1, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 阅读全文
posted @ 2016-03-03 07:44 哥布林工程师 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 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 node w 阅读全文
posted @ 2016-03-03 07:24 哥布林工程师 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find the subarray with smallest sum. Return the sum of the subarray. For [1, -1, -2, 1], return -3 这道题就是把Maximum Subarray反 阅读全文
posted @ 2016-03-03 07:11 哥布林工程师 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2016-03-03 07:00 哥布林工程师 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2016-03-02 14:20 哥布林工程师 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the 阅读全文
posted @ 2016-03-02 14:08 哥布林工程师 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Merge two given sorted integer array A and B into a new sorted integer array. A=[1,2,3,4] B=[2,4,5,6] return [1,2,2,3,4,4,5,6] 感觉和上一个题没啥区别 class Solut 阅读全文
posted @ 2016-03-02 13:59 哥布林工程师 阅读(154) 评论(0) 推荐(0) 编辑