由买买提看人间百态

topics

全部话题 - 话题: subset
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
m*********s
发帖数: 368
1
来自主题: Mathematics版 - 请教一个小的分析问题。
定义硬来
dense, 所以存在 a sequence {x_n} in A -> x, for any x in X
连续函数, 所以 f(x) = lim f(x_n) \in cl(f(A))
f(X) subset cl(f(A)), so cl(f(X)) subset cl(f(A))
反过来 cl(f(A)) subset cl(f(X)), 因为 f(A) \subset f(X)
so cl(f(A)) = cl(f(X))
当f(X) 是一个闭集的时候两者相等, 反之就是只有 f(X) subset cl(f(A))
j*****u
发帖数: 1133
2
来自主题: JobHunting版 - Facebook Phone Inteview + 流程请教
just wrote a non-recursive subset function in C#
static IList> GetSubsets(ISet set)
{
if (set == null)
throw new ArgumentNullException("set");
List> list = new List>();
var allElements = set.ToArray();
for (int i = 0; i < (1 << set.Count); ++i)
{
var subset = new HashSet();
int mask = i;
int index = 0;
while (mask > 0)
{
if ((mask & 0x1) != 0)
subset.Add... 阅读全帖
j*****u
发帖数: 1133
3
来自主题: JobHunting版 - Facebook Phone Inteview + 流程请教
just wrote a non-recursive subset function in C#
static IList> GetSubsets(ISet set)
{
if (set == null)
throw new ArgumentNullException("set");
List> list = new List>();
var allElements = set.ToArray();
for (int i = 0; i < (1 << set.Count); ++i)
{
var subset = new HashSet();
int mask = i;
int index = 0;
while (mask > 0)
{
if ((mask & 0x1) != 0)
subset.Add... 阅读全帖
L**********u
发帖数: 194
4
来自主题: JobHunting版 - Exposed上一道string permutation的题
This problem can be solved by binary representation of an integer.
I am a rookie of C++. thanks for comments
my codes
#include
#include
#include
using namespace std;
const int N=5;
void subset(int arr[], int n)
{
bitset n_bit(n);
cout<<"{";
for(int i=0;i if(n_bit[i]==1)
cout< cout<<"};";
cout< }
//main function
int main()
{
cout<<"The set has "< int arr[N];
for(int i=0;i arr[i]=... 阅读全帖
p*****2
发帖数: 21240
5
来自主题: JobHunting版 - 面试题总结(2) - Two/Three pointers
面试题总结(3) - Permutation and Combination
基本题,但是非常重要。面试中碰到任何一题一点也不奇怪。PIE, CC150和Leetcode都
不约而同地包含了这类题。把这些题目做熟是必须的。基本上来说这类题的解法都是
DFS,程序的大体框架非常类似,只是根据题目的要求代码稍作修改。当然每道题也有
不同的解法,但是你应该根据自己的喜好把这类题目的解决方案统一化。熟悉了这类题
目以后对于DFS(will be discussed in a separate section) 的理解会非常深刻。基
本上一般的DFS的题目应该没什么问题了。
无论是排列还是组合,这类题都有一个变形,就是要求不能有重复的输出。PIE和CC150
都没有提到相应的解法,大家应该很好的体会一下。如果没有相应的准备,属于面试的
时候比较容易跪的题目。
Permutation
输入没有重复:Permutations, CC150 9.5, PIE Chapter7 Permutations of a String
输入有重复,输出不能有重复:Permutations II
Next Per... 阅读全帖
p*****2
发帖数: 21240
6
来自主题: JobHunting版 - 我的面试题总结
好多人问,我就发到这里吧。
面试题的构成和分类
首先声明一下,这里的面试题主要所指数据结构和算法的题目,题目的分析集中在
Leetcode上面的题目上。
我认为一道面试题由以下几个方面组成的
Question
Data structure in question
Data structure in solution
Algorithm in solution
Coding
题目:非常关键,一个题目通常有一些相应的变形题目,同一个题目可能有不同的要求
。比如时间复杂度,空间复杂度的要求,比如recursive,
iterative的要求。而根据题目的变形与要求,可能会极大的影响到你能够采取的数据
结构和算法。
问题中的数据机构:问题中有可能带数据结构,有可能没有数据结构,有可能是可以自
定义数据结构
解决方案中的数据结构:可以是in-place的,也就是利用已有的数据结构,也可能是创
建新的数据结构。新的数据结构跟已有的数据结构没有必然的联系,而很多问题都是一
题多解,可能采取不同的数据结构。
算法:一般来说,当解决方案中的数据结构确定以后,算法也就确定了。同样,一旦解
决方案的算法确定... 阅读全帖
p*****2
发帖数: 21240
7
来自主题: JobHunting版 - 我的面试题总结
好多人问,我就发到这里吧。
面试题的构成和分类
首先声明一下,这里的面试题主要所指数据结构和算法的题目,题目的分析集中在
Leetcode上面的题目上。
我认为一道面试题由以下几个方面组成的
Question
Data structure in question
Data structure in solution
Algorithm in solution
Coding
题目:非常关键,一个题目通常有一些相应的变形题目,同一个题目可能有不同的要求
。比如时间复杂度,空间复杂度的要求,比如recursive,
iterative的要求。而根据题目的变形与要求,可能会极大的影响到你能够采取的数据
结构和算法。
问题中的数据机构:问题中有可能带数据结构,有可能没有数据结构,有可能是可以自
定义数据结构
解决方案中的数据结构:可以是in-place的,也就是利用已有的数据结构,也可能是创
建新的数据结构。新的数据结构跟已有的数据结构没有必然的联系,而很多问题都是一
题多解,可能采取不同的数据结构。
算法:一般来说,当解决方案中的数据结构确定以后,算法也就确定了。同样,一旦解
决方案的算法确定... 阅读全帖
D*********G
发帖数: 193
8
看到版上很多水平不错的同胞,经常因为一些bug而没拿到offer,非常可惜。
分享一下,如何避免coding bug的一些心得.
1.平常训练的时候,尽量遵循以下原则:
a) 确定输入,输出
b) 先举例(这里举例不用太考虑Conner case),例如subset I,就可以用[1,2]; subset
II,就可以用[1,2,2]
c) 然后确定算法、方法.例如subset I,很多人都用BFS,但是面试官往往会问你一些
trade off,然后eventually让你试试DFS.
d) 然后写出简单思路(类似于comments或者pseudo code)
e) 写代码,如果是dfs,最好先实现dfs sub-function. 如果step d做得好,写代码的
过程注意力要全部放在代码的精简性和可读性。要知道,programming "language",这
个language真的是有语言的意义的,好的代码,一看就懂!
f) 写完代码之后,再测试更多的例子,例如subset II,可以试 [], [1], [1,1],...
之类的。可以花1-2分钟检查更多的例子,但是不宜过久。... 阅读全帖
D*********G
发帖数: 193
9
看到版上很多水平不错的同胞,经常因为一些bug而没拿到offer,非常可惜。
分享一下,如何避免coding bug的一些心得.
1.平常训练的时候,尽量遵循以下原则:
a) 确定输入,输出
b) 先举例(这里举例不用太考虑Conner case),例如subset I,就可以用[1,2]; subset
II,就可以用[1,2,2]
c) 然后确定算法、方法.例如subset I,很多人都用BFS,但是面试官往往会问你一些
trade off,然后eventually让你试试DFS.
d) 然后写出简单思路(类似于comments或者pseudo code)
e) 写代码,如果是dfs,最好先实现dfs sub-function. 如果step d做得好,写代码的
过程注意力要全部放在代码的精简性和可读性。要知道,programming "language",这
个language真的是有语言的意义的,好的代码,一看就懂!
f) 写完代码之后,再测试更多的例子,例如subset II,可以试 [], [1], [1,1],...
之类的。可以花1-2分钟检查更多的例子,但是不宜过久。... 阅读全帖
s*********t
发帖数: 36
10
来自主题: JobHunting版 - Linkedin八月onsite面经
怎么下面觉得下面的不对?不是subset啊。 subset of longest palindrome subset
至少第一个和最后一个要一样, 然后只要中间有palindrome 就是一个subset,我觉得
应该是:
bool D[][]
len = [3, array.size()-3]
if s(i) == s(j) &&(D(i+1, j-1)| D(i, j-1) | D(i+1, j)
maxLen = len
是这样吗?
c******n
发帖数: 145
11
来自主题: JobHunting版 - 问两道fb题

0
我觉得你这方法不错啊
减去平均数后,找出新序列的subset sum = 0
有现成的DP算法求subset sum,可以找出所有的subsets来
然后计算每个subset的长度,找出最短的来就行了
o*q
发帖数: 630
12
来自主题: JobHunting版 - 请教leetcode高频题是哪些题
# Title Editorial Acceptance Difficulty Frequency
1
Two Sum 28.3% Easy
292
Nim Game 54.4% Easy
344
Reverse String 57.3% Easy
136
Single Number 52.2% Easy
2
Add Two Numbers 25.6% Medium
371
Sum of Two Integers 51.6% Easy
4
Median of Two Sorted Arrays
20.4% Hard
6
ZigZag Conversion 25.6% Easy
13
Roman to Integer 42.7% Easy
237
... 阅读全帖
a**s
发帖数: 9606
13
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
1. 下载VirtualDub
http://virtualdub.sourceforge.net/
2. 下载并安装Plugin
http://codecpack.co/download/FFInputDriver.html
下载后解压缩到VirtualDub安装目录下的Plugin目录 (或者Plugin32/Plugin64)
3. 下载安装 XVid 或者 X264 encoder
xvid: http://www.xvid.org/Downloads.15.0.html
h264: http://sourceforge.net/projects/x264vfw/
俺习惯用XVid, 这里有个很老的设置介绍:
http://www.doom9.org/index.html?/xvid-vdub-final.htm
4. 安装好1-3, 尝试打开一个摄像机视频文件(可以drag-n-drop). 如果顺利打开,
就应该压缩没有问题了. 如果不能打开, 可能是缺相应格式的plugin. Google一
下应该能找到.
5. 按Ctrl+P, 视频压缩窗口会弹出, 选"XviD MP... 阅读全帖
a**s
发帖数: 9606
14
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
def ReadVDScript(strJsFile):
lstSubs=[]
lstVideoFile=[]
strOutFile = ""
fpJs=open(strJsFile, 'r')
strScript=fpJs.read()
fpJs.close()

# Get videos source(s)
# VirtualDub.Open("2012.12.08.vs.Tim.avi","",0);
# VirtualDub.append("2.MOV")
n1 = strScript.find('.Open') + 5
if n1>4:
n1 = strScript.find('"', n1) + 1
lstVideoFile.append(strScript[n1:strScript.find('"', n1)])
... 阅读全帖
a**s
发帖数: 9606
15
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
1. 下载VirtualDub
http://virtualdub.sourceforge.net/
2. 下载并安装Plugin
http://codecpack.co/download/FFInputDriver.html
下载后解压缩到VirtualDub安装目录下的Plugin目录 (或者Plugin32/Plugin64)
3. 下载安装 XVid 或者 X264 encoder
xvid: http://www.xvid.org/Downloads.15.0.html
h264: http://sourceforge.net/projects/x264vfw/
俺习惯用XVid, 这里有个很老的设置介绍:
http://www.doom9.org/index.html?/xvid-vdub-final.htm
4. 安装好1-3, 尝试打开一个摄像机视频文件(可以drag-n-drop). 如果顺利打开,
就应该压缩没有问题了. 如果不能打开, 可能是缺相应格式的plugin. Google一
下应该能找到.
5. 按Ctrl+P, 视频压缩窗口会弹出, 选"XviD MP... 阅读全帖
a**s
发帖数: 9606
16
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
def ReadVDScript(strJsFile):
lstSubs=[]
lstVideoFile=[]
strOutFile = ""
fpJs=open(strJsFile, 'r')
strScript=fpJs.read()
fpJs.close()

# Get videos source(s)
# VirtualDub.Open("2012.12.08.vs.Tim.avi","",0);
# VirtualDub.append("2.MOV")
n1 = strScript.find('.Open') + 5
if n1>4:
n1 = strScript.find('"', n1) + 1
lstVideoFile.append(strScript[n1:strScript.find('"', n1)])
... 阅读全帖
g*******y
发帖数: 1930
17
来自主题: Programming版 - 问一个选区划分问题的复杂度
Good idea to consider set partition
But I think there's a flaw, in election zone problem, a valid partition will
result in that the sum of subset falls within a certain range.
For example, m1, m2, m3 ... m_n are votes for party A:
M = sum of {m1...m_n}
a subset with n/2 element: {m_i1, m_i2,...m_i(n/2)}
X = sum of {m_i1, m_i2,...m_i(n/2)}
a valid partition requires:
nm/4 < X < M-nm/4
which means the target subset sum is a range, not a single value;
in contrast, in the Subset NPC problem, the tar
f********x
发帖数: 99
18
The world beyond batch: Streaming 101: A high-level tour of modern data-
processing concept
http://radar.oreilly.com/2015/08/the-world-beyond-batch-streami
by Tyler Akidau August 5, 2015
Editor’s note: This is the first post in a two-part series about the
evolution of data processing, with a focus on streaming systems, unbounded
data sets, and the future of big data.
Streaming data processing is a big deal in big data these days, and for good
reasons. Amongst them:
Businesses crave ever more tim... 阅读全帖
t*****n
发帖数: 225
19
来自主题: Mathematics版 - Is there such a "measure" on integers?
Define a finitely additive measure F on all the subsets
of the set Z of integers as follows:
For any subset S of integers, any positive integer n,
define f_S(n)=1/n if n is in S, and f_S(n)=0 if n is not in S.
Then f_S1+f_S2= f_S if S is the union of 2 disjoint subsets S1 and S2.
Define F(S)=lim (f_S(1)+...+f_S(n))/log n,
then
1. F(S)=0 for any finite subset S.
2. F(S) is non-negative.
3. F(S) is finitely additive.
4. F(Z)=1.
楼主发包子吧

of the set of
z***9
发帖数: 1052
20
来自主题: Statistics版 - R问题求救,在线等
现有3000多个观察者,7个变量,每个变量都有两个level,Y or N。每个观察者都会属
于一个subset(比如YYYYYYY,NNNNNNN,YNNNNNN).很明显一共有2^7=128个subset。要求
把128个subset列出来,并把每一个subset拥有的观察者列出来。
高手路过,千万不要错过。跪谢。
c***z
发帖数: 6348
21
Any subset or min subset? For any subset, just use the mother set.
For min subset, it is the min submatrix of a binary matrix with respect to:
1. row.sum >= M
2. col.sum >= N
I would try dynamic programming but I am brain dead to think about the
details now.
A heuristic is to move a 2Mx2N submatrix around to see if we get lucky.
b*****e
发帖数: 474
22
来自主题: JobHunting版 - MS onsite 面经
关于这道题大家想多了。就是一个直接的依次找下一个字符吧
int check(char *p, char *s){ // p: pattern, s: string, both non-NULL
if (*p=='\0') return 1; // is subset
while (*s) {
if ( *p==*s++) p++;
if (*p=='\0') return 1;
}
return 0; // not subset
}
6)
Find whether one string is a subset of another string (not need to be
contiguous, but order should match).
x********o
发帖数: 519
23
来自主题: JobHunting版 - 问个算法题,修改版
here is the C++ code:
#include
#include
#include
using namespace std;
void print_vector(const vector &v){
vector::const_iterator iter=v.begin();
while(iter!=v.end()){
cout<<*iter<<" ";
++iter;
}
cout< }
void subset(vector v, vector sub, int size,set > &s){
if(sub.size()==size){
sort(sub.begin(),sub.end());
s.insert(sub);
return;
}
vector::iterator iter=v.begin();
size_t l=v.size();
for(int ... 阅读全帖
f*********i
发帖数: 197
24
来自主题: JobHunting版 - 问一道题(1)
不好意思,是我没有把题目说清楚.
是把这个array里面的integer分到两个subsets里面,所以貌似一个NP问题.
我觉得关键是在如何减枝操作,如果都是positive的话,应该可以用DP来做把,维护两个
subsets,然后不断添加.
或者,divide and conquer, 如果有类似a1+a2=a3+a4,那么这四个数就自动归类到两个
subsets中,这样可以减少比较次数,当然,要考虑a1+a3=a2+a4,或者其他combination的
情况.
没有头绪....
g**********y
发帖数: 14569
25
来自主题: JobHunting版 - 问一道题(1)
想了一下,这个还是可以用DP解, 复杂度是O(K*n^2)
a是输入数组
n = a.length
K = sum(a)
A = average(a)
S = new boolean[n][K][n] (第一维是subset最大可用的数范围,第二维是subset和,
第三维是subset size)
S[0][0][0] = true;
for i=1 to n {
for j=1 to K {
for k=1 to n {
S[i][j][k] = S[i-1][j][k] || (j>a[i] && S[i-1][j-a[i]][k-1]);
}
}
}
best = Integer.MAX_VALUE
for i=1 to n {
avg = A * i;
find t closest to avg that S[n][t][i] = true;
if |t/i - avg| < |best - avg| then best = t/i;
}
return best;
a**********2
发帖数: 340
26
来自主题: JobHunting版 - 问道老题
given a set of distinct integers {a1, a2, a3, a4, a5, ...}
and a set of exclusion rules: R = {{a1, a3}, {a2, a4, a10}, ...}
can you print out all the valid subsets?
Example:
what is a valid subset? {a1, a4}
what is an invalid subset? {a1, a2, a4}
A**u
发帖数: 2458
27
来自主题: JobHunting版 - 请教一个题目
career cup 上的题目
Write a method that returns all subsets of a set.
想请教一下,递归的怎么写呢
这是career cup的java写法,我不懂java,完全看不懂, 请大家给个算法思路
ArrayList> getSubsets(ArrayList set,
2 int index) {
3 ArrayList> allsubsets;
4 if (set.size() == index) {
5 allsubsets = new ArrayList>();
6 allsubsets.add(new ArrayList()); // Empty set
7 } else {
8 allsubsets = getSubsets(set, index + 1);
9 int item = set.get(index);
10 ArrayList阅读全帖
k***t
发帖数: 276
28
来自主题: JobHunting版 - Exposed上一道string permutation的题
Given a string, print out all subsets. Each subset is a string with some, or
all, characters in the original string.The original string may have
duplicated characters. The output shouldn't contain any duplicated subset
strings.
E*******0
发帖数: 465
29
来自主题: JobHunting版 - 请教最优算法:最多装满水的桶?
换一个说法:
1st step:
Given an integer array, and a value. Find a subset of the array such that
the sum equals the value.
2nd step:
Given an integer array, and a value. Find maximal groups of subset such that
the sum of each group equals the value.
3rd step:
Given an integer array, and a value. Find maximal groups of subset such that
the sum of each group equals to or bigger than the value.
t****a
发帖数: 1212
30
初学者,给一个lisp的解:
(defn all-subset [s]
(if (= (count s) 1)
[s]
(let [fst (first s)
rst (rest s)
rst-sub (all-subset rst)
new-sub (map #(cons fst %) rst-sub)
all-sub (concat [[fst]] rst-sub new-sub)]
all-sub)))
(all-subset [1 2 3 4 5])
; ([1] [2] [3] [4] (5) (4 5) (3 4) (3 5) (3 4 5) (2 3) (2 4) (2 5) (2 4 5) (
2 3 4) (2 3 5) (2 3 4 5) (1 2) (1 3) (1 4) (1 5) (1 4 5) (1 3 4) (1 3 5) (1
3 4 5) (1 2 3) (1 2 4) (1 2 5) (1 2 4 5) (1 2 3 4) (1 2 3 5... 阅读全帖
r*********n
发帖数: 4553
31
来自主题: JobHunting版 - phone interview question
类似http://people.csail.mit.edu/bdean/6.046/dp/ 里面的第7题balanced partition
假设A是3的倍数,n是数列长度
vector DP[0,1,...,A][0,1,...,n-1]
every time you consider a new integer, fill in one column of DP,the
difference between this problem and the balanced partition problem is that
DP[s][i] is now a vector contains all indices leading to subset sum being
equal to s。
when you back track starting at DP[A/3][n-1], you can easily get all
feasible subsets. Then it's not difficult to determine whether three of them... 阅读全帖
h**o
发帖数: 548
32
来自主题: JobHunting版 - 什么情况下用dynamic programming?
为什么象 leetcode 里 subsets 这种题没人用 DP 哪?
每个分支下也有重复运算啊? 例如 算123时的23 和 算23时的23.
还是太复杂了不值得?
subsets problem:
Given a set of distinct integers, S, return all possible subsets.
For example, If S = [1,2,3], a solution is:
[
[3],
[1],
[2],
[1,2,3],
[1,3],
[2,3],
[1,2],
[]
]
g***j
发帖数: 1275
33
来自主题: JobHunting版 - 分享一下面试题目
周四面的,具体哪个公司就不说了,说是周一周二给结果,但愿好运了。
分享一下面试题目,也refresh一下我的memory
1 给一堆整数,所有数都是偶数次,只有一个出现奇数次,如何求出这个数;
给一堆整数,求出所有出现奇数次的整数;
两个鸡蛋,100层楼,求出哪儿破,我说我听说过了,没有继续问了。
然后又问了一个,给定两个date,如何判断差别是否less than one month;great
than one month; exactly one month;
都要写code,最后一个没有写完,不过对方说,不要紧,本来就是extra question,可
能他想问我鸡蛋题,我说听说过了,他改问了这个。
2 给一个tree,定义height是根节点到叶子节点的距离中最短的一个,如何求出这个距
离; 后来又问了bfs和dfs的区别
给一个array of int,要求实现power set,设计一个class,1)判断是否有下一个
subset;2)如果又,给出下一个subset。不管你什么标准输出subset,要求不重复;
都要求写code
如果project deadline 无... 阅读全帖
S*******C
发帖数: 822
34
http://oj.leetcode.com/problems/subsets/
第一种格式:res作为局部变量避免线程安全问题,但比较啰嗦
public ArrayList> subsets(int[] num){
if(num==null) return null;
Arrays.sort(num);
ArrayList> res=new ArrayList>(
);
res.add(new ArrayList());// [[]]
dfs(res, num,0,new ArrayList());
return res;
}
private void dfs(ArrayList> res, int[] num, int pos,
ArrayList temp){... 阅读全帖
b***e
发帖数: 1419
35
来自主题: JobHunting版 - 问道G家的题
This reduces to:
http://en.wikipedia.org/wiki/Minimum-cost_flow_problem
Only strings of the same length as the target string are candidates of a
potential conflict. Compute the intersection of each candidates with the
target. In your example:
“apple”, [“plain”, “amber”, “blade”]
We get [{1}, {0}, {4}]. Then the task is to find the smallest set that is
not totally included in any of the intersections. In this case, {2} is good
. So the answer should be "2p2". From another angle to look at
i... 阅读全帖
b***e
发帖数: 1419
36
来自主题: JobHunting版 - 问道G家的题
This reduces to:
http://en.wikipedia.org/wiki/Minimum-cost_flow_problem
Only strings of the same length as the target string are candidates of a
potential conflict. Compute the intersection of each candidates with the
target. In your example:
“apple”, [“plain”, “amber”, “blade”]
We get [{1}, {0}, {4}]. Then the task is to find the smallest set that is
not totally included in any of the intersections. In this case, {2} is good
. So the answer should be "2p2". From another angle to look at
i... 阅读全帖
q****m
发帖数: 153
37
来自主题: JobHunting版 - 问几道glassdoor上面的题
1 return n closest points on a plane
这个题目是什么意思?
同样类似的
Find the nearest K point given a set of N point.
2 find the largest subsequence given an array that yields the largest sum
Find maximum sum subset in an array with negative integers
这两题,一个是subsequence一个是subset,如果不是连续的,难道不是所有的正数加
起来就行了么?
同理这样的两题
largest subsequence of the given array that yields the largest PRODUCT
Maximum product subset with negative and positive integers
h*********8
发帖数: 73
38
来自主题: JobHunting版 - Linkedin八月onsite面经
面的application组
1.Design tinyurl
面试的是一个台湾人加一个烙印,面完自我感觉不错,面试官也说这个solution works
。但是最后feedback不好。
2.Coding
面试官是一男一女两个中国人
Leetcode Search for a Range原题,先写了3pass的solution,面试官问能不能用
2pass解决,答可以,于是说了2pass的solution。
第二题是Find the size of longest palindrome subset of an array,注意是subset
而不是subarray。不能改变order。所以[1, 2, 2, 0, 1]的longest palindrome
subset是[1, 2, 2, 1],应该返回4。
当时想到可以选定array中的某一点,把array分成左右两个subarray,就是取一个中点
把[1, 2, 2, 0, 1]分成[1, 2]和[2, 0, 1]两个subarray,然后把[2, 0, 1]reverse
order变成[1, 0, 2]
然后用Leetc... 阅读全帖
l*****a
发帖数: 14598
39
来自主题: JobHunting版 - Linkedin八月onsite面经
这句话怎么解释? ==>注意是subset而不是subsequence
如果是subset 的话,跟顺序有关系吗?
另外不看你怎么答的,判断不出来悲剧原因啊

works
subset
2,
j********r
发帖数: 127
40
来自主题: JobHunting版 - LinkedIn onsite一道题
给一个string, 可以删除任意字符,求所有可以得到的palidrome字串集
我就想了个递归, 还是没有区分掉一些重复的情况,worst case O(2^n)基本同暴力解
Map> allSubSet = new HashMap();
Set getAllPalidrome(String s, int x, int y){
int ind = x * s.length() + y;
if(allSubSet.constainsKey(ind)) return allSubSet.get(ind);
Set ret = new HashSet();
if (s == null || s.size() == 0) { ret.add(""); return ret;}
if (s.size() == 1) { ret.add(s); return ret;}
for(int i = x; i <= y; i++){
for (int j = y; j >= i; j--){
... 阅读全帖
j********r
发帖数: 127
41
来自主题: JobHunting版 - LinkedIn onsite一道题
给一个string, 可以删除任意字符,求所有可以得到的palidrome字串集
我就想了个递归, 还是没有区分掉一些重复的情况,worst case O(2^n)基本同暴力解
Map> allSubSet = new HashMap();
Set getAllPalidrome(String s, int x, int y){
int ind = x * s.length() + y;
if(allSubSet.constainsKey(ind)) return allSubSet.get(ind);
Set ret = new HashSet();
if (s == null || s.size() == 0) { ret.add(""); return ret;}
if (s.size() == 1) { ret.add(s); return ret;}
for(int i = x; i <= y; i++){
for (int j = y; j >= i; j--){
... 阅读全帖
M***D
发帖数: 249
42
Again, please take what I say as suggestions only:
1) Developmental delay:
-I think your friend's daughter did not have speech/language developmental
delay.
-She appears having motor skill problems:
a) Gross motor skill problems: 不会跳绳, 不会拍球, and avoids taking part
in PE classes.
b) Fine motor skill problems: 不会用筷子, 拒绝用笔
c)Toilet training: 小时候祖母只要一把着她“嘘嘘”,她多少总会尿一点出来。
目前她已经接近8周岁了, 有时会偷偷爬到洗手盆上尿尿,甚至尿一半,在洗手盆上转
个方向再尿剩下的一半。 This is quite interesting, did her grandmother 把着她
到洗手盆上尿尿 when she was... 阅读全帖
d****u
发帖数: 20
43
来自主题: NCAA版 - The 10 greatest rivalries
http://espn.go.com/endofcentury/s/other/bestrivalries.html
If some one has to claim that some rivalry is the best within a subset of
subset of subset of games. I have no more to say.
n*****r
发帖数: 1087
44
想求解的东西已经用笨办法做出来了,现在想问问有没有什么简洁的办法,我想应该有。
问题:我要把column A的时间归类到A B C中,B 和 C 都有 subsets, 每个subset下面
还有subsets,然后总共有column E中的十几个case,根据每个自己的公式求解。
试过的笨办法:就是加了十几个column,用if function把column A的date归类到A B C
中,就是说加3个column for case A B C,return 一个 “Yes" 和 两个 "No“ 到这
三个column中;以此类推,比如return Yes到 case B, case B旁边再加2个column for
case 1 2,然后再reurn”Yes" "No"到这两个column;在case 1 2下面各自再加3 个
column for case x y z,最后在其中的一个case里用公式求解。
这个笨办法导致的问题是:由于row数额接近一万,再添加十几个column,无形中增加
了很多cells。还有就是别人看起来不直观。所以想弄个table,这样子只需要加两... 阅读全帖
d********g
发帖数: 8
45
要求证明是np-complete.
怎样从subset sum 问题 转化到这个问题。
Subset sum:
Given a set U of natural numbers {a1,a2....an) and a W, is there any subset
of U whose sum is equal to W.
Assume we know this problem is NP-COMPLETE
a directed graphG==(V,E),there is a weight w(e) for every edege e, which
would be positive or negative. Zero-weight-cycle problem is to decide if
there is a simple cycle in G so that sum of the edges weight is 0.
i******d
发帖数: 15
46
来自主题: TeX版 - How to embed fonts
I encountered same problem before. Font embedding is relatively simple as it
is a latex option. In higher version latex (I tried tetex-3.0 package),
pdflatex embeds all the fonts by default. However, font subsetting in .eps/.
pdf figures depends on the source applications that generates these figures. e
.g. matlab do only embed/not subset fonts when exporting eps/pdf figures, I
even can not find an option to change this setting.
One solution is to use third-party tools to subset fonts in eps/pdf
c****u
发帖数: 243
47
来自主题: Mathematics版 - 43rd IMO2002 Questions
A1. S is the set of all (h, k) with h, k non-negative integers such that h +
k < n. Each element of S is colored red or blue, so that if (h, k) is red and
h' <= h, k' <= k, then (h', k') is also red. A type 1 subset of S has n blue
elements with different first member and a type 2 subset of S has n blue
elements with different second member. Show that there are the same number of
type 1 and type 2 subsets.
A2. BC is a diameter of a circle center O. A is any point on the circle with
angle AOC >
Q***5
发帖数: 994
48
来自主题: Mathematics版 - 问一个实分析的问题
You can prove that for the case where E is a bounded open set, using
dominated convergence Th.
For more general E, you may find open set A, such that E is a subset of A,
but m(A\E) is as small as you want.
Now, E\E+t is a subset of A\E+t, which in turn is a subset of (A\A+t) U (A+
t\E+t), and continuity follows
D**u
发帖数: 204
49
来自主题: Mathematics版 - Is there such a "measure" on integers?
I am wondering whether there exists such a "measure" F on ALL the subsets of the set of
integers, which satisfies the following conditions:
(1) F(S) = 0 for any finite subset S.
(2) F(S) can be negative.
(3) finite additivity: If S is the union of 2 disjoint subsets S1 and S2,
then F(S) = F(S1) + F(S2).
(4) non-triviality: F(S) != 0 for some S.
c*****n
发帖数: 33
50
来自主题: Mathematics版 - 问个复分析题
We only need to prove that the sum of a_n(f(z^n)-f(0)) converges to an
analytic function. To show this one only need to show that the sum uniformly
converges on any compact subset of the unit disc. Note that on any compact subset of
the unit disc. Note that we have |f(z^n)-f(0)|\leq M|z|^n. Using this and that
$|a_n|$ is uniformly bounded since it is convergent, one can show the sum is
uniformly convergent on any compact subset of the unit disc. The trick is also used
in proving convergence of
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)