西雅圖換駕照
<124> Binary Tree Maximum Path Sum
Description
Question: Given a non-empty binary tree, find the maximum path sum.
For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.
Leetcode link: 124. Binary Tree Maximum Path Sum
<33> Search in Rotated Sorted Array
Description
Question: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You are given a target value to search. If found in the array return its index, otherwise return -1.
You may assume no duplicate exists in the array.
Your algorithm’s runtime complexity must be in the order of O(log n).
Leetcode link: 33. Search in Rotated Sorted Array
<106> Construct Binary Tree from Inorder and Postorder Traversal
Description
Question: Given inorder and postorder traversal of a tree, construct the binary tree.
You may assume that duplicates do not exist in the tree.
For example, given:
1 | inorder = [9,3,15,20,7] |
Return the following binary tree:
1 | 3 |
Leetcode link: 106. Construct Binary Tree from Inorder and Postorder Traversal
105. Construct Binary Tree from Inorder and Postorder Traversal (Related)
<413> Arithmetic Slices
Description
Question: A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
A zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 <= P < Q < N.
A slice (P, Q) of array A is called arithmetic if the sequence:
A[P], A[p + 1], …, A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.
The function should return the number of arithmetic slices in the array A.
Leetcode link: 413. Arithmetic Slices
<221> Maximal Square
Description
Question: Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.
Leetcode link: 221. Maximal Square
<79> Word Search
Description
Question: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
Leetcode link: 79. Word Search
<139> Word Break
Description
Question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Note: The same word in the dictionary may be reused multiple times in the segmentation.
You may assume the dictionary does not contain duplicate words.
Leetcode link: 139. Word Break