摘要: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文
posted @ 2017-11-03 16:52 immjc 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
posted @ 2017-11-03 15:58 immjc 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the roo 阅读全文
posted @ 2017-11-03 15:11 immjc 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 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? 判断回文链表 思路:由于链表无法像数组、字符串一样直接定位到中间索引 阅读全文
posted @ 2017-11-03 11:26 immjc 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 从低位到高位模拟二进制相加,如果相加结果产生进位,则对该数对2取余将结果放去结果st 阅读全文
posted @ 2017-11-03 10:21 immjc 阅读(125) 评论(0) 推荐(0) 编辑