摘要: Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-01-09 22:24 匡子语 阅读(223) 评论(0) 推荐(0)
摘要: Sort a linked list inO(nlogn) time using constant space complexity.思路:用归并排序。设输入链表为S,则先将其拆分为前半部分链表A,后半部分链表B。注意,要把A链表的末尾置为NULL。即要把链表划分为两个独立的部分,防止后面错乱。#i... 阅读全文
posted @ 2015-01-09 22:01 匡子语 阅读(216) 评论(0) 推荐(0)