随笔分类 -  leetcode

摘要:题目描述 Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values 阅读全文
posted @ 2017-05-05 15:19 qqky 阅读(290) 评论(0) 推荐(0)
摘要:题目描述 Sort a linked list in O(n log n) time using constant space complexity. 思路: 冒泡排序、选择排序、插入排序,时间复杂度为O(n^2); 快速排序、归并排序、堆排序,时间复杂度为O(nlogn); 基数排序、计数排序,时 阅读全文
posted @ 2017-05-04 16:23 qqky 阅读(366) 评论(0) 推荐(0)
摘要:题目描述 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题目描述 给定一个升序排列的有序单链表,将其转换为一棵平衡的二叉搜索树 阅读全文
posted @ 2017-04-28 15:20 qqky 阅读(724) 评论(0) 推荐(0)
摘要:【题目】 A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep 阅读全文
posted @ 2017-04-28 15:12 qqky 阅读(851) 评论(0) 推荐(0)