上週看了很不一樣的傳統戲劇,決定跟大家分享一下心得
這是台北加開場,之後在台中國家歌劇院
128. Longest Consecutive Sequence
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Example 1:
1 | Input: nums = [100,4,200,1,3,2] |
Example 2:
1 | Input: nums = [0,3,7,2,5,8,4,6,0,1] |
125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
1 | Input: "A man, a plan, a canal: Panama" |
Example 2:
1 | Input: "race a car" |
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Note that you cannot sell a stock before you buy one.
Example 1:
1 | Input: [7,1,5,3,6,4] |
Example 2:
1 | Input: [7,6,4,3,1] |
105. Construct Binary Tree from Preorder and Inorder Traversal
Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.
Example 1:
1 | Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] |
Example 2:
1 | Input: preorder = [-1], inorder = [-1] |