暱稱 : 華一跤,slipontheway
: interviewer ,
: interviewee
影片 : 00:24
模擬面試過程
: 在影像處理的過程中,經常需要將圖片翻轉,可能是左右翻轉或上下翻轉,那這個翻轉的概念可以對應到資料結構中的tree,你可以幫我用tree的結構做類似圖片左右翻轉的動作嗎?
: 以tree為結構做左右翻轉的概念就類似於將二元樹翻轉,請問tree有什麼限制嗎?
: tree 節點數量<100 ,每個節點的數值介於 -100~100 。
: 好的,那我的想法使用遞迴的方式將左右子樹對調。
: 有其他非遞迴的解法嗎?
: 好的,我的想法是用level order的方式走訪,然後搭配queue的結構。先將root根節點加入queue,先以根節點為主,將他的左有子樹交換,再確認他的左右子樹是否為NULL,如果不是NULL就加入queue。寫成一個迴圈,只要queue不是空的,就用q.front取出一個node,一樣將他的左右子點交換,再將非空的左右子樹加入queue,直到queue為空即完成invert binary tree。
影片: 14:44
模擬面試過程
: linking list可以用於管理作業系統中的空閒記憶體。當系統動態分配和釋放記憶體時,它使用linking list追蹤空閒記憶體區塊。今天有一個記憶體空間,要刪除從後面數來的第n個區塊,請你使用linking list的資料結構實現,給你linking list 的head,在刪除後回傳head
: 所以我要刪除倒數第n個元素,我想舉個例子確認我對題目的了解,
: 沒錯,請開始撰寫程式。
: 那我的想法是完整的走訪一次List,計算出list的長度,再用長度k減n得到m。在第二次走訪時,指標到達第m個字元,即可繞過要被刪除的字元 ,最終回傳head。
: 因為memory的空間很大,你的這個方法需要走訪2次這個list可能有點浪費時間,可以多加一點東西,壤整個刪除的過程中只要走訪一次list嗎?
: 好的那可能就需要2個指標,pre與cur,由cur先往前移動n個位置,如果cur已經是NULL,那表示要刪除的位置就是head。如果cur還不是NULL,將pre和cur同步往前,直到cur是List裡的最後一個元素為止,此時pre的位置是需要被刪除的前一個元素,更改指標繞過就完成了。
影片: 29:00
模擬面試過程
: In logical reasoning and proofs, the symmetry of parentheses ensures the accuracy and rigor of logical expressions. So, please verify if a string is valid according to the following conditions:
: So I need to check the symmetry of the parentheses. I would like to use an example to confirm if my understanding of the problem is correct.
: Yeah, please start writing the program.
My idea is to use a stack to store different types of brackets. When encountering a left bracket, it will be pushed into the stack. When encountering a right bracket, if the top of the stack contains the corresponding left bracket, then the string is valid up to this point, and the element can be popped from the stack. But, if the top of the stack does not contain the corresponding left bracket, or if the stack is already empty, then the string is invalid, and I can return false immediately. After reading all the elements, if the stack is empty, return true; otherwise, return false.
: well, Can you define a map to help you determine whether the brackets are corresponding pairs?
: I define a map of closing brackets to their corresponding opening brankets, and check if the character is an opening brankets, if it's an opening bracket, push it into stack. If not, check whether tke stack is empty, or the corresponding opening bracket doesn't match the top of stack, can return false, otherwise, pop the stack. after check all character, if the stack is empty, return true, otherwise return false.
注意麥克風收音問題。
應徵者:
面試者: