由买买提看人间百态

topics

全部话题 - 话题: tempe
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
g*****9
发帖数: 4125
1
来自主题: WashingtonDC版 - 请推荐电热水器
One unit means I only have one heater in the system.
Basically each heater (also called tankless waterheater, instantaneous
waterheater, ondemand waterheater, they are the same thing) can only water
temp based the flow rate. Say you get one that can raise the water temp by
10 degree at the flow rate of 4 gallon per minute, which means it can raise
water temp by 20 degree at flow rate of 2 gallon per min, or raise water
temp by 40 degree at flow rate of 1 gallon per min.
So depending on your app... 阅读全帖
k********k
发帖数: 5617
2
来自主题: Translation版 - 美國東海岸迎接颶風“三弟”來襲
http://fr-ca.actualites.yahoo.com/une-m%C3%A9ga-temp%C3%AAte-at
La côte est américaine se prépare au passage de Sandy
Par Radio-Canada | Radio Canada – il y a 2 heures 53 minutes
Tandis que Sandy a été reclassée en ouragan, samedi, quatre États
américains sont en état d'alerte, dont New York et le New Jersey, et 26
navires de guerre ont reçu l'ordre de quitter Norfolk, en Virginie.
Les météorologues américains ont enregistré des vents soufflant jusqu'à
120 km/h alors que Sand... 阅读全帖
h******o
发帖数: 334
3
怎样才能不覆盖前面存?我想每一列存后,就search 一个数据。完整的code如下:
Write a binary search method, which gets a 2D array and a query as arguments
and returns the number of times that the query occurs in the array. The 2D
array is sorted by columns but not by row.
public static int count(int[][] array, int query) {
int searchTotal = 0;
//iterate each 2D array' column
for (int c=0; c < array[0].length; c++){
searchTotal += biSearch(array, query, c);
}
return searchTotal;
}
private sta... 阅读全帖
s******d
发帖数: 2730
4
来自主题: Statistics版 - 一个R做图的问题
I know matplot works. But if you have different numbers of obs from each
state and different x levels for each state, that could be a little tricky.
Still doable.
For your question. See the following example.
temp<-sample(c(rep("NY",3), rep("NC", 2), rep("AL", 4)))
temp
temp<-as.factor(temp)
temp
temp<-as.numeric(temp)
temp

