摘要: 原题链接在这里:https://leetcode.com/problems/balanced-binary-tree/ 题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-ba 阅读全文
posted @ 2015-09-05 00:44 Dylan_Java_NYC 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/reorder-list/ 题目: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must 阅读全文
posted @ 2015-09-03 05:49 Dylan_Java_NYC 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ 题目: Given an array where elements are sorted in ascending order, con 阅读全文
posted @ 2015-09-03 04:04 Dylan_Java_NYC 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ 题目: Given a singly linked list where elements are sorted in ascending 阅读全文
posted @ 2015-09-03 03:36 Dylan_Java_NYC 阅读(370) 评论(0) 推荐(0) 编辑
摘要: Private means this could only be seen within this class. Protected means "package private", this could be seen by subclasses and package members. | Cl 阅读全文
posted @ 2015-09-03 03:07 Dylan_Java_NYC 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/sort-list/ 题目: Sort a linked list in O(n log n) time using constant space complexity. 题解: divide and conquer. 从中 阅读全文
posted @ 2015-09-03 02:59 Dylan_Java_NYC 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/insertion-sort-list/ 题目: Sort a linked list using insertion sort. 题解: 与Sort List类似. 当出现cur.val > cur.next.val时就需 阅读全文
posted @ 2015-09-03 01:16 Dylan_Java_NYC 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ 题目: Follow up for "Remove Duplicates":What if duplicates are allowed at 阅读全文
posted @ 2015-09-02 13:01 Dylan_Java_NYC 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题目: Given a sorted array, remove the duplicates in place such that each ele 阅读全文
posted @ 2015-09-02 12:38 Dylan_Java_NYC 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ 题目: Given a sorted linked list, delete all nodes that have duplicate numb 阅读全文
posted @ 2015-09-02 12:25 Dylan_Java_NYC 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-list/ 题目: Given a sorted linked list, delete all duplicates such that each element 阅读全文
posted @ 2015-09-02 12:19 Dylan_Java_NYC 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/partition-list/ 题目: Given a linked list and a value x, partition it such that all nodes less than x come before 阅读全文
posted @ 2015-09-01 04:28 Dylan_Java_NYC 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/linked-list-cycle-ii/ 题目: Given a linked list, return the node where the cycle begins. If there is no cycle, ret 阅读全文
posted @ 2015-09-01 03:45 Dylan_Java_NYC 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/linked-list-cycle/ 题目: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it withou 阅读全文
posted @ 2015-08-29 22:12 Dylan_Java_NYC 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/swap-nodes-in-pairs/ 题目: Given a linked list, swap every two adjacent nodes and return its head. You must solve 阅读全文
posted @ 2015-08-29 21:51 Dylan_Java_NYC 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 原题链接:https://leetcode.com/problems/add-two-numbers/ 题目: You are given two linked lists representing two non-negative numbers. The digits are stored in 阅读全文
posted @ 2015-08-29 05:39 Dylan_Java_NYC 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/intersection-of-two-linked-lists/ 题目: Write a program to find the node at which the intersection of two singly l 阅读全文
posted @ 2015-08-29 04:07 Dylan_Java_NYC 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/palindrome-linked-list/ 题目: Given a singly linked list, determine if it is a palindrome. Follow up:Could you do 阅读全文
posted @ 2015-08-29 03:19 Dylan_Java_NYC 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/remove-nth-node-from-end-of-list/ 题目: Given a linked list, remove the nth node from the end of list and return i 阅读全文
posted @ 2015-08-29 01:00 Dylan_Java_NYC 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/reverse-nodes-in-k-group/ 题目: Given a linked list, reverse the nodes of a linked list k at a time and return its 阅读全文
posted @ 2015-08-27 02:53 Dylan_Java_NYC 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 原题链接:https://leetcode.com/problems/remove-linked-list-elements/ 题目: Remove all elements from a linked list of integers that have value val. ExampleGiv 阅读全文
posted @ 2015-08-23 00:14 Dylan_Java_NYC 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/reverse-linked-list-ii/ 题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For exam 阅读全文
posted @ 2015-08-22 05:20 Dylan_Java_NYC 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/reverse-linked-list/ 题目: Reverse a singly linked list. 题解: Iteration 方法: 生成tail = head, cur = tail, while loop 的 阅读全文
posted @ 2015-08-22 04:15 Dylan_Java_NYC 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/evaluate-reverse-polish-notation/ 题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. 阅读全文
posted @ 2015-08-22 01:10 Dylan_Java_NYC 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/basic-calculator-ii/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression str 阅读全文
posted @ 2015-08-21 12:21 Dylan_Java_NYC 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/basic-calculator/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression string 阅读全文
posted @ 2015-08-21 09:42 Dylan_Java_NYC 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ 题目: Given a binary tree, return the zigzag level order traversal of it 阅读全文
posted @ 2015-08-21 07:48 Dylan_Java_NYC 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/binary-tree-level-order-traversal/ 题目: Given a binary tree, return the level order traversal of its nodes' value 阅读全文
posted @ 2015-08-21 06:54 Dylan_Java_NYC 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ 题目: Given inorder and postorder traversal of a tree, 阅读全文
posted @ 2015-08-21 03:03 Dylan_Java_NYC 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 题目: Given preorder and inorder traversal of a tree, c 阅读全文
posted @ 2015-08-21 02:33 Dylan_Java_NYC 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/majority-element/ 题目: Given an array of size n, find the majority element. The majority element is the element t 阅读全文
posted @ 2015-08-20 10:32 Dylan_Java_NYC 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/binary-tree-postorder-traversal/ 题目: Given a binary tree, return the postorder traversal of its nodes' values. F 阅读全文
posted @ 2015-08-20 08:01 Dylan_Java_NYC 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/binary-tree-inorder-traversal/# 题目: Given a binary tree, return the inorder traversal of its nodes' values. For 阅读全文
posted @ 2015-08-20 02:48 Dylan_Java_NYC 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/binary-tree-preorder-traversal/ 题目: Given a binary tree, return the preorder traversal of its nodes' values. For 阅读全文
posted @ 2015-08-19 09:15 Dylan_Java_NYC 阅读(425) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里: https://leetcode.com/problems/min-stack/ 题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time 阅读全文
posted @ 2015-08-19 05:07 Dylan_Java_NYC 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/valid-parentheses/ 题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine 阅读全文
posted @ 2015-08-18 12:02 Dylan_Java_NYC 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/implement-queue-using-stacks/ 题目: Implement the following operations of a queue using stacks. push(x) -- Push el 阅读全文
posted @ 2015-08-18 11:35 Dylan_Java_NYC 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/implement-stack-using-queues/ 题目: Implement the following operations of a stack using queues. push(x) -- Push el 阅读全文
posted @ 2015-08-18 10:57 Dylan_Java_NYC 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 这是一道面试亚马逊时的题目,要求Time O(n). 我刚开始想的是算出所有的数的总product,再去除以对应位置的元素,但这种做法的问题是若该位置为0,就会报错。到网上搜了下,才知道,原来有这种做法。e.g. arr = {0,1,2,3},生成两个array: upArr = {1,arr[0... 阅读全文
posted @ 2015-08-18 04:09 Dylan_Java_NYC 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 原题链接在这里:https://leetcode.com/problems/multiply-strings/ 题目: Given two non-negative integers num1 and num2 represented as strings, return the product o 阅读全文
posted @ 2015-08-18 03:32 Dylan_Java_NYC 阅读(279) 评论(0) 推荐(0) 编辑