Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>...
分类:
其他好文 时间:
2014-07-07 16:59:12
阅读次数:
169
Problem Description:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.Solution: 1 public int maxPoint.....
分类:
其他好文 时间:
2014-07-07 16:55:19
阅读次数:
281
Problem Description:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Solution:1 Arrays.sort(A...
分类:
其他好文 时间:
2014-07-07 16:10:04
阅读次数:
174
题目
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down...
分类:
其他好文 时间:
2014-06-30 11:10:34
阅读次数:
211
搭建一个最小代价的网络,最原始的最小生成树的应用。
这里使用Union find和Kruskal算法求解.
注意:
1 给出的数据是原始的矩阵图,但是需要转化为边表示的图,方便运用Kruskal,因为需要sort
2 减少边,一个矩阵最多需要(N*N-N)>>1条边,有人讨论本题是否有向,那是无意义的,因为本题的最小生成树和方向无关。
3 使用Union find是为了判断是否有环,比原...
分类:
Web程序 时间:
2014-06-30 08:10:08
阅读次数:
200
题目
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)).
方法
转换为寻找第k大的数。
...
分类:
其他好文 时间:
2014-06-30 06:05:58
阅读次数:
261
题目
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 operations permitte...
分类:
其他好文 时间:
2014-06-30 00:46:38
阅读次数:
262
【题目】
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
【题意】
给定一个整数以外,其中除了一个整数只出现一次以外...
分类:
其他好文 时间:
2014-06-29 22:52:35
阅读次数:
246
find命令
find pathname -options [-print -exec -ok ...]
-print: find命令将匹配的文件输出到标准输出。
-exec: find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为'command' { } \;,注意{ }和\;之间的空格。
-ok: 和-exec的作用相同,只不过以一种更...
分类:
系统相关 时间:
2014-06-29 20:48:34
阅读次数:
355
题目
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"
Minimum wi...