程序员的世界, 为程序员服务

2016-06-29
LeetCode-Search in Rotated Sorted Array

##题目 ####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 return its index, otherwise return -1. You may assume no duplicate exist

Read More

2016-06-29
LeetCode-Shortest Palindrome

##题目 ####Shortest Palindrome Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa". Given &quo

Read More

2016-06-29
LeetCode-Simplify Path

##题目 ####Simplify Path Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" Corner Cases: Did you consider the case where path = "/../"?In this case, you shoul

Read More

2016-06-29
LeetCode-Single Number II

##题目 ####Single Number II Given an array of integers, every element appears three except for one. Find that single one. ####Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Read More

2016-06-29
LeetCode-Single Number

##题目 ####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 extra memory?

Read More

2016-06-29
LeetCode-Sort Colors

##题目 ####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 0, 1, and 2 to represent the color red, white, and blue respectively. Note:You ar

Read More

2016-06-29
LeetCode-Sort List

##题目 ####Sort List Sort a linked list in O(n log n) time using constant space complexity.

Read More

2016-06-29
LeetCode-Spiral Matrix II

##题目 ####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 ], [ 7, 6, 5 ] ]

Read More

2016-06-29
LeetCode-Spiral Matrix

##题目 ####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 should return [1,2,3,6,9,8,7,4,5].

Read More

2016-06-29
LeetCode-Sqrt(x)

##题目 ####Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x.

Read More

2016-06-29
LeetCode-Subsets II

##题目 ####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 duplicate subsets. For example,If S = [1,2,2], a solution is: [ [2], [1], [1,

Read More

2016-06-29
Spring概述

主要对Spring框架的概念进行阐释,知道为什么要使用Spring。

Read More

2016-06-29
LeetCode-Subsets

##题目 ####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,If S = [1,2,3], a solution is: [ [3], [1], [2], [1,2,3], [1,3], [2,3],

Read More

2016-06-29
LeetCode-Substring with Concatenation of All Words

##题目 ####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 any intervening characters. For example, given:S:

Read More

2016-06-29
LeetCode-Sudoku Solver

##题目 ####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 puzzle… …and its solution numbers marked in red.

Read More

2016-06-29
LeetCode-Sum Root to Leaf Numbers

##题目 ####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 sum of all root-to-leaf numbers. For example, 1 / \ 2 3 The

Read More

2016-06-29
LeetCode-Add Binary

##题目 ####Add Binary Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".

Read More

2016-06-29
LeetCode-Surrounded Regions

##题目 ####Surrounded Regions Given a 2D board containing ‘X’ and ‘O’, capture all regions surrounded by ‘X’. A region is captured by flipping all ‘O’s into ‘X’s in that surrounded region. For example, X X X X X O O X X X O X X O X X After running your function, the board should be: X X X X X X X X X

Read More

2016-06-29
LeetCode-Swap Nodes in Pairs

##题目 ####Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself

Read More

2016-06-29
LeetCode-Symmetric Tree

##题目 ####Symmetric Tree Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following is not: 1 / \ 2 2 \ \ 3 3 ####Note:Bonus points if you could solve

Read More