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刷题笔记
】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
【
leetcode刷题笔记
】Simplify Path
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => &quo
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Merge Intervals
Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 题解:首先对所有的区间按照start大小排序,然后遍历排序后的数组,用last
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Valid Number
Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false
·
2015-10-31 10:42
LeetCode
【
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 ve
·
2015-10-31 10:42
LeetCode
【
leetcode刷题笔记
】Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should return all 5 unique BST's shown be
·
2015-10-31 10:41
Binary search
【
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,
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】Anagrams
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 题解: 所谓的anagrams,只若干个词,它们包含的字母的个数和种类完全一样,只是字符的顺序不一样。比如说bus,usb,sub就是一组angr
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 ope
·
2015-10-31 10:41
LeetCode
【
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 shou
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where
·
2015-10-31 10:41
LeetCode
【
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], [
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】Add Binary
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 题解:简单的二进制加法模拟。a,b的最后以为对齐开始进行加法,用carr
·
2015-10-31 10:41
LeetCode
【
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 "
·
2015-10-31 10:41
LeetCode
【
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
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】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 toT. Each number in C may only be used 
·
2015-10-31 10:41
LeetCode
【
leetcode刷题笔记
】Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 题解:以strs[0]为模板,每次挨个查看是否所有的串里面是否第i位上都和strs[0]一样,如果都一样,把i位置上的字符放到answer里面,i++,继续循环,否则返回当前的answer。 代码如下:
·
2015-10-31 10:41
LeetCode
【
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
·
2015-10-31 10:40
LeetCode
【
leetcode刷题笔记
】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 its
·
2015-10-31 10:40
LeetCode
【
leetcode刷题笔记
】Insertion Sort List
Sort a linked list using insertion sort. 题解:实现链表的插入排序。 要注意的地方就是,处理链表插入的时候尽量往当前游标的后面插入,而不要往前面插入,后者非常麻烦。所以每次利用kepeler.next.val和head.val比较大小,而不是kepeler.val和head.val比较大小,因为如果用后者,要把head指向的节点插入到k
·
2015-10-31 10:40
LeetCode
【
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
·
2015-10-31 10:40
LeetCode
【
leetcode刷题笔记
】Jump Game
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. Determine if yo
·
2015-10-31 10:40
LeetCode
【
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.
·
2015-10-31 10:40
LeetCode
【
leetcode刷题笔记
】Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note:&
·
2015-10-31 10:39
LeetCode
【
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. 题解:因为题目要求原地算法,所以我们只能利用矩阵第一行和第一列存放置零信息。 首先遍历第一行和第一列,看他们是否需要全部置零,用两个变量firs
·
2015-10-31 10:39
LeetCode
【
leetcode刷题笔记
】Binary Tree Level Order Traversal(JAVA)
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \
·
2015-10-31 10:39
LeetCode
【
leetcode刷题笔记
】Sort List
Sort a linked list in O(n log n) time using constant space complexity. 题解:实现一个链表的归并排序即可。主要分为三部分: 1.找到中点并返回的函数findMiddle; 2.归并函数merge; 3.排序函数sortList。 数组的findMiddle函数非常容易实现
·
2015-10-31 10:39
LeetCode
【
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 example
·
2015-10-31 10:39
LeetCode
【
leetcode刷题笔记
】Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 题解: 思路比较简单,每条直线都可以表示为y=kx+b,所以对于任意三点,如果它们共线,那么它们中任意两点的斜率都相等。 所以就遍历points数组,对其中
·
2015-10-31 10:39
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? 题解:参见http://www.cnblogs.com/sunshineatnoon/p/3825032.html 代码如下: 1 /** 2
·
2015-10-31 10:39
LeetCode
【
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: [
·
2015-10-31 10:39
LeetCode
【
leetcode刷题笔记
】Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Not
·
2015-10-31 10:35
LeetCode
【
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". 题解:用栈就行了 代码: 1 class Solution { 2 public: 3
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 解题:还是简单的递归,把情况
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Best Time to Buy and Sell Stock II
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 as many transactions as you lik
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 解题:设定一个变量sum存放反转后的答案,每次取输入x的最后一位n,并用sum = sum*10+n更新sum。 例如题设的数字123,初始sum为0,过程如下: 取末尾的3,sum=3,x
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3
·
2015-10-31 10:35
Binary search
【
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): 1 12
·
2015-10-31 10:35
LeetCode
【
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 o
·
2015-10-31 10:35
LeetCode
【
leetcode刷题笔记
】Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return&
·
2015-10-31 10:35
LeetCode
【
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 withou
·
2015-10-31 10:34
LeetCode
【
leetcode刷题笔记
】Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation
·
2015-10-31 09:57
LeetCode
【
leetcode刷题笔记
】Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3
·
2015-10-31 09:57
LeetCode
【
leetcode刷题笔记
】Text Justification
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy app
·
2015-10-31 09:54
LeetCode
【
leetcode刷题笔记
】Word Ladder II
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Ea
·
2015-10-31 09:54
LeetCode
【
leetcode刷题笔记
】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 examp
·
2015-10-31 09:53
LeetCode
【
leetcode刷题笔记
】Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover
·
2015-10-31 09:53
上一页
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
其他