由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一道题目
相关主题
就差一点了,接着求祝福leetcode的online judge runtime error是指什么?
google面经新鲜G面筋(Fail)
Probability quesiton把n个interval 放到一个container里
问个算法题, 关于区间 overlap的讨论一道面试题
FB interview question狗电面
Interval tree解法leetcode 的 Insert Interval 就是过不了大的
问个Facebook 电面题Insert Interval large case测试没过,怎么优化?
leetcode 这题insert interval怎么做?Merge Interval那道题
相关话题的讨论汇总
话题: total话题: mini话题: int话题: intervals话题: gap
进入JobHunting版参与讨论
1 (共1页)
c***g
发帖数: 472
1
假设给你一个function,可以返回工人过去时间工作的时间间隔,比如1-4点,5-9点,
要求判断工人是否可以继续工作,工人工作的条件是: worker can work up to 12
hours total before an 8 hour contiguous break
c***g
发帖数: 472
2
我提供的代码是这样的,希望大家提宝贵意见。
static int MINI_GAP = 8;
static int MINI_TOTAL = 12;
bool canDriverLogIn(userId){

vector intervals = getShifts(userId);

int total = 0 ;
int gap = 0;

int current = getCurrentTime();

int size = intervals.size();

if(size <= 0 ) return true;

for(int i = 0; i < size; i++) {
int gap = (current + 24 - intervals[i].end) % 24;
int total += intervals[i].end - intervals[i].start;

if( gap >= MINI_GAP && total <= MINI_TOTAL) return true;

if(total > MINI_TOTAL ) return false;

current = intervals[i].end;
}

return true;
}

【在 c***g 的大作中提到】
: 假设给你一个function,可以返回工人过去时间工作的时间间隔,比如1-4点,5-9点,
: 要求判断工人是否可以继续工作,工人工作的条件是: worker can work up to 12
: hours total before an 8 hour contiguous break

l*********8
发帖数: 4642
3
题意不清啊。 给几个test cases吧?

【在 c***g 的大作中提到】
: 假设给你一个function,可以返回工人过去时间工作的时间间隔,比如1-4点,5-9点,
: 要求判断工人是否可以继续工作,工人工作的条件是: worker can work up to 12
: hours total before an 8 hour contiguous break

1 (共1页)
进入JobHunting版参与讨论
相关主题
Merge Interval那道题FB interview question
JAVA里sort的algorithm time complexity是多少Interval tree解法
觉得G家很喜欢考interval的题,二爷要不总结一发?问个Facebook 电面题
interval tree vs. merge intervalsleetcode 这题insert interval怎么做?
就差一点了,接着求祝福leetcode的online judge runtime error是指什么?
google面经新鲜G面筋(Fail)
Probability quesiton把n个interval 放到一个container里
问个算法题, 关于区间 overlap的讨论一道面试题
相关话题的讨论汇总
话题: total话题: mini话题: int话题: intervals话题: gap