E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
LeetCode刷题笔记
【
leetcode刷题笔记
】Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great":
·
2015-11-02 10:25
LeetCode
【
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 [
·
2015-11-02 10:24
LeetCode
【
leetcode刷题笔记
】Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string
·
2015-11-02 10:23
LeetCode
【
leetcode刷题笔记
】Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题解:开始想到的方法比较偷懒,直接遍历一遍数组,把每个ListNode对应的值放到数组里面,然后把数组转换成BST,想来这个题的本意肯定不是这样。 自己也想到
·
2015-11-02 10:23
search
binary
【
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 fil
·
2015-11-02 10:21
LeetCode
【
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 ar
·
2015-11-02 10:21
LeetCode
【
leetcode刷题笔记
】Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit strin
·
2015-11-02 10:19
LeetCode
【
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? 判断一个链表是否有环。 题解: 设置两个指针p1和p2; p1每次走一步,p2
·
2015-11-02 10:18
LeetCode
【
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 ],
·
2015-11-02 10:11
LeetCode
【
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? 解题:开始进入一个误区,跟循环链表搞混了,其实这个环的开头可以不在head这里,例如下面的链表也是有环的:
·
2015-11-02 10:08
LeetCode
【
leetcode刷题笔记
】Median of Two Sorted Arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 题解:注意这里对median的理解,如果A,B合并后
·
2015-11-01 13:54
LeetCode
【
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&nb
·
2015-11-01 13:53
partition
【
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
·
2015-11-01 13:53
substring
【
leetcode刷题笔记
】Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matc
·
2015-11-01 13:52
LeetCode
【
leetcode刷题笔记
】Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start tim
·
2015-11-01 13:51
LeetCode
【
leetcode刷题笔记
】Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 题解:就是让实现一个大整数乘法。 假设两个数num1和num2
·
2015-11-01 13:51
LeetCode
【
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. 题解:模拟即可,用carrie
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 题解:转换的方法:从左往右扫描罗马字符,如果当前的字符对应的数字比上一个数字小,就直接加上这个数字;否则加上这个数字并且减去上一个数字的两倍,然后更新上一个数字。
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】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
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A
·
2015-10-31 11:28
conversion
【
leetcode刷题笔记
】Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】Pow(x, n)
Implement pow(x, n). 题解:注意两点: 普通的递归把n降为n-1会超时,要用二分的方法,每次把xn = x[n/2] * x[n/2] * xn-[n/2]*2, [n/2]表示n除以2下取整。 n有可能取负数,负数的时候,先计算pow(x,-n),然后返回1/pow(x,-n); 代码如下: 1 pub
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transacti
·
2015-10-31 11:28
LeetCode
【
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 ta
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】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 poss
·
2015-10-31 11:28
LeetCode
【
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&n
·
2015-10-31 11:28
LeetCode
【
leetcode刷题笔记
】Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. 题解:二分的方法,从0,1,2.....x搜索sqrt(x)的值。 代码如下: 1 public class Solution { 2 public int sqrt(int x) { 3
·
2015-10-31 11:27
LeetCode
【
leetcode刷题笔记
】Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node
·
2015-10-31 11:27
Binary search
【
leetcode刷题笔记
】LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positi
·
2015-10-31 11:27
LeetCode
【
leetcode刷题笔记
】Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 题解:基本的罗马字符和数字对应如下表所示: 罗马字符 数字 I 1 V 5 X 10 L 50 C 100 D 500 M 10
·
2015-10-31 11:27
LeetCode
【
leetcode刷题笔记
】Populating Next Right Pointers in Each Node II
What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example,Given the following binary tree,
·
2015-10-31 11:27
LeetCode
【
leetcode刷题笔记
】Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 类似http://www.cnblogs.com/sunshineatnoon/p/3854935.ht
·
2015-10-31 11:27
LeetCode
【
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
·
2015-10-31 11:27
LeetCode
【
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 =
·
2015-10-31 11:27
partition
【
leetcode刷题笔记
】Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree {3,9,20,
·
2015-10-31 11:26
LeetCode
【
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
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 题解:递归,树的高度 = max(左子树高度,右子树高度)
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 题解:递归解决,用私有变量minDep保存最小的深度,每当
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】Path Sum
Given 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 tree and s
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】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) e
·
2015-10-31 11:26
LeetCode
【
leetcode刷题笔记
】Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, det
·
2015-10-31 10:43
LeetCode
【
leetcode刷题笔记
】3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that
·
2015-10-31 10:43
LeetCode
【
leetcode刷题笔记
】Divide Two Integers
Divide two integers without using multiplication, division and mod operator. 题解:要求不用乘除和取模运算实现两个数的除法。 那么用加减法是很自然的选择。不过如果一次只从被除数中剪掉一个除数会TLE。所以我们借助移位运算,依次从被除数中减去1个除数,2个除数,4个除数......当减不动的时候,再依次
·
2015-10-31 10:43
LeetCode
【
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
·
2015-10-31 10:43
substring
【
leetcode刷题笔记
】Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which t
·
2015-10-31 10:42
substring
【
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&nbs
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Implement strStr()
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 暴力法,从haystack第一个字符开始查找needle。 代码如下: 1 public cl
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题解:最开始用了最naive的方法,每次在k个链表头中找出最小的元素,插入到新链表中。结果果断TLE了。 分析一下,如果这样做,每取出一个节点,要遍历k个链表一
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parenth
·
2015-10-31 10:42
LeetCode
上一页
17
18
19
20
21
22
23
24
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他