由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 亚麻的监牢题
相关主题
Alibaba Hiring in SV: Web Front-end SEGoogle店面
一道M$面试题的解法...问个题
整理的一些stl,auto_ptr的东西,求bless三道 Amazon Onsite Coding 题 (转载)
问一道精华帖的老题请教个题目
Google Intern 面试 【请教】大概说一下昨天的Google Phone Interview
一个N个数的int数组如何找到3个majority的数?问一道算法题
求助一道C面试题:在线等amazon问题求教
One confusing questionfacebook电面题目
相关话题的讨论汇总
话题: arr话题: front话题: int话题: inactive话题: days
进入JobHunting版参与讨论
1 (共1页)
d****e
发帖数: 499
1
大概意思是有八个一排的监牢,每个有active和inactive状态,如果某一个牢房的左右
临都是active或inactive, 这个牢房第二天变active,否则变inactive, 计算n天后的牢
房状态
state =[bool]
calcStates(curState: [bool], days: int) {
// output the state of each cell after specific days
}
P******a
发帖数: 1379
2
除了硬算有啥其他办法吗?
更新:2的8次方个状态,所以256个状态应当分割成若个联通图,每个联通图应当就是
一个单向循环的loop。如果函数会被反复调用,可以把所有状态都预算一遍,每次调用
就直接查表。


:大概意思是有八个一排的监牢,每个有active和inactive状态,如果某一个牢房的左
右临都是active或inactive, 这个牢房第二天变active,否则变inactive, 计算n天后的
牢房状态
d***l
发帖数: 7
3
边上的两个怎么说?
t******d
发帖数: 1383
4
public void process(int[] arr) {
int front = 0;
int i = 0;
for (; i < arr.length - 1; i++) {
if ((front == 1 && arr[i+1] == 0) || (front == 0 && arr[i+1] ==
1)) {
front = arr[i];
arr[i] = 1;
} else {
front = arr[i];
arr[i] = 0;
}
}
if (front == 1)
arr[i] = 1;
else
arr[i] = 0;
}

public void process(int[] arr, int days) {
while (days > 0) {
process(arr);
days--;
}
}
p*****2
发帖数: 21240
5

头尾连起来?

【在 d***l 的大作中提到】
: 边上的两个怎么说?
t*********r
发帖数: 63
6
第一直觉状态压缩加记忆搜索,某一天一定会出现重复的状态,然后直接mod到这一天
所需要的时间
h**6
发帖数: 4160
7
抽屉原理,最多256种状态。
1 (共1页)
进入JobHunting版参与讨论
相关主题
Microsoft screening programming problemGoogle Intern 面试 【请教】
bing的screening question,没回音了,帮忙看问题在哪一个N个数的int数组如何找到3个majority的数?
问一个题目求助一道C面试题:在线等
生成一个有重复数的全排列,怎么做比较好One confusing question
Alibaba Hiring in SV: Web Front-end SEGoogle店面
一道M$面试题的解法...问个题
整理的一些stl,auto_ptr的东西,求bless三道 Amazon Onsite Coding 题 (转载)
问一道精华帖的老题请教个题目
相关话题的讨论汇总
话题: arr话题: front话题: int话题: inactive话题: days