大致想法是這樣:
[framePrev]->[frame: k nodes]->[frameNext]
然後allocate stack(k 個pointer), 用來存放一個k個node 的指標
將此frame 反轉後,再將frame 往後移
source code:
https://github.com/cy-arduino/leetcode/blob/master/25.%20Reverse%20Nodes%20in%20k-Group.py
https://github.com/cy-arduino/leetcode/blob/master/25.%20Reverse%20Nodes%20in%20k-Group.c
沒有留言:
張貼留言