Given a string that contains only digitsContinue reading “[Leetcode]282. Expression Add Operators”0-9
and a target value, return all possibilities to add binaryoperators (not unary)+
,-
, or*
between the digits so they evaluate to the target value.
[Leetcode]340. Longest Substring with At Most K Distinct Characters
Given a string, find the length of the longest substring T that contains at most k distinct characters.Continue reading “[Leetcode]340. Longest Substring with At Most K Distinct Characters”
[Leetcode]188. Best Time to Buy and Sell Stock IV
This series of Buy and Sell Stock I~VI on Leetcode is a great practice for Dynamic Programming – State Machine. Therefore I prepared blogs for each of them and hopefully it would help you to understand them better. You can find the relations of them at the bottom and feel free to leave any comments.
- [Leetcode]121. Best Time to Buy and Sell Stock
- [Leetcode]122. Best Time to Buy and Sell Stock II
- [Leetcode]123. Best Time to Buy and Sell Stock III
- [Leetcode]188. Best Time to Buy and Sell Stock IV
- [Leetcode]309. Best Time to Buy and Sell Stock with Cooldown
- [Leetcode]714. Best Time to Buy and Sell Stock with Transaction Fee
[Leetcode]123. Best Time to Buy and Sell Stock III
This series of Buy and Sell Stock I~VI on Leetcode is a great practice for Dynamic Programming – State Machine. Therefore I prepared blogs for each of them and hopefully it would help you to understand them better. You can find the relations of them at the bottom and feel free to leave any comments.
- [Leetcode]121. Best Time to Buy and Sell Stock
- [Leetcode]122. Best Time to Buy and Sell Stock II
- [Leetcode]123. Best Time to Buy and Sell Stock III
- [Leetcode]188. Best Time to Buy and Sell Stock IV
- [Leetcode]309. Best Time to Buy and Sell Stock with Cooldown
- [Leetcode]714. Best Time to Buy and Sell Stock with Transaction Fee
[Leetcode]1537. Get the Maximum Score
You are given two sorted arrays of distinct integersContinue reading “[Leetcode]1537. Get the Maximum Score”nums1
andnums2.
A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current array from left to right. If you are reading any value that is present innums1
andnums2
you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path). Score is defined as the sum of uniques values in a valid path. Return the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 10^9 + 7.
[Leetcode]42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. Example: Input: height=[0,1,0,2,1,0,1,3,2,1,2,1] Output: 6Continue reading “[Leetcode]42. Trapping Rain Water”
[Leetcode]1510. Stone Game IV
Alice and Bob take turns playing a game, with Alice starting first. Initially, there areContinue reading “[Leetcode]1510. Stone Game IV”n
stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square numberof stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positive integern
. ReturnTrue
if and only if Alice wins the game otherwise returnFalse
, assuming both players play optimally.
[Leetcode]212. Word Search II
Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must 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 in a word. Example: Input: board = [ ['o','a','a','n'], ['e','t','a','e'], ['i','h','k','r'], ['i','f','l','v'] ] words =Continue reading “[Leetcode]212. Word Search II”["oath","pea","eat","rain"]
Output:["eat","oath"]