[Leetcode]1566. Detect Pattern of Length M Repeated K or More Times

LeetCode_logo
Given an array of positive integers arr,  find a pattern of length m that is repeated k 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.
Return true if there exists a pattern of length m that is repeated k or more times, otherwise return false.
Continue reading “[Leetcode]1566. Detect Pattern of Length M Repeated K or More Times”

[Leetcode]1022. Sum of Root To Leaf Binary Numbers

LeetCode_logo
Given a binary tree, each node has value 0 or 1.  Each root-to-leaf path represents a binary number starting with the most significant bit.  For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13.
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.
Continue reading “[Leetcode]1022. Sum of Root To Leaf Binary Numbers”

[Leetcode]122. Best Time to Buy and Sell Stock II

LeetCode_logo

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. 

Continue reading “[Leetcode]122. Best Time to Buy and Sell Stock II”

[Leetcode]121. Best Time to Buy and Sell Stock

LeetCode_logo

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.

Continue reading “[Leetcode]121. Best Time to Buy and Sell Stock”