1 package com.lw.leet1; 2 3 import java.util.Stack; 4 5 /** 6 * @ClassName:Solution 7 * @Description: 8 * Reverse Words in a String 9 ...
分类:
其他好文 时间:
2014-08-15 22:22:49
阅读次数:
205
This problem can be solve in simpler O(NsqrtN) solution, but I will describe O(NlogN) one.
We will solve this problem in offline. For each x (0?≤?x?n) we
should keep all the queries that end in x...
分类:
其他好文 时间:
2014-08-15 21:11:49
阅读次数:
292
You should first runupdate, thenupgrade. Neither of them automatically runs the other.apt-get updateupdates the list of available packages and their v...
分类:
其他好文 时间:
2014-08-15 21:05:19
阅读次数:
229
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 s...
分类:
其他好文 时间:
2014-08-15 19:39:39
阅读次数:
222
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 c...
分类:
其他好文 时间:
2014-08-15 17:18:39
阅读次数:
177
Description
F- Hats
Background
John Hatman, the honest cloakroom attendant of the RoyalTheatre of London, would like to know the solution to the followingproblem.
TheProble...
分类:
其他好文 时间:
2014-08-15 14:37:28
阅读次数:
208
Here another memory for speed implementation:class Solution {public: bool isValidSudoku(vector > &board) { size_t row_cnt = board.size(); ...
分类:
其他好文 时间:
2014-08-15 14:18:48
阅读次数:
194
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 stil...
分类:
其他好文 时间:
2014-08-15 12:07:08
阅读次数:
145
时间限制:0.5s空间限制:15M题意: 给出一个N*M的矩阵A,计算矩阵B,满足B[i][j]=min{ A[x][y]:(y>=j) and ( x>=i+j-y )}Solution : 如图方式从右下角遍历矩阵,那么可令B[i][j]=min(A[i][j],B[...
分类:
其他好文 时间:
2014-08-15 10:40:58
阅读次数:
191
I got a DP solution first which is O(n^2). Apparently it is not a optimized one - think about: it is linear value space. There must be O(n) solution.A...
分类:
其他好文 时间:
2014-08-15 05:04:07
阅读次数:
249