上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 33 下一页
摘要: Given a string, we can "shift" each of its letter to its successive letter, for example:"abc" -> "bcd". We can keep "shifting" which forms the sequenc... 阅读全文
posted @ 2015-12-25 06:54 Hygeia 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 这也能算hard题……Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba”,T is "... 阅读全文
posted @ 2015-12-25 05:37 Hygeia 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Given twosparse matricesAandB, return the result ofAB.You may assume thatA's column number is equal toB's row number.Example:A = [ [ 1, 0, 0], [-1, ... 阅读全文
posted @ 2015-12-25 04:54 Hygeia 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a string, determine if a permutation of the string could form a palindrome.For example,"code"-> False,"aab"-> True,"carerac"-> True.解法一:解题思路:The... 阅读全文
posted @ 2015-12-21 11:38 Hygeia 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.leetcode上返回类型不太一样,改编一下第三个解法:4mspublic class Solution {... 阅读全文
posted @ 2015-12-21 10:53 Hygeia 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list inO(nlogn) time using constant space complexity. 1 /** 2 * 本代码由九章算法编辑提供。没有版权欢迎转发。 3 * - 九章算法致力于帮助更多中国人找到好的工作,教师团队均来自硅谷和国内的一线大公... 阅读全文
posted @ 2015-12-21 09:09 Hygeia 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-12-21 05:33 Hygeia 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort. 1 public class Solution { 2 public ListNode insertionSortList(ListNode head) { 3 ListNode dummy =... 阅读全文
posted @ 2015-12-21 04:14 Hygeia 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解法一:双节点public TreeNode sortedListToBST... 阅读全文
posted @ 2015-12-19 06:23 Hygeia 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321overflow!public class Solution { public int reverse(int x... 阅读全文
posted @ 2015-11-17 10:25 Hygeia 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 33 下一页