- 博客(42)
- 收藏
- 关注
原创 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 / 3return [1,3,2].Note: Recursive solutio
2016-02-29 22:53:39 219
原创 lintcode: Palindrome Partitioning II
Palindrome Partitioning II 30:00Given a string s, cut s into some substrings such that every substring is a palindrome.Return the minimum cuts needed for a palindrome partiti
2016-02-28 15:26:52 291
原创 lintcode: 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.Have you met this question in a real interview?Exa
2016-02-28 00:28:04 284
原创 lintcdoe: Number of Airplanes in the Sky
Number of Airplanes in the Sky 30:00Given an interval list which are flying and landing time of the flight. How many airplanes are on the sky at most?Have you met this questi
2016-02-27 23:24:58 524
原创 lintcode:Restore IP Addresses
Restore IP Addresses 30:00Given a string containing only digits, restore it by returning all possible valid IP address combinations.Have you met this question in a real inter
2016-02-27 23:17:06 368
原创 Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return -1 instead.Have you met this question in a real
2016-02-27 22:08:43 283
原创 leetcode:Kth Smallest Element in a B
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the
2016-02-26 23:38:23 195
原创 lintcode: Remove Nth Node From End of List
Remove Nth Node From End of List You have exceeded the time limitGiven a linked list, remove the nth node from the end of list and return its head.Have you met this question
2016-02-26 00:16:27 246
原创 lintcode: Kth Smallest Number in Sorted MatrixShow result
Kth Smallest Number in Sorted MatrixShow result 30:00 StartFind the kth smallest number in at row and column sorted matrix.Have you met this question in a real intervie
2016-02-26 00:13:59 373
原创 lintcode:Remove Node in Binary Search Tree
Remove Node in Binary Search Tree You have exceeded the time limitGiven a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no
2016-02-25 22:57:47 418
原创 lintcode:Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2016-02-25 15:32:51 317
原创 leetcode:Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extr
2016-02-24 23:29:12 199
原创 leetcode:Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a
2016-02-24 23:27:48 303
原创 leetcode:Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o
2016-02-24 16:32:51 302
转载 设计一个只能在堆上或栈上实例化的类
转自:http://www.cnblogs.com/luxiaoxun/archive/2012/08/03/2621827.html一道C++笔试题:设计一个只能在堆内存上实例化的类和一个只能在栈内存上实例化的类只能在堆内存上实例化的类:将析构函数定义为private,在栈上不能自动调用析构函数,只能手动调用。也可以将构造函数定义为private,但这样需要手动写一个函数
2016-02-20 23:17:13 665
转载 c++设计一个不能被继承的类,为什么必须是虚继承?原因分析
转自:http://my.oschina.net/cuilili/blog/323696用C++实现一个不能被继承的类(例1)?12345678910111213141516171819202122232425262728293031
2016-02-20 23:08:26 320
转载 Google面试题(java)—有四个线程1、2、3、4。线程1的功能就是输出1,线程2的功能就是输出2,以此类推.........现在有四个文件ABCD
转自:http://blog.csdn.net/b275518834/article/details/8750142import java.util.ArrayList;import java.util.HashMap;import java.util.List;public class CallThread { private static class MyRunabl
2016-02-20 22:59:26 1982 1
转载 Epoll在LT和ET模式下的读写方式
转自:http://www.ccvita.com/515.html在一个非阻塞的socket上调用read/write函数, 返回EAGAIN或者EWOULDBLOCK(注: EAGAIN就是EWOULDBLOCK)从字面上看, 意思是:EAGAIN: 再试一次,EWOULDBLOCK: 如果这是一个阻塞socket, 操作将被block,perror输出: Res
2016-02-20 22:14:09 283
转载 TCP协议中的三次握手和四次挥手(图解)
转自:http://blog.csdn.net/whuslei/article/details/6667471建立TCP需要三次握手才能建立,而断开连接则需要四次握手。整个过程如下图所示:先来看看如何建立连接的。首先Client端发送连接请求报文,Server段接受连接后回复ACK报文,并为这次连接分配资源。Client端接收到ACK报文后也向Server段
2016-02-20 20:58:13 298
转载 网络编程中的Socket详解---Delayed Ack(Ack确认延迟) && Nagle Algorithm(纳格算法)
转自:http://www.tuicool.com/articles/YfM7nm今天开始学习Socket编程,但是上网查询的一些资料之后发现与之相关的知识太多了,所以我从基础看起,慢慢来,首先来看一下Delayed Ack 和 Nagle Algorithm的内容。1.Delayed Acktcp协议规定在接受到数据段时需要向对方发送一个确认,但如果只是单纯的发送
2016-02-20 17:43:07 941
原创 leetcode:Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret
2016-02-20 16:01:23 197
原创 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 nu
2016-02-20 14:08:13 250
转载 堆排序
转自:http://www.cnblogs.com/hanxi/archive/2012/10/12/2721540.html在程序设计相关领域,堆(Heap)的概念主要涉及到两个方面:一种数据结构,逻辑上是一颗完全二叉树,存储上是一个数组对象(二叉堆)。 垃圾收集存储区,是软件系统可以编程的内存区域。本文所说的堆,指的是前者。堆排序的时间复杂度是O(nlgN),与
2016-02-19 23:36:31 189
原创 leetcode: Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
2016-02-19 21:03:46 229
原创 leetcode:Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Subscribe to see which companies asked this question/** * Definition for a binary tree n
2016-02-19 19:37:57 211
原创 leetcode:Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.
2016-02-19 19:25:33 240
转载 快速排序
转自: http://www.myexception.cn/cpp/1887480.html快速排序的递归和非递归实现 -----C++、JAVA代码实现快速排序的基本思想是:通过一趟排序将待排记录分割成独立的两部分,其中一部分记录的关键字均比另一部分记录的关键字小,则可分别对这两部分记录继续进行排序,已达到整个序列有序.快速排序是一种不稳定的排序方法,其平均时间复杂度为:O(
2016-02-18 23:30:43 200
原创 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 to T.Each number in C may only be used once in the combina
2016-02-17 01:40:02 216
原创 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.Subscribe to see which companies asked this questionclass Solution {
2016-02-16 23:34:45 210
转载 elevator design example
转自:http://careercup.com/question?id=5698327039442944repose with format corrected*public class Elevator { public static final int MAX_FLOORS = 50; // upward floor queue private Priorit
2016-02-14 19:28:34 411
原创 leetcode:Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co
2016-02-13 21:07:00 294
原创 leetcode:Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each
2016-02-13 18:20:03 280
原创 leetcode:Additive Number
Additive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the s
2016-02-13 11:11:34 353
原创 leetcode:Remove Invalid Parentheses
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( and).
2016-02-13 11:09:39 383
原创 leetcode:Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousand Thre
2016-02-13 11:07:49 236
原创 leetcode: Basic Calculator
Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty
2016-02-13 11:06:08 236
原创 leetcode:Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z. class TrieNode { public: TrieNode *nodeMap
2016-02-13 11:04:24 175
原创 leetcode:Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o
2016-02-13 11:01:47 188
原创 leetcode:Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is9534330.Note: The result may be very
2016-02-13 10:59:46 196
原创 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 "()",
2016-02-13 00:23:44 230
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人