摘要:        
用递归就比较简单。class Solution {public: ListNode *reverseKGroup(ListNode *head, int k) { ListNode* current = head; ListNode** nodeArray = new ListNode*[k]; int i = 0; while (current != NULL && i next; i++; } if (i 0; j--) { nodeArra...    阅读全文
posted @ 2013-09-08 23:32
阿牧遥
阅读(231)
评论(0)
推荐(0)
        
            
        
        
摘要:        
LeetCode抽风,用Java会runtime error就用c++来写。思路是简单的,写法参考了答案。用了root和pivot两个辅助头结点,就可以免去对是否为NULL的判断。还有要对尾节点的next设为NULL。class Solution {public: ListNode *partition(ListNode *head, int x) { ListNode* root = new ListNode(-1); ListNode* pivot = new ListNode(-1); ListNode* root_last = root;...    阅读全文
posted @ 2013-09-08 23:12
阿牧遥
阅读(305)
评论(0)
推荐(1)
        
 
                    
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号