随笔分类 -  Leetcode

1 2 3 4 5 ··· 8 下一页
Algorithm, Datastructure
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2016-06-08 03:12 茜茜的技术空间 阅读(263) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Analysis: postorder 阅读全文
posted @ 2016-06-03 10:22 茜茜的技术空间 阅读(153) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,3,2]. Note: Recursive solut 阅读全文
posted @ 2016-06-03 10:16 茜茜的技术空间 阅读(191) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu 阅读全文
posted @ 2016-06-03 10:11 茜茜的技术空间 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2016-06-02 12:28 茜茜的技术空间 阅读(166) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list in O(n log n) time using constant space complexity. Analysis: 1. use merge sort 2. use quick sort Java code 20160601 merge sort: 阅读全文
posted @ 2016-06-02 09:17 茜茜的技术空间 阅读(218) 评论(0) 推荐(0) 编辑
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3- 阅读全文
posted @ 2016-06-02 08:43 茜茜的技术空间 阅读(203) 评论(0) 推荐(0) 编辑
摘要:Given 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. You should preserve the 阅读全文
posted @ 2016-06-02 07:50 茜茜的技术空间 阅读(305) 评论(0) 推荐(0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 解题思路: Th 阅读全文
posted @ 2016-06-02 07:32 茜茜的技术空间 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2016-06-02 07:02 茜茜的技术空间 阅读(426) 评论(0) 推荐(0) 编辑
摘要: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 @ 2016-06-02 03:15 茜茜的技术空间 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? A linked list can be re 阅读全文
posted @ 2016-06-02 02:41 茜茜的技术空间 阅读(386) 评论(0) 推荐(0) 编辑
摘要:There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should... 阅读全文
posted @ 2016-01-19 09:03 茜茜的技术空间 阅读(472) 评论(0) 推荐(0) 编辑
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should re... 阅读全文
posted @ 2016-01-19 03:16 茜茜的技术空间 阅读(302) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted in asc... 阅读全文
posted @ 2016-01-16 13:47 茜茜的技术空间 阅读(568) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2016-01-16 12:41 茜茜的技术空间 阅读(289) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2016-01-15 08:48 茜茜的技术空间 阅读(625) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2016-01-15 04:21 茜茜的技术空间 阅读(357) 评论(0) 推荐(0) 编辑
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-11-14 09:56 茜茜的技术空间 阅读(178) 评论(0) 推荐(0) 编辑
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2015-11-14 04:37 茜茜的技术空间 阅读(240) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 8 下一页
点击右上角即可分享
微信分享提示