There areContinue reading “[Leetcode]1553. Minimum Number of Days to Eat N Oranges”`n`

oranges in the kitchen and you decided to eat some of these oranges every day as follows: Eat one orange. If the number of remaining oranges (`n`

) is divisible by 2 then you can eat n/2 oranges. If the number of remaining oranges (`n`

) is divisible by 3 then you can eat 2*(n/3) oranges. You can only choose one of the actions per day. Return the minimum number of days to eat`n`

oranges.Constraints:`1 <= n <= 2*10^9`

## [Leetcode]1537. Get the Maximum Score

You are given twoContinue reading “[Leetcode]1537. Get the Maximum Score”sortedarrays of distinct integers`nums1`

and`nums2.`

Avalidis 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 inpath`nums1`

and`nums2`

you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).Scoreis defined as the sum of uniques values in a valid path. Return the maximumscoreyou can obtain of all possiblevalid paths. Since the answer may be too large, return it modulo 10^9 + 7.

## [Leetcode]560. Subarray Sum Equals K

Given an array of integers and an integerContinue reading “[Leetcode]560. Subarray Sum Equals K”k, you need to find the total number of continuous subarrays whose sum equals tok.Example 1:Input:nums = [1,1,1], k = 2Output:2

## [Leetcode]139. Word Break

Given aContinue reading “[Leetcode]139. Word Break”non-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.Note:The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate words.

## [Leetcode]42. Trapping Rain Water

GivenContinue reading “[Leetcode]42. Trapping Rain Water”nnon-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:6

## [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 amoveconsisting of removinganynon-zerosquare numberof stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positive integer`n`

. Return`True`

if and only if Alice wins the game otherwise return`False`

, assuming both players play optimally.

## [Leetcode]264. Ugly Number II

Write a program to find theContinue reading “[Leetcode]264. Ugly Number II”`n`

-th ugly number. Ugly numbers arepositive numberswhose prime factors only include`2, 3, 5`

.Example:Input:n = 10Output:12Explanation:`1, 2, 3, 4, 5, 6, 8, 9, 10, 12`

is the sequence of the first`10`

ugly numbers.Note:1.`1`

is typically treated as an ugly number. 2.`n`

does not exceed 1690.

## [Leetcode]279. Perfect Squares

Given a positive integerContinue reading “[Leetcode]279. Perfect Squares”n, find the least number of perfect square numbers (for example,`1, 4, 9, 16, ...`

) which sum ton.Example 1:Input:n=`12`

Output:3Explanation:`12 = 4 + 4 + 4.`