2015年3月28日

Leetcode解题-链表(2.2.6)RotateList

摘要: 1 题目:Rotate ListGiven a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->nullptr and k = 2, r... 阅读全文

posted @ 2015-03-28 11:27 毛小娃 阅读(79) 评论(0) 推荐(0)

Leetcode解题-树(5.0.0)基础类

摘要: 与第二章类似,LeetCode指定了TreeNode实现。为了方便后续习题的编写和测试,创建一个基础父类,包含TreeNode实现,以及create()和print()创建和打印树的方法。其中create()采用类似“堆”的方式,用数组表示树形结构,复习一下,左右子结点就是2*i和2*i+1。而p... 阅读全文

posted @ 2015-03-28 11:25 毛小娃 阅读(101) 评论(0) 推荐(0)

Leetcode解题-链表(2.2.3)PartitionList

摘要: 题目:2.2.3 Partition ListGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. ... 阅读全文

posted @ 2015-03-28 11:21 毛小娃 阅读(97) 评论(0) 推荐(0)

Leetcode解题-链表(2.2.2)ReverseLinkedList

摘要: 题目:2.2.2 Reverse Linked List IIReverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->nullptr, m... 阅读全文

posted @ 2015-03-28 11:17 毛小娃 阅读(99) 评论(0) 推荐(0)

Leetcode解题-链表(2.2.1)AddTwoNumbers

摘要: 1 题目:2.2.1 Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of th... 阅读全文

posted @ 2015-03-28 08:42 毛小娃 阅读(143) 评论(0) 推荐(0)

Leetcode解题-链表(2.2.0)基础类

摘要: 1 基类的作用在开始练习LeetCode链表部分的习题之前,首先创建好一个Solution基类,其作用就是:Ø 规定好每个子Solution都要实现纯虚函数test做测试;Ø 提供了ListNode结构的定义;Ø create函数创建链表;Ø print打印链表等工具函数;从而方便我们编写... 阅读全文

posted @ 2015-03-28 08:33 毛小娃 阅读(210) 评论(0) 推荐(0)

导航