題目: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 解題思路: 前序遍歷序列的第一個元素肯定為根節點;然后再在中序遍歷序列中找到該節點,并以
Palindrome Linked List 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? https://leetcode.com/problems/palindrome-linked-list/ ? LeetCode。? ? ? 判斷單鏈表是否為回文,要求時間復雜度O
題目鏈接:Populating Next Right Pointers in Each Node | LeetCode OJ Given a binary tree struct TreeLinkNode {TreeLinkNode *left;TreeLinkNode *right;TreeLinkNode *next;
} Populate each next pointer to point to its next right node. If there is no next
Given an array of size?n, find the majority element. The majority element is the element that appears?more than?? n/2 ??times. You may assume that the array is non-empty and the majority element always exist in the array. 題目大意: 給定一個長度為n的
題目: leetCode,A robot is located at the top-left corner of a?m?x?n?grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the
題目: A message containing letters from?A-Z?is being encoded to numbers using the following mapping: 'A' -> 1
'B' -> 2
...
'Z' -> 26 Given an encoded message containing digits, determine the total number of ways to
原題 TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design the encode and decode methods for the TinyURL service. There is no res
1.題目描述 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest