
leetcode
文章平均质量分 75
mingtianhuihaode
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode203 Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5public class Solution {原创 2015-10-20 15:48:25 · 343 阅读 · 0 评论 -
nyoj90 整数划分
整数划分时间限制:3000 ms | 内存限制:65535 KB难度:3描述将正整数n表示成一系列正整数之和:n=n1+n2+…+nk, 其中n1≥n2≥…≥nk≥1,k≥1。 正整数n的这种表示称为正整数n的划分。求正整数n的不 同划分个数。 例如正整数6有如下11种不同的划分: 6; 5+1; 4+2,4+1+1; 3+3,3原创 2015-11-23 12:54:13 · 429 阅读 · 0 评论 -
leetcode40 Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina原创 2015-11-22 16:21:21 · 384 阅读 · 0 评论 -
leetcode29 Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.public class Solution { public int divide(int dividend, int divisor) { i原创 2015-11-02 15:19:15 · 353 阅读 · 0 评论 -
leetcode25 Reverse Nodes in k-Group
Reverse Nodes in k-GroupMy SubmissionsQuestionTotal Accepted: 47206 Total Submissions: 181287 Difficulty: HardGiven a linked list, reverse the nodes of a linked list k at a tim原创 2015-11-18 17:19:25 · 492 阅读 · 0 评论 -
leetcode54 Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]原创 2015-11-25 13:47:19 · 326 阅读 · 0 评论 -
leetcode328. Odd Even Linked List
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 value in the nodes.You should try to do it in原创 2016-02-25 10:10:38 · 449 阅读 · 0 评论 -
leetcode77 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,4],]原创 2016-02-26 10:27:49 · 414 阅读 · 0 评论 -
leetcode80 Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi原创 2016-02-26 11:04:12 · 384 阅读 · 0 评论 -
leetcode82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-原创 2016-02-26 14:51:32 · 389 阅读 · 0 评论 -
leetcode39 Combination Sum
Total Accepted: 69250 Total Submissions: 238683 Difficulty: MediumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.原创 2015-11-22 16:19:12 · 313 阅读 · 0 评论 -
leetcode11 Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin原创 2015-10-13 17:28:25 · 271 阅读 · 0 评论 -
leetcode15 3Sum
/**Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.*/import java.util.ArrayList;import jav原创 2015-10-14 16:55:48 · 251 阅读 · 0 评论 -
leetcode257 Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]import java原创 2015-10-22 10:14:45 · 291 阅读 · 0 评论 -
leetcode38 Count and Say
package leetcode38;import java.util.ArrayList;/** * The count-and-say sequence is the sequence of integers beginning as follows: * 1, 11, 21, 1211, 111221, ... * * 1 is read off as "one 1" or原创 2015-10-21 16:24:51 · 343 阅读 · 0 评论 -
leetcode21 Merge Two Sorted Lists
/*Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.*/public class Solution { public static ListNode merg原创 2015-10-09 09:59:55 · 279 阅读 · 0 评论 -
leetcode202 Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares原创 2015-10-09 09:10:06 · 315 阅读 · 0 评论 -
leetcode112 Path Sum
Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary原创 2015-10-11 10:21:33 · 474 阅读 · 0 评论 -
leetcode5 Longest Palindromic Substring
Longest Palindromic SubstringGiven a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic subst原创 2015-10-11 19:52:01 · 309 阅读 · 0 评论 -
leetcode8 String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca原创 2015-10-12 21:27:11 · 351 阅读 · 0 评论 -
leetcode 18 4Sum
/**Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements in a qu原创 2015-11-11 21:15:03 · 299 阅读 · 0 评论 -
leetcode14 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.public class Solution { public String longestCommonPrefix(String[] strs) { StringBuilder sb = new StringBuil原创 2015-10-14 15:07:17 · 324 阅读 · 0 评论 -
leetcode86. 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 of原创 2016-02-26 15:19:57 · 426 阅读 · 0 评论