注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 匿名 于 2022-2-7 00:12 编辑
今天犯傻了。 看错题目导致一道题没做出来。
1. Signle Linked List 1-n find max start and end pair with space O(1). ------- Reverse half nodes and go though two list. ---- Pass
2. There are two arrays with same size, find Max subarray size that limited by K. When K - Max(SubArray1) > Sum(SubArray2) * size of subarray. Subarray1 and subArray2, start and end are same. ----------- use max value deque + slide window able to resolve this.
我把题目要求读错了。事后回忆错误的case才反应过来。求点米好读面筋。继续面试。
First Question.
public int doFindMaxPair(ListNode head){
int size = 0;
ListNode node = head;
while(node != null){
size++;
node = node.next;
}
int n = size/2;
if(head == null){
return 0;
}
ListNode preNode = head;
ListNode curNode = head.next;
break;
}
}
if(!maxQueue.isEmpty()){
long power = powerMax - bootingPower.get(maxQueue.getFirst());
if(power >= (right - left + 1)*sum){
isMoveRight = true;
}
}else{
isMoveRight = true;
}
left++;
}
}
return max;
}
|