06 2016 档案

摘要:question: Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time and O(1) space? answer: 思路:把前半部分的链表翻转,再分 阅读全文
posted @ 2016-06-29 12:54 绵绵思远道 阅读(152) 评论(0) 推荐(0)
摘要:1.链表是一种与火车非常相似的数据结构,在链表里,我们叫火车头为表头,每节车厢就是链表的元素,车厢里载的人和物就是元素的数据域,连接车厢的部件就是元素的指针。从火车的结构我们可以发现链表的一个特点,元素之间前后依赖,串联而成。 2.性质: 元素相互依赖,串联而成(除了火车头,每节车厢都只链接到前一节 阅读全文
posted @ 2016-06-29 11:59 绵绵思远道 阅读(439) 评论(0) 推荐(0)
摘要:question: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return:  阅读全文
posted @ 2016-06-28 22:27 绵绵思远道 阅读(95) 评论(0) 推荐(0)
摘要:question: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 阅读全文
posted @ 2016-06-28 20:47 绵绵思远道 阅读(135) 评论(0) 推荐(0)
摘要:question: Reverse a singly linked list. answer: 使用三个指针遍历单链表,逐个链接点进行反转。 阅读全文
posted @ 2016-06-28 19:09 绵绵思远道 阅读(129) 评论(0) 推荐(0)
摘要:question: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 - 阅读全文
posted @ 2016-06-28 19:02 绵绵思远道 阅读(142) 评论(0) 推荐(0)
摘要:question: Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". answer: 交换字符串中的元素 阅读全文
posted @ 2016-06-28 18:51 绵绵思远道 阅读(136) 评论(0) 推荐(0)
摘要:1.线性表是由相同数据类型的 n 个数据元素a0,a1,......,an-1 组成的有限序列。一个数据元素可以由若干个数据项组成。若用 L 命名线性表,则其一般表示如下: L=(a0,a1,......,an-1) 其中, a0​​ 是唯一的“第一个”数据元素,又称为表头元素;an-1​​ 是唯一 阅读全文
posted @ 2016-06-28 18:31 绵绵思远道 阅读(780) 评论(0) 推荐(0)