Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions.
(股票收益)
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions.
(股票收益)
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).
(股票收益)
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.
(股票收益)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
(计算三角矩阵的最短路径)
Given a non-negative index k where k ≤ 33, return the k_th index row of the Pascal’s triangle. Note that the row index starts from 0.
(第k行杨辉三角)
Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.
(杨辉三角)
Given a binary tree, Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all next pointers are set to NULL.
(连接二叉树同一层的结点)
You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all next pointers are set to NULL.
(连接完全二叉树同一层的结点)
Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, “ACE” is a subsequence of “ABCDE” while “AEC” is not).
(有效子序列个数)
Given a binary tree, flatten it to a linked list in-place.
(压平二叉树)