- 博客(30)
- 收藏
- 关注
原创 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.按照daos
2014-11-10 00:57:04
267
原创 LeetCode Sort List
Sort a linked list in O(n log n) time using constant space complexity.对链表进行归并排序
2014-11-09 23:10:57
367
原创 LeetCode Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN
2014-11-07 21:56:13
335
原创 LeetCode Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without
2014-11-07 14:48:43
277
原创 LeetCode Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku
2014-11-07 12:56:37
309
原创 LeetCode Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille
2014-11-07 11:56:59
269
原创 LeetCode Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.将数组kanz
2014-11-06 19:41:13
346
原创 LeetCode Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the
2014-11-06 19:11:04
310
原创 LeetCode Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,
2014-11-06 18:44:56
451
原创 LeetCode Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each
2014-11-06 17:57:08
313
原创 LeetCode Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur
2014-11-06 14:21:48
320
原创 java数据结构 数组与有序数组
/* * 数组:线性表 */public class MyArray { private long[] arr; //表示有效数据的长度 private int elements; public MyArray(){ arr=new long[50]; } public MyArray(int maxsize){ arr=new long[maxsize]; } /
2014-11-06 11:36:53
474
原创 LeetCode 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(m
2014-11-06 00:13:55
255
原创 LeetCode Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers
2014-11-05 22:34:53
290
原创 LeetCode 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 21:19:17
335
原创 LeetCode 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 ]]
2014-11-05 21:04:28
262
原创 LeetCode Subsets II
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 dupli
2014-11-05 20:08:40
367
原创 LeetCode 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 exa
2014-11-05 19:05:50
337
原创 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-11-05 17:11:51
234
原创 LeetCode 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
2014-11-05 15:57:54
357
原创 LeetCode 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
2014-11-05 15:10:31
292
原创 LeetCode Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically
2014-11-05 12:48:47
320
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人