由买买提看人间百态

topics

全部话题 - 话题: value2
1 (共1页)
e*****m
发帖数: 320
1
来自主题: Statistics版 - 请教这样的数据应该怎么分析
有这样一个问题,借贵地向大家请教一下。
有一个实验,十个Subjects,每个subject先平躺,同时用方法A和方法B测数据,每种
方法测三次,得到三个数值。
然后,subject坐起来,再同时用方法A和方法B测数据,每种方法再各测三次,得到三
个数值。
然后,subject再平躺,再测。
最后,subject再坐起来,再测。
这样就得到一组这样的数值:
METHOD A, SUPINE, SUBJECT1: value1 value2 value3
METHOD B, SUPINE, SUBJECT1: value1 value2 value3
METHOD A, Sitting, SUBJECT1: value1 value2 value3
METHOD B, Sitting, SUBJECT1: value1 value2 value3
METHOD A, SUPINE, SUBJECT2: value1 value2 value3
METHOD B, SUPINE, SUBJECT2: value1 value2 value3
等等等等。。。
现在想比较:1. METHOD ... 阅读全帖
s******t
发帖数: 2374
2
来自主题: JobHunting版 - Facebook Phone Screen
找了一个以前写的递归的
public int findLowestAncestor(Node root, int value1, int value2) {
if (root == null) return -1;

if (root.value > value1 && root.value > value2) {
findLowestAncestor(root.left, value1, value2);
}
else if (root.value < value1 && root.value < value2) {
findLowestAncestor(root.right, value1, value2);
}
else return root.value;
}
l*****y
发帖数: 8
3
来自主题: Database版 - SQL问题求救!!
本人有简单问题求教
已通过查询获得若干个结果,现必须将这些结果insert
到另一个表,say: result(number,value1,value2)
现在问题是:
只有value1 和value2是已知道的(即前面的结果)。可是
number 是一个primary key,表示序号如1,2,3,4,5,....
请问怎么样写insert into result(number,value1,value2)..???
我的意思是有100个value1,value组成的tuple.如何得到
table result such as
number value1 value 2
1 x1 y1
2 x2 y2
.....................
100 x100 y100
我尝试用

