221. Maximal Square

221. Maximal Square Given an m x n binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. 1 2 3 4 Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 4 1 2 3 4 Example 2: Input: matrix = [["0","1"],["1","0"]] Output: 1 1 2 3 4 Example 3: Input: matrix = [["0"]] Output: 0 Constraints: m == matrix.length n == matrix[i].length 1 <= m, n <= 300 matrix[i][j] is ‘0’ or ‘1’....

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

1852. Distinct Numbers in Each Subarray

1852. Distinct Numbers in Each Subarray Given an integer array nums and an integer k, you are asked to construct the array ans of size n-k+1 where ans[i] is the number of distinct numbers in the subarray nums[i:i+k-1] = [nums[i], nums[i+1], …, nums[i+k-1]]. Return the array ans. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example 1: Input: nums = [1,2,3,2,2,1,3], k = 3 Output: [3,2,2,2,3] Explanation: The number of distinct elements in each subarray goes as follows: - nums[0:2] = [1,2,3] so ans[0] = 3 - nums[1:3] = [2,3,2] so ans[1] = 2 - nums[2:4] = [3,2,2] so ans[2] = 2 - nums[3:5] = [2,2,1] so ans[3] = 2 - nums[4:6] = [2,1,3] so ans[4] = 3 Example 2: Input: nums = [1,1,1,1,2,3,4], k = 4 Output: [1,2,3,4] Explanation: The number of distinct elements in each subarray goes as follows: - nums[0:3] = [1,1,1,1] so ans[0] = 1 - nums[1:4] = [1,1,1,2] so ans[1] = 2 - nums[2:5] = [1,1,2,3] so ans[2] = 3 - nums[3:6] = [1,2,3,4] so ans[3] = 4 Constraints:...

<span title='2021-05-27 00:00:00 +0000 UTC'>May 27, 2021</span>&nbsp;·&nbsp;2 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

472. Concatenated Words

472. Concatenated Words Given an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array. 1 2 3 4 5 6 7 8 9 10 11 12 Example 1: Input: words = ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"] Output: ["catsdogcats","dogcatsdog","ratcatdogcat"] Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats"; "dogcatsdog" can be concatenated by "dog", "cats" and "dog"; "ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat"....

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

216. Combination Sum III

216. Combination Sum III Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number is used at most once. Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in any order. 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 27 28 29 30 31 32 33 34 35 36 37 Example 1: Input: k = 3, n = 7 Output: [[1,2,4]] Explanation: 1 + 2 + 4 = 7 There are no other valid combinations....

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

39. Combination Sum

39. Combination Sum Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different. It is guaranteed that the number of unique combinations that sum up to target is less than 150 combinations for the given input....

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

40. Combination Sum II

40. Combination Sum II Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used once in the combination. Note: The solution set must not contain duplicate combinations. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [ [1,1,6], [1,2,5], [1,7], [2,6] ] Example 2: Input: candidates = [2,5,2,1,2], target = 5 Output: [ [1,2,2], [5] ] Constraints:...

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

473. Matchsticks to Square

473. Matchsticks to Square You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time. Return true if you can make this square and false otherwise. 1 2 3 4 5 Example 1: Input: matchsticks = [1,1,2,2,2] Output: true Explanation: You can form a square with length 2, one side of the square came two sticks with length 1....

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

477. Total Hamming Distance

477. Total Hamming Distance The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: nums = [4,14,2] Output: 6 Explanation: In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just showing the four bits relevant in this case)....

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

494. Target Sum

494. Target Sum You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols ‘+’ and ‘-’ before each integer in nums and then concatenate all the integers. For example, if nums = [2, 1], you can add a ‘+’ before 2 and a ‘-’ before 1 and concatenate them to build the expression “+2-1”. Return the number of different expressions that you can build, which evaluates to target....

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

93. Restore IP Addresses

93. Restore IP Addresses Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order. A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single dots and cannot have leading zeros. For example, “0.1.2.201” and “192.168.1.1” are valid IP addresses and “0.011.255.245”, “192.168.1.312” and “192.168@1.1” are invalid IP addresses....

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

139. Word Break

139. Word Break Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: true Explanation: Return true because "leetcode" can be segmented as "leet code"....

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

322. Coin Change

322. Coin Change You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin....

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

328. Odd Even Linked List

328. Odd Even Linked List Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. Note that the relative order inside both the even and odd groups should remain as it was in the input. 1 2 3 4 Example 1: Input: head = [1,2,3,4,5] Output: [1,3,5,2,4] 1 2 3 4 Example 2: Input: head = [2,1,3,5,6,4,7] Output: [2,3,6,7,1,5,4] Constraints:...

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

91. Decode Ways

91. Decode Ways A message containing letters from A-Z can be encoded into numbers using the following mapping: ‘A’ -> “1” ‘B’ -> “2” … ‘Z’ -> “26” To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, “11106” can be mapped into: “AAJF” with the grouping (1 1 10 6) “KJF” with the grouping (11 10 6) Note that the grouping (1 11 06) is invalid because “06” cannot be mapped into ‘F’ since “6” is different from “06”....

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