Given an array of positive integersContinue reading “[Leetcode]1566. Detect Pattern of Length M Repeated K or More Times”arr
, find a pattern of lengthm
that is repeatedk
or more times. A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions. Returntrue
if there exists a pattern of lengthm
that is repeatedk
or more times, otherwise returnfalse
.
[Leetcode]459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.Continue reading “[Leetcode]459. Repeated Substring Pattern”
[Leetcode]1022. Sum of Root To Leaf Binary Numbers
Given a binary tree, each node has valueContinue reading “[Leetcode]1022. Sum of Root To Leaf Binary Numbers”0
or1
. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is0 -> 1 -> 1 -> 0 -> 1
, then this could represent01101
in binary, which is13
. For all leaves in the tree, consider the numbers represented by the path from the root to that leaf. Return the sum of these numbers.
[Leetcode]283. Move Zeroes
Given an arrayContinue reading “[Leetcode]283. Move Zeroes”nums
, write a function to move all0
's to the end of it while maintaining the relative order of the non-zero elements. Note: You must do this in-place without making a copy of the array. Minimize the total number of operations.
[Leetcode]122. Best Time to Buy and Sell Stock II
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]121. Best Time to Buy and Sell Stock
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]252. Meeting Rooms
Given an array of meeting time intervals consisting of start and end timesContinue reading “[Leetcode]252. Meeting Rooms”[[s1,e1],[s2,e2],...]
(si < ei), determine if a person could attend all meetings. Example 1: Input:[[0,30],[5,10],[15,20]]
Output: false
[Leetcode]190. Reverse Bits
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 Output: 00111001011110000010100101000000Continue reading “[Leetcode]190. Reverse Bits”