insert into result(number,value1,value2)
(
select number,A.value1,A,value2
from A
)
但是如何累加num
i*******d
发帖数: 81
4
其实就两个column的表,12 million也不算大。最后的表不小。一下update 48 个
column可能要写挺长时间。
你可以先把最后表的结构create出来,先写进去所有的unique id,create index。然
后每次update一个column。
create table t1( id int, value1 int);
create table t2( id int, value2 int);
create table t3( id int, value3 int);
insert into t1 values (2,2),(3,3);
insert into t2 values (1,1),(3,3);
insert into t3 values (1,1),(2,2);
select id into final from (select id from t1 union select id from t2 union
select id from t3) as t;
create clustered index id on final(id);
al... 阅读全帖
n**e
发帖数: 116
5
Here is my implementation in C++. Just my two cents.
// -------------------------------------------------------------------------
---
// Name: lowestCommonAncestor
// Description: Given two values representing two node's values in a
binary
// search tree, find the lowest common ancestor of the two nodes.
//
// Assumption: We assume those two values are different and both exist in
the
// tree if the tree is not empty.
//
// Node: This algorithm returns root node if one of ... 阅读全帖
i*******d
发帖数: 81
6
CTE + 一串 left outer join 可以实现。
SQL Server 三个table:
create table t1( id int, value1 int);
create table t2( id int, value2 int);
create table t3( id int, value3 int);
insert into t1 values (2,2),(3,3);
insert into t2 values (1,1),(3,3);
insert into t3 values (1,1),(2,2);
with idtable as
(select id from (select id from t1 union select id from t2 union
select id from t3) as t)
select idtable.id,isnull(value1,-1) as value1, isnull(value2,-1) as value2,
isnull(value3,-1) as value3
from idtable left ou... 阅读全帖
m********c
发帖数: 105
7
来自主题: JobHunting版 - google scramble string O(n) 解法
贴一个我的recursive代码,time complexity是O(n^2),large Judge用了144ms,不
是最优解,但是容易理解
bool isScramble(string s1, string s2) {
// Start typing your C/C++ solution below
// DO NOT write int main() function

if (s1 == s2)
return true;

int size = s1.size();

int value1=0, value2=0;
for (int i=0; i value1 += (s1[i]-'a');
value2 += (s2[i]-'a');
}
if (value1 != value2)
r... 阅读全帖
s*****g
发帖数: 17
8
来自主题: Database版 - SQL问题求救!!
In the result table, you may need an identity.
CREATE TABLE RESULT
(id int identity(1,1) not null,
value1 datatype,
value2 datatype
)
Then you can insert the values of value1 and value21.
INSERT INTO RESULT(value1, value2)
SELECT value1,value2
FROM A
Hope that it works.
z********4
发帖数: 1668
9
有48张表,每个表有一个id字段(建立了unique idex),一个value字段:
表1的字段:id, value1
表2的字段:id, value2
表3的字段,id, value3
……
表48的字段:id, value48
现在希望把这48张表根据id字段合并为一张,结构为:
id, value1, value2, value3,...,value48
问题是,每个表记录的id并不完全一样,表1中有的id表2中可能没有,反之亦然。但是
要求保留所有在48张表中出现过的id。如果这个id在表x中不存在,那么合并后的总表
中,这个id的valuex字段赋一个-1值。
例如,总表可能是这样的:
id, value1, value2, value3,...,value48
a, 1, 2, 3, ..., -1
b, 2, -1, 3, .... 3
...
另外一个问题是,每个表都非常大,记录数量在1200w左右。
数据库为postgresql,求好的解决方案。感谢!
h*z
发帖数: 34
10
来自主题: Programming版 - C++ 两个project enum value名冲突
具体情况看下面的code,project2要用到project1的API,但是project2中header2.h文件
的一个enum Type2的value与project1中header1.h文件的enum Type1的value相同出现
冲突. project1和project2都是很大的项目, 有legacy的原因, 所以直接改value不是
很方便. 不知道板上的大侠有没有碰到类似情况, 该如何处理.
//Project 1:
//header1.h
enum Type1
{
VALUE0=0,
VALUE1,
VALUE2,
VALUE3
};
///////////////////////////////////
//Project 2:
//header2.h
enum Type2
{
VALUE0=0,
VALUE1,
VALUE2
};
///////////
//Main.cpp in Project 2
#include "header1.h"
#in... 阅读全帖
k*******a
发帖数: 772
11
写了一个,不过有点繁
data a;
input id $ week value1;
datalines;
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
;
data b;
set a;
by id;
if value1 ne . then do
value2=value1;
retain value2;
end;
if last.id then output;
keep id value2;
data a;
merge a b;
by id;
proc print data=a;run;
d*******r
发帖数: 23
12
"Programming Interviews Exposed" has the solution. One of the properties
of BST is that left subtree nodes is always smaller than right subtree
nodes. So all you need to do is to iterate through the BST from the root
and find the first node that is lesser than one node and greater than
the other node. Pseudo code:
If valuel and value2 are less than the current node's value
Examine the left child
If valuel and value2 are greater than the current node's value
Examine the right child
Otherwise
The
c**********e
发帖数: 2007
13
【 以下文字转载自 Programming 讨论区 】
发信人: careerchange (Stupid), 信区: Programming
标 题: How to convert string to string array (or vector)
发信站: BBS 未名空间站 (Mon Sep 13 19:18:21 2010, 美东)
It looks that`in Java, there is a function Split which convert a string to a
string array. I wonder if we could do the same in C++. How to do the
conversion?
string MyString = "value1;value2;value3;value4;"
string[] MyStringArray = MyString.Split(';');
MyStringArray[0] (would give value1)
MyStringArray[1] (would give value2)
n***k
发帖数: 2780
14
what's the best data structure for storing and looking up a huge amount of
url's (presented in a prefix format) like these:
com.google.www -> value1
com.yahoo.finance -> value2
com.yahoo.finance/stocks -> value3
com.yahoo/finance -> value2
1.2.3.4/node/123 -> value4
....
the requirements are:
1. it has to be compact (compression if necessary).
2. lookup time should be fast (constant would be ideal, but a few level of
tree lookup is fine too).
g***s
发帖数: 3811
15
来自主题: JobHunting版 - 求解比硬币找零稍难的一题
Since the DP stores all the values, we don't need to handle (log v_N) times.
So, it is same time complexity of Knapsack problem.
new_V < 2*V
Knapsack can be handle in O(N*V), so this question can be handled in O(N*2*V
) = O(N*V). N is the type of coins.
the O(N*V) codes for knapsack are hard to read. following is sample codes,
time = O(V * sigma log s_i) .
public static int getMinStampNum(Coin[] coins, int V) {
ArrayList p = new ArrayList();
for (Coin coin ... 阅读全帖
l******9
发帖数: 579
16
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
l******9
发帖数: 579
17
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to generate a value by combining value1 to value4, suppose that it is
called "value_combine". The "value_combine" should be unique. For example,
given the different combinations... 阅读全帖
M*****t
发帖数: 26706
18
来自主题: LosAngeles版 - mysql的问题
要连接两个表,Key用来联接的。这两个表里,都有一些key missing,所以我想连接后
的数据显示null value from both tables. 谁知道怎么弄?
表一
Key Value1
A 1
B 2
C 2
D 2
表二
Key Value2
A 3
B 2
F 2
连接后的表:
Key Value1 Value2
A 1 3
B 2 2
C 2 null
D 2 null
F null 2
p****s
发帖数: 3184
19
来自主题: Database版 - SQL问题求救!!

In Oracle, it is quite easy to achieve this by using SEQUENCE.
E.g.,
CREATE SEQUENCE my_sequence
INCREMENT BY 1
START WITH 1
NOMAXVALUE;
INSERT INTO result(number,value1,value2)
select my_sequence.nextval, A.value1,A,value2
from a;
DROP SEQUENCE my_sequence.
In DB2, you must use user-defined function with scratchpad (check
Chamberline's book for coding examples) to achieve the same effects.
l******9
发帖数: 579
20
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_procedure()
end
my_procedure()
# do something
select value1, value2, value3
i need to keep the
value1, value2, value3
in one single table after the loop is don... 阅读全帖
l******9
发帖数: 579
21
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: generate unique integer ID from columns in SQL table
发信站: BBS 未名空间站 (Fri Nov 14 17:36:46 2014, 美东)
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to g... 阅读全帖
G**Y
发帖数: 33224
22
来自主题: Linux版 - 有没有parser的sample code?
C的。
读这样的文件。
## comments
keyword1 value2
keyword2 value2
## comments
keyword value
要求:skip所有 comments
这些,
keyword value
不一定按顺序出现?
h****b
发帖数: 157
23
来自主题: Programming版 - 问个c++问题
Is there anything wrong with this C++ class declaration?
class temp
{
int value1;
mutable int value2;
public :
void fun(int val)
const{
((temp*) this)->value1 = 10;
value2 = 10;
}
};
为什么我编译没问题? 再有((temp*) this)什么意思? const函数不是不能改变
member
variable?
多谢
s*******e
发帖数: 664
24
来自主题: Programming版 - [合集] c++ parameter reflection
☆─────────────────────────────────────☆
igah (igah) 于 (Mon Sep 21 21:38:57 2009, 美东) 提到:
here is the problem i am facing a lot when writing many applications in c++.
let's say you have a user class Foo and you need some parameters, e.g.
struct Foo {
int value1;
double value2;
};
and the parameters are read from some property file of name-value pairs:
value1=123
value2=23.4
the parameters can be changed at run time through some user interface (e.g.
jmx like controls) which sets the values al
c**********e
发帖数: 2007
25
It looks that`in Java, there is a function Split which convert a string to a
string array. I wonder if we could do the same in C++. How to do the
conversion?
string MyString = "value1;value2;value3;value4;"
string[] MyStringArray = MyString.Split(';');
MyStringArray[0] (would give value1)
MyStringArray[1] (would give value2)
etc......
l******9
发帖数: 579
26
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: generate unique integer ID from columns in SQL table
发信站: BBS 未名空间站 (Fri Nov 14 17:36:46 2014, 美东)
I need to generate a new column in a table in a sql database.
the given table is:
id1 value1 value2 value3 value4
9465 387 801 1990 20
All columns are integer. All columns are integer. value1 and value2 are
always 3 digits, value3 are year value, value4 is not more than 3 digits.
I need to g... 阅读全帖
l******9
发帖数: 579
27
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
r********e
发帖数: 1686
28
RT
if I have a dataset as below:
id week value1
a 1 12
a 2 22
a 3 33
a 4 .
a 5 .
a 6 .
a 7 .
b 1 78
b 2 .
b 3 .
b 4 .
b 5 .
b 6 .
b 7 .
b 8 .
c 1 88
c 2 67
c 3 76
c 4 .
c 5 .
c 6 .
I need to capture the last missing value1 for each ID as value2 to achieve
the following dataset:
id week value1 value2
a 1 12 33
a 2 22 33
a 3 33 33
a... 阅读全帖
t********1
发帖数: 799
29
来自主题: Statistics版 - SAS quarter calculation question
there is a table with different variables as below,
yyyymmm, value1(%), value2(%), value3(%), .......
now I need to calculate every three observations' accummulated percent, i.e.
quarterly accummulated percent for value1,value2, value3,.....
How can I realize this? Thank you very much.
H*******r
发帖数: 98
30
来自主题: Statistics版 - 编程菜鸟问一个sas编程问题
one is...
data select;
set original;
where var1 in (value1 value2 value3 value4 value5 value6 value7 value8)
or
var1 between minvalue and maxvalue or
var2 in (number1 number2 number3) or
var3 in (number1 number2 number3) or
var4 in (number1 number2 number3) or
var5 in (number1 number2 number3) or
var6 in (number1 number2 number3) or
var7 in (number1 number2 number3) or
var8 in (number1 number2 number3) or
... 阅读全帖
l******9
发帖数: 579
31
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: keep group of values of SQL procedure in one table
发信站: BBS 未名空间站 (Sat May 24 09:48:08 2014, 美东)
I need to print out a group of values from a procedure on SQL server 2008.
If I use select , it generated a distinct table into the result part of SQL
server 2008 managemetn studio every time the procedure is called.
i need to call the procedure in a loop. I want to print the values into one
table.
Thx!
while
begin
my_proce... 阅读全帖
s*********h
发帖数: 6288
32
来自主题: DataSciences版 - Spark group问题
如果我想把(key,value1) (key,value2),....(key,valueN)这样的group成
(key,[value1,value2,value3...valueN])
而不使用groupByKey,应该怎么实现啊?
另一方面用了groupByKey出现的是
(key, )
第二个东西不是一个list
q*********u
发帖数: 280
33
hash恐怕那些整数不适合当key, 如果是后面名字当key的话,没办法做value1+value2=
sum了,其实这个题复习了,可惜就是没事先写出来,写出来就能抄了。

好像跟范围也没太大关系吧?
或者空间没限制,直接用hash,不用sort
y**i
发帖数: 1112
34
整数为什么不适合当key?
如果用hash的话,我觉得就直接用stdext::hash_map,都不用自己写了,不用考虑内部
实现了,面试的时候可以简化代码不少。不过这个卫星数据到底是用来做什么的?唯一
有用的情况就是当有两个整数相等的情况下,同时都满足和另一个整数构成给定的和,
那么输出的时候应该分别输出这两个相等的整数和其卫星数据的pair吧,这样卫星数据
不一样就可以区分两个相等的整数。如果是这种情况,那么careercup上提供的两个指
针一左一右的算法就需要做相应的改动,每次遇到满足sum的时候,不能同时移动两个
指针了(要分别在两端做相等的判断)。如果用hash_map,应该把卫星和累计次数都记
下来。欢迎拍砖

value2=
k***e
发帖数: 556
35
你需要再认真的看下hash

value2=
b*******d
发帖数: 750
36
来自主题: JobHunting版 - 面经
最近面了几个公司,大的如LG,中等的PDB,小的有20~30个人的三个,tiny的7,8个
人的两三个,人不错,但太risky。
最想去的没有中, 水平问题。从一个,凑活300K过日子。
拿到卡后的骑驴找马。太累,收山,生娃。
1. numPath from top left to bottom right.
写没想到这个居然栽了,被对方态度搞的不能focus,写出来但总出错。水平问题。
2. find median in 2 sorted arrays
3. find median in very large file of LONGs in many machines.
global value space binary search; bucket stats; reduce number of passes of
files.
4. implement web crawler in java
不是project,就是 task queue, executor。
5. implement Timer, Timer Task in java
prirotity queue; num... 阅读全帖
l******9
发帖数: 579
37
I need to so a sql query on IBM netezza sql database from Aginity workbench
on win7.
My query:
SELECT *
from table1 AS c ,
table2 AS b
where CAST(c.id as int) = b.id
in table1, id is character varying(20) and in table2, id is int.
Table1:
id value1 value2
'985' 'casdqwdc' '654.3184' // they are all char
Table2:
id value1
985 694381 // id is int, value1 is int
I got error:
ERROR [HY000] ERROR: pg_atoi: error in "id": can't parse "id"
Any help would be apprec... 阅读全帖
l*********r
发帖数: 122
38
来自主题: JobHunting版 - 一道面试题请教
每条记录格式为
记录数目增长很快.
要求的运算是计算每分钟各个value的均值
假定有一个cloud provider如AWS,
解释 用什么样的 technologies去存data 和运算.
q**1
发帖数: 193
39
来自主题: BuildingWeb版 - PHP问题
如何调用其它 html 或 php file,并传递参数。我现在用

contain 其他网页,但是不知道如何将当前文件里定义的参数
传递到 component.html
我原先用 Perl 的 HTML::Mason 可以
<& /path/to/component.html, arg1 => value1, arg2 => value2 &>
然后在 component.html里面做相应设置。。
请问,在 PHP 里面如何实现?? //bow
d********g
发帖数: 10550
40
我服了


...

怎么找?这么用就是行为艺术,assumption是你确定这页面上有且只有多少个hidden,
要这样连value都直接猜算了
m***u
发帖数: 14
41
来自主题: Database版 - 问一个excel的弱问题
请教一个excel的问题
比如有一个数列,
a
1 value1
2 value2
3 value3
4 value4
5 value5
6 value6
7 value7
8 value8
9 value9
用什么命令能取出里面的一组值,比如,在数列b里面,让:
b
1 =a1
2 =a3
3 =a5
4 =a7
5 =a9
问题比较弱,先谢谢了。
F**e
发帖数: 593
42
来自主题: Database版 - 问个database design的问题
用的是MySQL. 要用来记录很多user的timestamp based的数据。做query的时候都是针
对单独的一个user. 每个记录象这样:
user_i timestamp1 value1
user_j timestamp2 value2
user_i timestamp3 value3
user_i timestamp3 value4
有三种选择,第一种就是用一个table来放所有数据,象上面一样。这样的坏处就是每
次要scan很多不相关user的record.
选择二:每个user用一个单独的table, 当然相同的schema.
选择三:每个user用一个单独的database.
二,三的好处就是query会快一点。但挺怪的。DB的高手们指教一下。先谢了。
j*****o
发帖数: 320
43
来自主题: Database版 - 请教一个SQL问题
Table data:
id Value1 Value2
1 1-1 1-2
1 2-1 2-2
2 3-1 3-2
3 4-1 4-2
3 5-1 5-2
3 6-1 6-2
怎么才能输出:
id Value
1 1-1 1-2 2-1 2-2
2 3-1 3-2
3 4-1 4-2 5-1 5-2 6-1 6-2
谢谢.
h********l
发帖数: 67
44
来自主题: Database版 - mySQL 问题 (转载)
【 以下文字转载自 Programming 讨论区 】
发信人: happyangel (快乐的天使), 信区: Programming
标 题: mySQL 问题
发信站: BBS 未名空间站 (Mon Jul 2 15:07:50 2007)
程序经常要用到下面的mysql语句(每秒一次左右):
update Table set col1=value1 where col2=value2
mysql和程序在同一台机子: P4 2800, 2G Memory
运行后,CPU使用率一直维持在100%. 请问这是什么
原因?谢谢!
g***l
发帖数: 18555
45
select 1 from T2 where T1.ID1 = T2.ID2 是MULTI RECORDS?
我不知道你这个QUERY到底想实现什么, SET里面的JOIN跟WHERE EXISTS里的没啥关系
,本来应该是很简答的JOIN吧
Update
T1
set
value1 =t2.value2
from
table T1
inner join
table T2 on
(
T1.ID1= T2.ID2
)
l******9
发帖数: 579
46
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: Error of SQL query on IBM netezza SQL database from Aginity workbench
发信站: BBS 未名空间站 (Fri Dec 5 16:46:56 2014, 美东)
I need to so a sql query on IBM netezza sql database from Aginity workbench
on win7.
My query:
SELECT *
from table1 AS c ,
table2 AS b
where CAST(c.id as int) = b.id
in table1, id is character varying(20) and in table2, id is int.
Table1:
id value1 value2
'985' 'casdqwdc' '654.3184' // t... 阅读全帖
g**********y
发帖数: 14569
47
来自主题: Java版 - Simple question
What's the most efficient data structure in Java to express:
key -> {key1:value1, key2:value2, ... keyN:valueN}
HashMap is one way. Since I need no operation other than
getter/setter, class is kind of heavy. Anything lighter?
p*****2
发帖数: 21240
48
就是把一个string
{key1:value1, key2:value2} 转换成object。
b*******r
发帖数: 1130
49
来自主题: Java版 - 请教两个hadoop的简单问题
不知道发在这个版上是否合适
如果我想让一个key pair(A, B)等同于(B, A),是不是在自定义key的equals method
中实现(A, B)=(B, A)就可以了?
另外如何在map中输出多个key value pair,例如map的输入
key=article, value=(editor1, editor2, editor3)
map输出
key1=(editor1, editor2), value1=article
key2=(editor1, editor3), value2=article
key3=(editor2, editor3), value3=article
b*******r
发帖数: 1130
50
来自主题: Java版 - 请教两个hadoop的简单问题
不知道发在这个版上是否合适
如果我想让一个key pair(A, B)等同于(B, A),是不是在自定义key的equals method
中实现(A, B)=(B, A)就可以了?
另外如何在map中输出多个key value pair,例如map的输入
key=article, value=(editor1, editor2, editor3)
map输出
key1=(editor1, editor2), value1=article
key2=(editor1, editor3), value2=article
key3=(editor2, editor3), value3=article
1 (共1页)