character
s******o
发帖数: 283
5
来自主题: Statistics版 - 请帮忙解答两个SAS base考题
Q1, For this question, why the answer is C not A, the month is descending order
is not July,June and May, Why? Thanks very much for your kind help!
Given the SAS data set WORK.TEMPS:
Day Month Temp
--- ----- ----
1 May 75
15 May 70
15 June 80
3 June 76
2 July 85
14 July 89
The following program is submitted:
proc sort data=WORK.TEMPS;
by descending Month Day;
run;
proc print data=WORK.TEMPS;
run;
Which output is correct?
... 阅读全帖
n*****5
发帖数: 61
6
来自主题: Statistics版 - sas base 题一问
27.Given the SAS data set WORK.TEMPS:
Day Month Temp
— —– —-
1 May 75
15 May 70
15 June 80
3 June 76
2 July 85
14 July 89
The following program is submitted:
proc sort data=WORK.TEMPS;
by descending Month Day;
run;
proc print data=WORK.TEMPS;
run;
Which output is correct?
A.
Obs Day Month Temp
— — —– —-
1 2 July 85
2 14 July 89
3 3 June 76
4 15 June 80
5 1 May 75
6 15 May... 阅读全帖
x**n
发帖数: 1936
7
【 以下文字转载自 sysop 讨论区 】
发信人: xian (海底核爆掀巨浪, 倒海翻江找扶桑), 信区: sysop
标 题: 《别了,可耻的cynic与可悲的TempBM》
发信站: BBS 未名空间站 (Sat Jan 1 01:20:24 2011, 美东)
又一年结束了。 在过去的一年里,我被军版封了无数次。特别是那个被贪官二奶包的
小白脸和那个在加拿大养不起女儿靠领救济过日子的 cynic 封我删我简直到了登峰造
极的程度。
也就是在前天,那个cynic,在我发了个嘲弄那所谓四代铁疙瘩的帖子后,好象捅了他
党娘的G点,it把我封了7天。他爷爷我不服气,找版主TempBM问理,24小时没见动静。
我写信再探再问,结果Temp说,是因为我帖子的口气不对因此给封的。
尽管Temp把我解封了。 可这莫须有的罪名实在让人气不过,所以我就把我的原帖子又
贴了上去,要cynic给个解释。 可cynic一句没有解释, 又把我给封了。 这下,我再
去问Temp, 可这时的Temp却说我pa人了。 我说:“同样的帖子,刚才你说我昨天被封
是口气不好,话音未落,你现在又说我pa了。 那请... 阅读全帖
b******n
发帖数: 552
8
来自主题: JobHunting版 - 今天面试惨败,分享面经
作为MSFT interview第一题,你的表现决定后来interviewer出题的难度和方向。
bool InsertNodeToBST(TreeNode *root, int value)
{
TreeNode *p=root, *q;
while(p)
{
q=p;
if(valuedata)
p=p->left;
else if(value>p->data)
p=p->right;
else
{
cout<<"Found duplicate";
return false;
}
}
TreeNode *temp=new TreeNode();
temp->data=value;
temp->left=null;
temp->right=null;
if(!root) root=temp;
else
{
if(valuedata) q->left=temp;
else q->right=temp;
}
r
H**d
发帖数: 152
9
来自主题: JobHunting版 - 一到电面题
void pairWiseSwap(struct node *head)
{
struct node *temp = head;
while(temp != NULL && temp->next != NULL)
{
swap(&temp->data, &temp->next->data);
temp = temp->next->next;
}
}
j*******h
发帖数: 20
10
来自主题: JobHunting版 - find the first missing positive integer.
public class FirstMissingPositive {
int min;//Integer.MAX_VALUE;
int max;//Integer.MIN_VALUE;

private void checkMinMax(){
if( max > 0 && min > 0 ){
if( max < min ){
int temp = min;
min = max;
max = temp;
}
if( max - min > 1 )
max = -1;
}
}

public int firstMissingPositive(int[] A) {
// Start typing your Java... 阅读全帖
j*******h
发帖数: 20
11
来自主题: JobHunting版 - find the first missing positive integer.
public class FirstMissingPositive {
int min;//Integer.MAX_VALUE;
int max;//Integer.MIN_VALUE;

private void checkMinMax(){
if( max > 0 && min > 0 ){
if( max < min ){
int temp = min;
min = max;
max = temp;
}
if( max - min > 1 )
max = -1;
}
}

public int firstMissingPositive(int[] A) {
// Start typing your Java... 阅读全帖
s******k
发帖数: 3716
12
来自主题: JobHunting版 - 被thank you的fb电面面经
手快不需要5分钟
int getNumDecode(const char *str)
{
char temp[3]; temp[1] = temp[2] = '\0';
if(strlen(str) == 0) return 1;
int num = 0;
temp[0] = str[0];
if(mymap[temp)>0) // we have 1 digit decode a letter
num += getNumDecode(str+1);
if(strlen(str)==1) return num;
temp[1] = str[1];
if(mymap[temp]>0) // we have 2 digits decode a letter
num += str+2;
return num;
}
e***s
发帖数: 799
13
来自主题: JobHunting版 - G电面面经
我就不懂了,不就是BFS最后一个节点吗?
public static BTNode DeepestRightMostNode(BTNode root)
{
if (root == null)
return null;
Queue queue = new Queue();
queue.Enqueue(root);
BTNode temp = root;
while(queue.Count > 0)
{
temp = queue.Dequeue();
if(temp.Left != null)
queue.Enqueue(temp.Left);
if(temp.Right != null)
... 阅读全帖
q****m
发帖数: 153
14
来自主题: JobHunting版 - 我这个按层打印的有什么问题
请问我这个按层打印的code有什么问题,leetcode说我memory limit exceeded,另外
,除了memory,还有什么bug么?
class Solution {
public:
vector > levelOrder(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function

vector > results;

if(!root) return results;

queue myQ;

myQ.push(root);

TreeNode* dummy = NULL;

myQ.push(dummy);

vect... 阅读全帖
f*******t
发帖数: 7549
15
来自主题: JobHunting版 - leetcode出了新题word ladder
相当丑陋的BFS,已经尽量去除copy string的时间了,但还是超时,求指点T_T
class Path {
public:
Path() { path = new vector; }

~Path() { delete path; }

Path* duplicate() const {
Path *np = new Path;
np->path = new vector(*path);
return np;
}

vector *path;
};
class Solution {
public:
vector> findLadders(string start, string end, unordered_
set &dict) {
vector> ans;
queue<... 阅读全帖
f*******t
发帖数: 7549
16
来自主题: JobHunting版 - leetcode出了新题word ladder
相当丑陋的BFS,已经尽量去除copy string的时间了,但还是超时,求指点T_T
class Path {
public:
Path() { path = new vector; }

~Path() { delete path; }

Path* duplicate() const {
Path *np = new Path;
np->path = new vector(*path);
return np;
}

vector *path;
};
class Solution {
public:
vector> findLadders(string start, string end, unordered_
set &dict) {
vector> ans;
queue<... 阅读全帖
z***8
发帖数: 17
17
来自主题: JobHunting版 - Leetcode 最新题, 搞不懂

下面的code需要美化,不过应该是O(n):
void FakeRadixSort(vector &num, vector &temp, int N)
{
vector count;
count.resize(2*N);
int i=0;
for (i=0; i<2*N; i++)
{
count[i] = 0;
}
int size = num.size();

for (i=0; i {
int index = num[i] % N;
index += N;
++ count[index];
}
for (i=1; i<2*N; i++)
{
count[i] += count[i-1];
}
for (i=size-1; i>=0; i--)
{
int index = num[i] % N;
... 阅读全帖
j**7
发帖数: 143
18
来自主题: JobHunting版 - 微软onsite SDET 面经
第三题的答案:
public class InfixToPostfix {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String infix="4*((5+6)*7";
infix="3+(1*2)";
String postfix=toPostfix(infix);
System.out.println(postfix);
System.out.println(evaluate(postfix));
}

//evaluate a postfix equation
static int evaluate(String postfix)
{
Stack st=new Stack阅读全帖
x*****0
发帖数: 452
19
class Solution {
private:
TreeNode *pre;
public:
Solution() : pre(NULL) {}
void flatten(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
//static TreeNode* pre = NULL;
if (root != NULL) {
flatten(root->right);
flatten(root->left);
root->right = pre;
root->left = NULL;
pre = root;
}
}
};
各位帮我看看这段代码有什么问题?我自己测试leetcode给出的数据,没有问题。但是
就是过不了。
如果改... 阅读全帖
r******g
发帖数: 13
20
来自主题: JobHunting版 - leetcode上的4Sum一问
It will ignore the quad containing num[i-1] and num[i], I find it's easier
to deal with it when you find a solution.
This O(n^2) solution without using set, both the (unordered_map) and results
(vector) doesn't contain duplicates by preprocessing the array.
Run Status: Accepted!
Program Runtime: 16 milli secs
Progress: 15/15 test cases passed.
Run Status: Accepted!
Program Runtime: 460 milli secs
Progress: 282/282 test cases passed.
Sorry can't type chinese, please feel free to comment my code, ... 阅读全帖
j**7
发帖数: 143
21
public static int minCoinsFor(int[] denom, int total) {
int[][] choice = new int[denom.length + 1][total + 1];
int[][] DP = new int[denom.length + 1][total + 1];
DP[denom.length][0] = 0;
for (int i = 1; i <= total; i++) {
DP[denom.length][i] = -1;
}
for (int i = denom.length - 1; i >= 0; i--) {
for (int j = 0; j <= total; j++) {
int min = -1;
for (int k = 0; k * denom[i] <= j; k++) {
... 阅读全帖
S*****J
发帖数: 18
22
来自主题: JobHunting版 - leetcode Palindrome Partitioning
两个dp是求最小palindrome切割数的,这道题recursive地往回找就行了,和subsets的
思路差不多。
class Solution {
public:
bool isPalindrome(string s, int start, int end)
{

while(start {
if(s[start]!=s[end])
return false;

start++;
end--;
}
return true;
}

void DFS(string &s, int start, vector &temp, vector string>> &res)
{
if(start==s.size())
{
res.push_back(temp);
r... 阅读全帖
S*****J
发帖数: 18
23
来自主题: JobHunting版 - leetcode Palindrome Partitioning
两个dp是求最小palindrome切割数的,这道题recursive地往回找就行了,和subsets的
思路差不多。
class Solution {
public:
bool isPalindrome(string s, int start, int end)
{

while(start {
if(s[start]!=s[end])
return false;

start++;
end--;
}
return true;
}

void DFS(string &s, int start, vector &temp, vector string>> &res)
{
if(start==s.size())
{
res.push_back(temp);
r... 阅读全帖
l*****n
发帖数: 246
24
来自主题: JobHunting版 - G 店面
没什么思路,想这样做,不知道会不会被人鄙视:
public int[][] generateRandomBoard(int NColors, int N, int M) {
int[][] board = new int[N][M];
boolean isEnd = false;
while(!isEnd){
generateRandomBoard(board, NColors);
isEnd = checkBoard(board);
}
return board;
}
private void generateRandomBoard(int[][] board, int NColors) {
Random rm = new Random();
int N = board.length;
int M = board[0].length;
for(int i=0; i for(int j=0; j int te... 阅读全帖
S*******C
发帖数: 822
25
import java.util.Stack;
/*
* Given Tree and Node n and int k, print all node which are at physical
distance <=k from n
* @Amazon intern
*/
public class Solution {
public static void main(String args[]){
Solution solution = new Solution();
TreeNode a = new TreeNode(8);
TreeNode b = new TreeNode(6);
TreeNode c = new TreeNode(10);
TreeNode d = new TreeNode(9);
TreeNode e = new TreeNode(12);
TreeNode f = new TreeNode(4);
TreeNode ... 阅读全帖
j**7
发帖数: 143
26
来自主题: JobHunting版 - FB Onsite新题,有人能看看吗?
boolean alibaba(int numCaves, int[] strategy) {
boolean[] DP = new boolean[numCaves];
boolean canWin = true;
for (int k = strategy.length - 1; k >= 0; k--) {
boolean[] temp = new boolean[numCaves];
for (int i = 0; i < numCaves; i++) {
temp[i] = (strategy[k] == i) ? true : false;
if (k + 1 < strategy.length) {
if (i - 1 >= 0) {
temp[i] = temp[i] || DP[i - 1];
... 阅读全帖
j**j
发帖数: 4
27
来自主题: JobHunting版 - 讨论下lc最新的那道hard题吧
看了大家的思路,也整理一下java的解法,用static的函数弄的,没测试过速度。。。
public static ArrayList mathToTarget(String nums, long target) {
ArrayList result = new ArrayList<>();

long val1 = 0;
long val2 = 0;

for (int i = 1; i <= nums.length(); i++) {
val2 = Long.parseLong(nums.substring(0, i));
dfs(nums, i, val1, val2, target, nums.substring(0, i), result);
if (nums.charAt(0) == '0') break;
}

return result;
}
public static void dfs(String nums, int in... 阅读全帖
e********2
发帖数: 495
28
来自主题: JobHunting版 - 问道G的onsite题
public class Solution {

public int[] deleteTree(int[] nums, int ind) {

if(ind == nums[ind]) return new int[0];

int max = Integer.MAX_VALUE;
nums[ind] = max;

int j, k, temp;
for(int i = 0; i < nums.length; ++i){

j = i;
while(nums[j] != j && nums[j] != max && nums[j] >= 0
){
j = nums[j];
}
if(nums[j]... 阅读全帖

发帖数: 1
29
来自主题: JobHunting版 - 问个G家面试题
因为有个index作为隐形的第三个n space,所以可以交叉引用,再加个‘’ empty
string
复杂度降为O(n)
输入:
字符串:[cat, mouse, dog, rabbit, tiger, lion]
数值: [2, 0, 1, 3, 5, 4]
index: [0, 1, 2, 3, 4, 5]
输出:
字符串:[dog, cat, mouse, rabbit, lion, tiger]
1)
temp = cat
字符串:[dog, mouse, ‘’, rabbit, tiger, lion]
此时字符串[2]为空,查看index2,数值为1,交换
2)
temp = cat
字符串:[dog, ‘’, mouse, rabbit, tiger, lion]
字符串[1]空,查看index1,empty string,跟temp交换
3)
temp =‘’
字符串:[dog, cat, mouse, rabbit, tiger, lion]
move到index3,数值为3, 不变,下一数值为5,lion存入 字符串[4],temp =
tige... 阅读全帖
t*****e
发帖数: 3287
30
来自主题: Singapore版 - PR终于批下来了
本文摘要:
PR批准有时候要三个月以上
temp ep可以延期,只能延一次,也就是pr申请时间最长是六个月
持temp ep也可以出入境,只要有一个multi-entry visa的章。
damn,四个多月!气死我了,现在还没拿到信,只是打电话问的时候告诉我批下来了。
我的情况,从sp直接神情的pr,材料齐全,包括学位证明,offer letter,pr邀请信,
出生证明,还有公司帮我填的表。交了材料之后拿temp ep,不能离开新加坡。
本来以为一个多月就能申请下来,没想到三个月了杳无音信,打了无数电话,
都回复说是under processing
三个月到了,公司提醒我如果还没拿到PR就要去renew temp ep
我第一次听说temp ep还要renew的!本来懒得去ICA,又要请假。
打电话问了一下ICA,说是temp ep只有三个月有效期,过了之后不能用,要罚款
我就找了一天中午去了ICA,拿queue number的时候说我要expedite PR application
然后见officer,问了我的情况之后,又给我找了另外一个officer
帮我续了三个月的temp
r********n
发帖数: 6979
31
来自主题: Fishing版 - Bass出水以后能活多久?
今天做了点research. 大部分老美的说法是1-2分钟没有问题, 再长就不行了. 不过基
本都是经验之谈, 找到了这篇文章是evidence based. 作为大家参考
RE-EXAMINING "HOLDING YOUR BREATH" GUIDELINES
I've come across two truly fascinating studies concerning largemouth
bass and hypoxia. One was published a year ago, the other is set for
publication very soon. In both cases they studied varying amounts of air
exposure after exercise/angling that a bass could be subjected to. One
was done in the lab, one in the field. Both have reached the same basic
conclusion. C... 阅读全帖
m**k
发帖数: 18660
32
【 以下文字转载自 Joke 讨论区 】
发信人: Rains (雨), 信区: Joke
标 题: "Run From the Police 5k Walk/Run" is being postponed this
发信站: BBS 未名空间站 (Fri Dec 5 18:47:06 2014, 美东)
Dear Run from the Cops 5K participants,
Three years ago, the Tempe Police Department in partnership with The Tempe
Police Foundation – a 501(c) 3 nonprofit organization – designed an
interactive, lighthearted and healthy family athletic event to bring
together Tempe police employees and members of the community in a charitable
5K run known as... 阅读全帖
R***s
发帖数: 302
33
Dear Run from the Cops 5K participants,
Three years ago, the Tempe Police Department in partnership with The Tempe
Police Foundation – a 501(c) 3 nonprofit organization – designed an
interactive, lighthearted and healthy family athletic event to bring
together Tempe police employees and members of the community in a charitable
5K run known as the “Run From The Cops”.
Since its inception, the event has gained in its popularity as a fun way for
the Tempe community to connect with the police office... 阅读全帖
r***o
发帖数: 1526
34
来自主题: Database版 - 问个SQL问题
好像只能两步了
UPDATE #Temp SET T_ID = T.T_ID FROM T INNER JOIN #Temp ON #Temp.Name = T.
Name
UPDATE #Temp SET Count = TCount FROM
(SELECT Count(*) TCount, T_ID FROM #Temp GROUP BY T_ID) T
INNER JOIN #Temp ON #Temp.T_ID = T.T_ID
d*****1
发帖数: 123
35
ASU校园附近发生抢劫枪击案[zz]
TEMPE, AZ
Tempe警方说,亚利桑那州立大学的一位优秀学生星期天晚上在ASU校园附近被枪击,周
一早上去世。
调查人员说,21岁的Zachary Marco从图书馆走回家的路上,两名男子抢劫并枪杀了他。
“我不知道他到底做了什么导致这个”,他的父亲Daniel说, “我认为他仅仅只是在
走路而已。”
他的家人说Daniel是一个聪明的前途光明的年轻人。
Daniel说,他的儿子作为一个去年在亚利桑那州参议员页面里面服务的人,在校学习政
治学和哲学,是一个“一直拿A”的学生。
这起暗杀嫌疑人尚未被确定。
Tempe警方正调查有可能涉及到的这两名男子的信息,他们在警察9点半左右到达Rural
Road和University Drive附近的现场前逃跑了。
星期一下午十几个志愿者和Tempe警察在附近的两个不同公寓小区挨家挨户地发警告通
知,犯罪分子可能从附近经过。
“我们只是需要人们注意,提高警觉,采取预防措施,我们希望能产生一些线索”,
Tempe警方官员Lieutenant Vince Boerbon 如是说。
“如果有人想抢他的东西,他... 阅读全帖
z*******y
发帖数: 578
36
Void LevelTraversal(Node *root)
{
if(root == NULL) return;
queue q = new queue;
q.push(root);
q.push(NULL);
while(!q.empty() && q.size()!=1)
{
Node *temp = q.pop();
if(temp == NULL)
{
cout << endl;
q.push(NULL);
}
else
{
cout << temp->data << " ";
if(temp->left!=NULL)
q.push(temp->left);
if (temp->right!=NULL)
q.push(tem
w******0
发帖数: 43
37
来自主题: JobHunting版 - 问两道bloomberg的题目
第一次这么解决怎么样
int a = 2340
int temp = a
while(temp > 10)
{
printf("%d ", temp%10);
temp = temp/10;
}
printf("%d",temp);
m*****g
发帖数: 226
38
来自主题: JobHunting版 - Google经典题目一问
理论上似乎完全可行
比如
1. int temp
move c2 to i2, i2 to temp
move temp (i2) to i3, i3 to temp
move temp (i3) to i5, i5 to temp
.....
难点就是如何把代码写出来而且写的整洁
i**********e
发帖数: 1145
39
4. 很久以前写的大数 class. 基本思路很简单,就是小学的乘法 + carry.
BigInt BigInt::multiply(const BigInt &b) const
{
BigInt answer;
BigInt temp;

int carry = 0;
for (int i = 0; i < b.numDigits; i++)
{
temp.numDigits = this->numDigits + 1;
int down = b.digits[i];
for (int j = 0; j <= this->numDigits; j++)
{
int up = (j < this->numDigits) ? this->digits[j] : 0;
int tempDigit = up * down + carry;
temp.digits[j] = tempDigit % 10;
carry = tempDigit / 10;
}
temp.s... 阅读全帖
c*****m
发帖数: 315
40
来自主题: JobHunting版 - 问两道google面试题
搞了一上午搞出来了第一题,包含以下几点
1. 基本想法类似于HEAPSORT, 每次取HEAP 的最小值,和BST tree 当前最小位置的值
交换,然后再维护HEAP 的结构,同时取BST 中序遍历的下一个值。在整个过程中,树
的一部分变成了BST TREE, 另一部分还是HEAP 结构。
下面介绍相关的步骤。
2. 取HEAP 的最小值:粗略的想法是用HEAP[0]。这里有个问题:当HEAP[0] 被并入BST
部分以后,最小值不再是HEAP[0],而是HEAP[0] 的右子树。可以证明HEAP[0] 被并入
BST 的时候,它的左子树已经全部在BST 里了,而它的右子树都不在BST里,因此可以
TRACK 当前HEAP 的ROOT。
3.维护HEAP 的结构。算法和SIFTDOWN 一样,但要注意的是SIFT DOWN 的时候必须要检
查当前节点的子节点是不是在BST 部分,如果是,就停止交换。要做到这一点,只需要
TRACK 住当前HEAP 的最小值,BST 里的元素都会小于它。
代码如下(HEAP 用数组heap 表示):
//取一个BST子树最小节点的索引, 辅助函数
... 阅读全帖
p*******n
发帖数: 10
41
来自主题: JobHunting版 - 问个Amazon面试题
I don't think we need do permutation.
how about this solution?
int FindNext( int x)
{
int base = 1;
int current = x % 10 ;
int temp = x /10;
while (temp)
{
if (temp %10 {
int y = (current - temp%10)*9*base ;
return x+y;
}
else {
base *= 10;
current = temp%10 ;
temp /=10;

}

}
return 0;
}
p*******n
发帖数: 10
42
来自主题: JobHunting版 - 问个Amazon面试题
I don't think we need do permutation.
how about this solution?
int FindNext( int x)
{
int base = 1;
int current = x % 10 ;
int temp = x /10;
while (temp)
{
if (temp %10 {
int y = (current - temp%10)*9*base ;
return x+y;
}
else {
base *= 10;
current = temp%10 ;
temp /=10;

}

}
return 0;
}
x***i
发帖数: 64
43
来自主题: JobHunting版 - 请教一道面试题,关于tree的
贴一下我的code吧
string pre2post(string pre)
{
string temp, tmp_pos;
int i = 0;
stack ops;
while (i < pre.size())
{
temp = pre.substr(i,1);
if (pre[i]=='-' || pre[i]=='+' ||
pre[i]=='*' || pre[i]=='/')
{
ops.push(temp);
}
else {
while (!ops.empty() &&
!((tmp_pos=ops.top()).size()==1 &&
(tmp_pos[0]=='-' || tmp_pos[0]=='+' ||
tmp_pos[0]=='... 阅读全帖
j*******e
发帖数: 1058
44
来自主题: JobHunting版 - M家 onsite 悲剧,同胞们弄死烙印吧
我的解法,是一个普遍的k解法。在main里面把k改为2或者是面试官喜欢的k的值就ok。
希望大家指正。
class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
next = null;
}
}
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public ListNode reverseKGroup(ListNode head, int k) {
// Start typing your Java solution below
// DO NO... 阅读全帖
j*******e
发帖数: 1058
45
来自主题: JobHunting版 - M家 onsite 悲剧,同胞们弄死烙印吧
我的解法,是一个普遍的k解法。在main里面把k改为2或者是面试官喜欢的k的值就ok。
希望大家指正。
class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
next = null;
}
}
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public ListNode reverseKGroup(ListNode head, int k) {
// Start typing your Java solution below
// DO NO... 阅读全帖
r****k
发帖数: 21
46
来自主题: JobHunting版 - find the first missing positive integer.
重新构造数组,如果当前下标的value>0 && <=数组长度,则设置a[value-1] = value
例如原数组为: -3, -4, 1, 2, 6, 7
新数组为: 1, 2, 1, 2, 6, 6
然后循环数组,找到值不等于下标+1的i(a[i]!=i+1),返回i+1
int findFirstMissingPositive(int a[], int length)
{
int temp = 0;
int i = 0;
int value;
while (i < length)
{
if (temp > 0)
{
value = temp;
}
else
{
value = a[i];
i++;
}
if (value > 0 && value <= length)
{
if (a[value-1] == valu... 阅读全帖
r****k
发帖数: 21
47
来自主题: JobHunting版 - find the first missing positive integer.
重新构造数组,如果当前下标的value>0 && <=数组长度,则设置a[value-1] = value
例如原数组为: -3, -4, 1, 2, 6, 7
新数组为: 1, 2, 1, 2, 6, 6
然后循环数组,找到值不等于下标+1的i(a[i]!=i+1),返回i+1
int findFirstMissingPositive(int a[], int length)
{
int temp = 0;
int i = 0;
int value;
while (i < length)
{
if (temp > 0)
{
value = temp;
}
else
{
value = a[i];
i++;
}
if (value > 0 && value <= length)
{
if (a[value-1] == valu... 阅读全帖
G******i
发帖数: 5226
48
来自主题: JobHunting版 - [合集] 该不该跳
☆─────────────────────────────────────☆
exploit (temp) 于 (Fri Dec 2 15:46:37 2011, 美东) 提到:
base 多6000, 10000的signing bonus
如果走,公司股票损失大概10000/year, 而且还有2个月就要annual review了。
☆─────────────────────────────────────☆
peking2 (myfacebook) 于 (Fri Dec 2 15:50:22 2011, 美东) 提到:

现在base多少?要是100K,好像也没什么必要呀。
☆─────────────────────────────────────☆
Ginobili (潘帕斯雄鹰) 于 (Fri Dec 2 15:58:41 2011, 美东) 提到:
跳槽要综合考虑的因素太多
尤其是在你这种base相差不多的情况下
更主要取决于其他软指标。。
☆─────────────────────────────────────☆
ex... 阅读全帖
e***s
发帖数: 799
49
来自主题: JobHunting版 - 出两道题目大家做做
我也贴一个第一题,不知道对不对。
public static void setConflictEvent(ArrayList list){
Collections.sort(list);
Event temp = new Event(list.get(0).start, list.get(0).end, list.get(
0).conflict);

for(int i = 1; i < list.size(); i++)
{
if(temp.end > list.get(i).start)
{
list.get(i - 1).conflict = true;
list.get(i).conflict = true;

temp.end = Math.max(temp.end, list.get(i).end);
... 阅读全帖
c*******r
发帖数: 309
50
public void preOrderTraversal(Node root){
if(root==null)
return null;
Stack stack=new Stack();
stack.push(root);
while(!stack.isEmpty()){
Node temp=stack.pop();
System.out.println(temp.val);
if(temp.left!=null)
stack.push(temp.left);
if(temp.right!=null)
stack.push(temp.right);
}
}
比较麻烦的是inOrderTraversal. 需要写一个pushLeft的方法
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)