1013. Partition Array Into Three Parts With Equal Sum

1013. Partition Array Into Three Parts With Equal Sum Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums. Formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + … + arr[i] == arr[i + 1] + arr[i + 2] + … + arr[j - 1] == arr[j] + arr[j + 1] + … + arr[arr....

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

243. Shortest Word Distance

243. Shortest Word Distance Given an array of strings wordsDict and two different strings that already exist in the array word1 and word2, return the shortest distance between these two words in the list. 1 2 3 4 5 6 7 8 9 Example 1: Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "coding", word2 = "practice" Output: 3 Example 2: Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "coding" Output: 1 Constraints:...

<span title='2021-06-08 00:00:00 +0000 UTC'>June 8, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

191. Number of 1 Bits

191. Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ‘1’ bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer’s internal binary representation is the same, whether it is signed or unsigned....

<span title='2021-06-07 00:00:00 +0000 UTC'>June 7, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

231. Power of Two

231. Power of Two Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n = 16 Output: true Explanation: 24 = 16 Example 3: Input: n = 3 Output: false Example 4: Input: n = 4 Output: true Example 5: Input: n = 5 Output: false Constraints:...

<span title='2021-06-07 00:00:00 +0000 UTC'>June 7, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

832. Flipping an Image

832. Flipping an Image Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. For example, flipping [1,1,0] horizontally results in [0,1,1]. To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0. For example, inverting [0,1,1] results in [1,0,0]....

<span title='2021-06-06 00:00:00 +0000 UTC'>June 6, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1441. Build an Array With Stack Operations

1441. Build an Array With Stack Operations Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3…, n}. Build the target array using the following operations: Push: Read a new element from the beginning list, and push it in the array. Pop: delete the last element of the array. If the target array is already built, stop reading more elements. Return the operations to build the target array....

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

1876. Substrings of Size Three with Distinct Characters

1876. Substrings of Size Three with Distinct Characters A string is good if there are no repeated characters. Given a string s​​​​​, return the number of good substrings of length three in s​​​​​​. Note that if there are multiple occurrences of the same substring, every occurrence should be counted. A substring is a contiguous sequence of characters in a string. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: s = "xyzzaz" Output: 1 Explanation: There are 4 substrings of size 3: "xyz", "yzz", "zza", and "zaz"....

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

1878. Get Biggest Three Rhombus Sums in a Grid

1878. Get Biggest Three Rhombus Sums in a Grid You are given an m x n integer matrix grid​​​. A rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:...

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

938. Range Sum of BST

938. Range Sum of BST Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. 1 2 3 4 5 Example 1: Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32....

<span title='2021-05-25 00:00:00 +0000 UTC'>May 25, 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

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

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

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

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

1207. Unique Number of Occurrences

1207. Unique Number of Occurrences Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. 1 2 3 4 5 Example 1: Input: arr = [1,2,2,1,1,3] Output: true Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. 1 2 3 4 Example 2: Input: arr = [1,2] Output: false 1 2 3 4 Example 3: Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] Output: true Constraints:...

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