摘要:
原题链接在这里:https://leetcode.com/problems/balanced-binary-tree/ 题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-ba 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ 题目: Given an array where elements are sorted in ascending order, con 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ 题目: Given a singly linked list where elements are sorted in ascending 阅读全文
摘要:
Private means this could only be seen within this class. Protected means "package private", this could be seen by subclasses and package members. | Cl 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/sort-list/ 题目: Sort a linked list in O(n log n) time using constant space complexity. 题解: divide and conquer. 从中 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/insertion-sort-list/ 题目: Sort a linked list using insertion sort. 题解: 与Sort List类似. 当出现cur.val > cur.next.val时就需 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ 题目: Follow up for "Remove Duplicates":What if duplicates are allowed at 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题目: Given a sorted array, remove the duplicates in place such that each ele 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ 题目: Given a sorted linked list, delete all nodes that have duplicate numb 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/remove-duplicates-from-sorted-list/ 题目: Given a sorted linked list, delete all duplicates such that each element 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/swap-nodes-in-pairs/ 题目: Given a linked list, swap every two adjacent nodes and return its head. You must solve 阅读全文
摘要:
原题链接:https://leetcode.com/problems/add-two-numbers/ 题目: You are given two linked lists representing two non-negative numbers. The digits are stored in 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/intersection-of-two-linked-lists/ 题目: Write a program to find the node at which the intersection of two singly l 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/palindrome-linked-list/ 题目: Given a singly linked list, determine if it is a palindrome. Follow up:Could you do 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接:https://leetcode.com/problems/remove-linked-list-elements/ 题目: Remove all elements from a linked list of integers that have value val. ExampleGiv 阅读全文
摘要:
原题链接在这里: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 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/reverse-linked-list/ 题目: Reverse a singly linked list. 题解: Iteration 方法: 生成tail = head, cur = tail, while loop 的 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/evaluate-reverse-polish-notation/ 题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/basic-calculator-ii/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression str 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/basic-calculator/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression string 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ 题目: Given a binary tree, return the zigzag level order traversal of it 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/binary-tree-level-order-traversal/ 题目: Given a binary tree, return the level order traversal of its nodes' value 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ 题目: Given inorder and postorder traversal of a tree, 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 题目: Given preorder and inorder traversal of a tree, c 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/majority-element/ 题目: Given an array of size n, find the majority element. The majority element is the element t 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/binary-tree-postorder-traversal/ 题目: Given a binary tree, return the postorder traversal of its nodes' values. F 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/binary-tree-inorder-traversal/# 题目: Given a binary tree, return the inorder traversal of its nodes' values. For 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/binary-tree-preorder-traversal/ 题目: Given a binary tree, return the preorder traversal of its nodes' values. For 阅读全文
摘要:
原题链接在这里: https://leetcode.com/problems/min-stack/ 题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/valid-parentheses/ 题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/implement-queue-using-stacks/ 题目: Implement the following operations of a queue using stacks. push(x) -- Push el 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/implement-stack-using-queues/ 题目: Implement the following operations of a stack using queues. push(x) -- Push el 阅读全文
摘要:
这是一道面试亚马逊时的题目,要求Time O(n). 我刚开始想的是算出所有的数的总product,再去除以对应位置的元素,但这种做法的问题是若该位置为0,就会报错。到网上搜了下,才知道,原来有这种做法。e.g. arr = {0,1,2,3},生成两个array: upArr = {1,arr[0... 阅读全文
摘要:
原题链接在这里:https://leetcode.com/problems/multiply-strings/ 题目: Given two non-negative integers num1 and num2 represented as strings, return the product o 阅读全文