LinkedList
文章平均质量分 55
WayneShan
这个作者很懒,什么都没留下…
展开
-
【LeetCode】【JAVA】【047】Pascal's Triangle
题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] 思路: 用两层循环逐层求值原创 2015-02-22 09:18:27 · 152 阅读 · 0 评论 -
【LeetCode】【JAVA】【085】Word Break II
题目:https://leetcode.com/problems/word-break-ii/ 思路: 直接用 Recursion超时。取 Word Break 的思路,先 DP 获得 jth 位置可达到的 index,再通过 Recursion 获得所有结果。 Code: public class Solution { ArrayList resAL;原创 2015-04-29 23:29:34 · 178 阅读 · 0 评论 -
【LeetCode】【JAVA】【084】Remove Linked List Elements
题目:https://leetcode.com/problems/number-of-1-bits/ 思路: Nothing Code: public ListNode removeElements(ListNode head, int val) { while(head != null && head.val==val){原创 2015-04-29 22:31:13 · 184 阅读 · 0 评论 -
【LeetCode】【JAVA】【064】Remove Nth Node From End of List
题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end原创 2015-03-24 13:51:56 · 140 阅读 · 0 评论 -
【LeetCode】【JAVA】【062】Subsets
题目: Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example,原创 2015-03-24 12:11:29 · 167 阅读 · 0 评论 -
【LeetCode】【JAVA】【075】Triangle
题目: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4],原创 2015-04-03 02:03:53 · 136 阅读 · 0 评论 -
【LeetCode】【JAVA】【074】House Robber
题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent原创 2015-04-02 10:28:33 · 340 阅读 · 0 评论 -
【LeetCode】【JAVA】【071】Partition List
题目: 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 original relative order of the nodes in each原创 2015-03-26 23:10:05 · 133 阅读 · 0 评论 -
【LeetCode】【JAVA】【069】Combination Sum
题目: Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain原创 2015-03-26 13:19:13 · 134 阅读 · 0 评论 -
【LeetCode】【JAVA】【068】Intersection of Two Linked Lists
题目: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘原创 2015-03-26 09:34:53 · 141 阅读 · 0 评论 -
【LeetCode】【JAVA】【054】Pascal's Triangle II
题目: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?原创 2015-02-25 04:28:47 · 142 阅读 · 0 评论 -
【LeetCode】【JAVA】【048】Combinations
题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,原创 2015-02-24 00:36:41 · 205 阅读 · 0 评论 -
【LeetCode】【JAVA】【055】Binary Tree Level Order Traversal
题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20原创 2015-02-25 04:48:35 · 150 阅读 · 0 评论 -
【LeetCode】【JAVA】【043】Linked List Cycle II
题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space? 思路1: 具体看文章:http://blog.sina.原创 2015-02-21 13:30:00 · 141 阅读 · 0 评论