
Leetcode
文章平均质量分 75
yskyj
这个作者很懒,什么都没留下…
展开
-
Leetcode--Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Hide Tags Divide and Conquer Linked List Heap Have you met this question in a原创 2015-02-19 11:31:49 · 429 阅读 · 0 评论 -
Leetcode--Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order原创 2014-10-12 21:23:55 · 404 阅读 · 0 评论 -
Leetcode--Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].原创 2014-10-13 11:23:41 · 411 阅读 · 0 评论 -
Leetcode--Permutation
Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 思路:原创 2014-10-13 11:05:59 · 394 阅读 · 0 评论 -
Leetcode--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? 这里的成原创 2014-10-03 11:09:35 · 379 阅读 · 0 评论 -
Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it原创 2014-11-14 20:48:37 · 414 阅读 · 0 评论 -
Leetcode--Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorder it to原创 2014-10-03 13:30:29 · 313 阅读 · 0 评论 -
Leetcode--Single Number
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2014-10-03 19:34:39 · 329 阅读 · 0 评论 -
Leetcode--Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123""132""213""231""3原创 2014-10-14 09:52:28 · 368 阅读 · 0 评论 -
Leetcode--Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to原创 2014-11-14 13:59:01 · 460 阅读 · 0 评论 -
Leetcode--Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited number原创 2014-10-28 21:21:13 · 569 阅读 · 0 评论 -
Leetcode--Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total原创 2014-10-28 21:39:41 · 397 阅读 · 0 评论 -
Leetcode--Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width o原创 2014-10-12 11:23:35 · 390 阅读 · 0 评论 -
Leetcode--Reverse Words in a String
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". click to show clarification. Clarification: What constitutes原创 2014-10-01 21:18:55 · 418 阅读 · 0 评论 -
Leetcode--Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?原创 2014-10-02 23:49:21 · 392 阅读 · 0 评论 -
Leetcode--Sort List
Sort a linked list in O(n log n) time using constant space complexity. 题目原创 2014-10-02 22:37:17 · 370 阅读 · 0 评论 -
Leetcode--Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: ["2", "1",原创 2014-10-01 22:15:02 · 411 阅读 · 0 评论 -
Leetcode--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], [原创 2014-10-12 14:05:00 · 402 阅读 · 0 评论 -
Leetcode--Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"],原创 2014-10-15 10:15:25 · 378 阅读 · 0 评论 -
Leetcode--Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible原创 2014-10-15 09:26:24 · 430 阅读 · 0 评论 -
leetcode--Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.原创 2015-02-22 12:56:54 · 469 阅读 · 0 评论 -
Leetcode--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->1原创 2014-12-16 16:58:33 · 378 阅读 · 0 评论 -
Leetcode-Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". Hide Tags Math String原创 2014-10-21 15:53:00 · 335 阅读 · 0 评论 -
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 ] ] You原创 2014-11-05 15:17:01 · 512 阅读 · 0 评论 -
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 t原创 2014-11-05 10:28:39 · 388 阅读 · 0 评论 -
Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [原创 2014-11-05 19:44:36 · 454 阅读 · 0 评论 -
Leetcode--Count and Say
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 11. 11 is read off as "two 1s" or 21. 21 is read off as原创 2014-10-17 16:20:17 · 460 阅读 · 0 评论 -
Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the follo原创 2014-11-04 11:19:48 · 410 阅读 · 0 评论 -
Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["leet"原创 2014-10-05 10:46:28 · 402 阅读 · 0 评论 -
Leecode--Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(mn) s原创 2014-11-02 14:45:18 · 661 阅读 · 0 评论 -
Leetcode--Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a原创 2014-10-17 16:13:34 · 358 阅读 · 0 评论 -
Leetcode--Minimum Path Sum
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. Note: You can only move either down or right at a原创 2014-10-28 22:46:22 · 665 阅读 · 2 评论 -
Leetcode--Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in t原创 2014-11-01 20:53:48 · 468 阅读 · 0 评论 -
Leetcode--Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", Return 1 s原创 2014-10-15 22:04:57 · 387 阅读 · 0 评论 -
Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bo原创 2014-11-01 14:05:27 · 404 阅读 · 0 评论 -
Unique Paths II
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid原创 2014-11-01 14:26:50 · 371 阅读 · 0 评论 -
Leetcode--Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without usi原创 2014-10-04 11:01:05 · 433 阅读 · 0 评论 -
Leetcode--Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.原创 2014-10-12 11:31:04 · 409 阅读 · 0 评论 -
Leetcode--Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with c原创 2014-10-27 22:06:57 · 643 阅读 · 0 评论 -
Leetcode--Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. Hide Tags Linked List Two Point原创 2014-10-26 19:07:42 · 445 阅读 · 0 评论