276. Paint Fence

276. Paint Fence You are painting a fence of n posts with k different colors. You must paint the posts following these rules: Every post must be painted exactly one color. At most one pair of adjacent fence posts can have the same color. Given the two integers n and k, return the number of ways you can paint the fence. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: n = 3, k = 2 Output: 6 Explanation: All the possibilities are shown....

<span title='2021-05-17 00:00:00 +0000 UTC'>May 17, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

63. Unique Paths II

63. Unique Paths II A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below). Now consider if some obstacles are added to the grids. How many unique paths would there be?...

<span title='2021-05-16 00:00:00 +0000 UTC'>May 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

64. Minimum Path Sum

64. Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. 1 2 3 4 5 Example 1: Input: grid = [[1,3,1],[1,5,1],[4,2,1]] Output: 7 Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum....

<span title='2021-05-16 00:00:00 +0000 UTC'>May 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1859. Sorting the Sentence

1859. Sorting the Sentence A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters. A sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence. For example, the sentence “This is a sentence” can be shuffled as “sentence4 a3 is2 This1” or “is2 sentence4 This1 a3”....

<span title='2021-05-15 00:00:00 +0000 UTC'>May 15, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1860. Incremental Memory Leak

1860. Incremental Memory Leak You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second. At the ith second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory)....

<span title='2021-05-15 00:00:00 +0000 UTC'>May 15, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1861. Rotating the Box

1861. Rotating the Box You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following: A stone ‘#’ A stationary obstacle ‘*’ Empty ‘.’ The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box....

<span title='2021-05-15 00:00:00 +0000 UTC'>May 15, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

198. House Robber

198. House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night. Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police....

<span title='2021-05-15 00:00:00 +0000 UTC'>May 15, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

746. Min Cost Climbing Stairs

746. Min Cost Climbing Stairs You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: cost = [10,15,20] Output: 15 Explanation: Cheapest is: start on cost[1], pay that cost, and go to the top....

<span title='2021-05-15 00:00:00 +0000 UTC'>May 15, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

438. Find All Anagrams in a String

438. Find All Anagrams in a String Given two strings s and p, return an array of all the start indices of p’s anagrams in s. You may return the answer in any order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: s = "cbaebabacd", p = "abc" Output: [0,6] Explanation: The substring with start index = 0 is "cba", which is an anagram of "abc"....

<span title='2021-05-11 00:00:00 +0000 UTC'>May 11, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

66. Plus One

66. Plus One Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. You may assume the integer does not contain any leading zero, except the number 0 itself. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: digits = [1,2,3] Output: [1,2,4] Explanation: The array represents the integer 123....

<span title='2021-05-11 00:00:00 +0000 UTC'>May 11, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1208. Get Equal Substrings Within Budget

1208. Get Equal Substrings Within Budget You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the absolute difference between the ASCII values of the characters. You are also given an integer maxCost. Return the maximum length of a substring of s that can be changed to be the same as the corresponding substring of twith a cost less than or equal to maxCost....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1342. Number of Steps to Reduce a Number to Zero

1342. Number of Steps to Reduce a Number to Zero Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: num = 14 Output: 6 Explanation: Step 1) 14 is even; divide by 2 and obtain 7....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1344. Angle Between Hands of a Clock

1344. Angle Between Hands of a Clock Given two numbers, hour and minutes. Return the smaller angle (in degrees) formed between the hour and the minute hand. 1 2 3 4 Example 1: Input: hour = 12, minutes = 30 Output: 165 1 2 3 4 Example 2: Input: hour = 3, minutes = 30 Output: 75 1 2 3 4 Example 3: Input: hour = 3, minutes = 15 Output: 7....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

443. String Compression

1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold Given an array of integers arr and two integers k and threshold. Return the number of sub-arrays of size k and average greater than or equal to threshold. 1 2 3 4 5 Example 1: Input: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4 Output: 3 Explanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

443. String Compression

443. String Compression Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group’s length is 1, append the character to s. Otherwise, append the character followed by the group’s length. The compressed string s should not be returned separately, but instead be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars....

<span title='2021-05-10 00:00:00 +0000 UTC'>May 10, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx