- 博客(44)
- 资源 (2)
- 收藏
- 关注
原创 [LeetCode] Sort List
LeetCode: https://oj.leetcode.com/problems/sort-list/
2014-09-21 22:01:34 447
原创 [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 {1,4
2014-09-21 21:53:23 580
原创 [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 parentheses substring is "()", which
2014-09-21 21:29:22 582
原创 [LeetCode]Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.
2014-09-21 18:05:57 429
原创 [LeetCode] Median of Two Sorted Arrays
Median of Two Sorted ArraysThere 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))LeetC
2014-09-21 17:50:18 478
原创 [LeetCode] Palindrome Partitioning && Palindrome Partitioning II
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",
2014-09-21 17:09:17 382
原创 [LeetCode] Word Break && Word Break II
Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet",
2014-09-21 16:23:50 441
原创 [LeetCode]Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number
2014-09-21 15:24:59 399
原创 [LeetCode] String to Integer(atoi)
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 wha
2014-09-19 16:10:30 453
原创 [LeetCode] Surrounded Regions
Surrounded RegionsGiven 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,
2014-09-19 15:58:59 376
原创 [LeetCode]Merge Intervals && Insert Interval
LeetCode: https://oj.leetcode.com/problems/merge-intervals/
2014-09-19 15:34:29 520
原创 [LeetCode] Reverse Words in a String
Reverse Words in a StringGiven 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
2014-09-14 16:43:23 492
原创 [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 n
2014-09-14 16:03:49 405
原创 [LeetCode] Word Ladder
LeetCode: https://oj.leetcode.com/problems/word-ladder/
2014-09-14 15:44:06 556
原创 Java深度拷贝
基本概念浅拷贝:复制后对象的所有基本类型域的值与原对象相等,所有引用指向的对象和原对象指向的对象相同深拷贝:复制后对象的所有基本类型的值与原对象相等,且他们的引用指向不同的对象,但对象中的基本类型域的值相等,假如其中还包含引用,则指向的对象同样被拷贝了一份,以此类推(即所有引用链上的对象都被拷贝了一份)依赖clone方法的深度拷贝在Java的Object类中有一个clone方法
2014-09-13 22:52:46 1286
原创 [LeetCode]Combinations
LeetCode: https://oj.leetcode.com/problems/combinations/该题采用DFS的方法来解决,和Permutations,N-Queens的解决方式类似:代码如下:public class Solution { public List> combine(int n, int k) { List> comb
2014-09-12 19:50:20 397
原创 [LeetCode]Binary Tree Maximum Path Sum
LeetCode: https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/
2014-09-12 19:40:15 438
原创 [LeetCode] Path Sum && Path Sum II
Path Sum: https://oj.leetcode.com/problems/path-sum/Path Sum II: https://oj.leetcode.com/problems/path-sum-ii/
2014-09-12 18:54:23 497
原创 [LeetCode] Search in Rotated Sorted Array
LeetCode: https://oj.leetcode.com/problems/search-in-rotated-sorted-array/
2014-09-12 16:20:27 408
原创 树的遍历
本文对树的遍历操作做个总结:1. 前序遍历递归实现:public class Solution { public List preorderTraversal(TreeNode root){ List result = new ArrayList(); preOrder(result, root); return result; } private void pr
2014-09-12 15:26:26 366
原创 网络IO总结
网络IO的模式包括同步IO,异步IO,阻塞IO,非阻塞IO;这些IO模式之间的区别和联系是任何一个搞网络编程(Socket编程)的人必须弄清楚的问题,下面我们就来一层层的揭开他们的面纱吧。在Unix网络编程第一卷第六章中讨论了五种IO模型:1. 阻塞IO(Blocking IO)2. 非阻塞IO(Nonblocking IO)3. IO多路复用(IO multiplexing)
2014-09-10 16:55:05 503
原创 递归思想解决经典问题
递归是一个非常经典的算法思想,很多问题都可以采用递归来解决,特别是对于树、字符串这类本身就具有递归性质的数据结构相关的问题,下面就列出几个可以用递归来解决的经典问题:1. 字符串排列问题(不包含相同字符)该问题要求求出字符串的所有排列,我们可以循环遍历整个字符串,将每次循环遇到的字符和第一个位置的字符交换,然后求剩下字符串的所有排列;对于剩下的字符串,重复前面的过程,所以这是个递归的过
2014-09-09 21:05:30 962
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人