生活随笔
收集整理的這篇文章主要介紹了
Hulu面试(或许待更)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2022/1/5
首先是電面,時長一小時。
自我介紹+項目介紹+實習內容+中間穿插問題。
coding:反轉鏈表、k個一組翻轉鏈表(lc原題改進,不同之處在于不滿k個也要反轉,細節比較多)
#include <iostream>
using namespace std
;
struct ListNode{int val
;ListNode
* next
;ListNode():val(0),next(NULL){}ListNode(int x
,ListNode
* next
):val(x
),next(next
){}
};
ListNode
* reverseList(ListNode
* head
){ListNode
* prev
= NULL;ListNode
* curr
= head
;while(curr
){ListNode
* next
= curr
->next
;curr
->next
= prev
;prev
= curr
;curr
= next
;}return prev
;
}
ListNode
* NreverseList(ListNode
* head
,int N
){ListNode
* slow
= nullptr;ListNode
* fast
= nullptr;ListNode
* newhead
= new ListNode();ListNode
* curr
=newhead
;while(head
){slow
= head
;fast
= head
;int count
=N
;while(count
>1 && fast
->next
){fast
= fast
->next
;count
--;}head
= fast
->next
;fast
->next
= NULL;curr
->next
= reverseList(slow
);curr
= slow
;}curr
->next
= head
;return newhead
->next
;}
int main(){ListNode
* head
= new ListNode(1,NULL);ListNode
* first
= new ListNode(2,NULL);ListNode
* second
= new ListNode(3,NULL);ListNode
* third
= new ListNode(4,NULL);ListNode
* fourth
= new ListNode(5,NULL);ListNode
* fifth
= new ListNode(6,NULL);ListNode
* sixth
= new ListNode(7,NULL);ListNode
* seventh
= new ListNode(8,NULL);head
->next
= first
;first
->next
= second
;second
->next
=third
;third
->next
= fourth
;fourth
->next
= fifth
;fifth
->next
= sixth
;sixth
->next
= seventh
;ListNode
* newhead
;int N
=3;newhead
= NreverseList(head
,N
);ListNode
* curr
= newhead
;while(curr
){cout
<<curr
->val
<<" ";curr
= curr
->next
;}}
面試官人很好,面試體驗很好。
——————————————————————————
然后是一面,
coding:給定僅由0和若干個1組成的數組,僅修改兩個0為1,讓1和1之間的最小距離最大,值為多少?
/*
[0,1,0,1,0,1] min_dist = 1
[1, 0, 0, 0, 0, 0, 1] min_dist = 5
[0,0, 0, 1, 0, 0, 0, 0, 0, 1, ]
[1, 0, 1, 0, 1, 0, 1] min_dist = 1
[1, 1, 0, 0, 1, 0, 1] min_dist = 0
*/
——————————————————————————
然后是二面:
sql索引(這里整理一下)
c++中的static(這里也整理一下)
coding:連續子數組的最小和
連續子數組絕對值的最小和
后面的兩輪個人原因因為自己真的狀態不好,就到此為止了。
最后補充一道另一家公司的題目:
給出一個元素無序的數組,求出一個數,使得其左邊的數都小于它,右邊的數都大于等于它。要求時間復雜度為O(n)。
總結
以上是生活随笔為你收集整理的Hulu面试(或许待更)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。