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

833. Find And Replace in String

833. Find And Replace in String To some string s, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y....

<span title='2021-06-06 00:00:00 +0000 UTC'>June 6, 2021</span>&nbsp;·&nbsp;3 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

77. Combinations

77. Combinations Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Example 1: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] Example 2: Input: n = 1, k = 1 Output: [[1]] Constraints:...

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

1041. Robot Bounded In Circle

1041. Robot Bounded In Circle On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: “G”: go straight 1 unit; “L”: turn 90 degrees to the left; “R”: turn 90 degrees to the right. The robot performs the instructions given in order, and repeats them forever. Return true if and only if there exists a circle in the plane such that the robot never leaves the circle....

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

17. Letter Combinations of a Phone Number

17. Letter Combinations of a Phone Number Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] Example 2: Input: digits = "" Output: [] Example 3: Input: digits = "2" Output: ["a","b","c"] Constraints:...

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

189. Rotate Array

189. Rotate Array Given an array, rotate the array to the right by k steps, where k is non-negative. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Example 1: Input: nums = [1,2,3,4,5,6,7], k = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1,2,3,4,5,6] rotate 2 steps to the right: [6,7,1,2,3,4,5] rotate 3 steps to the right: [5,6,7,1,2,3,4] Example 2: Input: nums = [-1,-100,3,99], k = 2 Output: [3,99,-1,-100] Explanation: rotate 1 steps to the right: [99,-1,-100,3] rotate 2 steps to the right: [3,99,-1,-100] Constraints:...

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

22. Generate Parentheses

22. Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 1 2 3 4 5 6 7 8 9 Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["()"] Constraints: 1 <= n <= 8 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class Solution { public List<String> generateParenthesis(int n) { List<String> res = new ArrayList<>(); backtracking("(", 1, 0, n, res); return res; } void backtracking(String s, int open, int closed, int n, List<String> res) { if (open + closed == 2 * n) { res....

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

90. Subsets II

90. Subsets II Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. 1 2 3 4 5 6 7 8 9 Example 1: Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] Example 2: Input: nums = [0] Output: [[],[0]] Constraints: 1 <= nums.length <= 10 -10 <= nums[i] <= 10 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public List<List<Integer>> subsetsWithDup(int[] nums) { List<List<Integer>> res = new ArrayList<>(); List<Integer> current = new ArrayList<>(); Arrays....

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

343. Integer Break

343. Integer Break Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: n = 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input: n = 10 Output: 36 Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36....

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

46. Permutations

46. Permutations Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2: Input: nums = [0,1] Output: [[0,1],[1,0]] Example 3: Input: nums = [1] Output: [[1]] Constraints: 1 <= nums.length <= 6 -10 <= nums[i] <= 10 All the integers of nums are unique....

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

78. Subsets

78. Subsets Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. 1 2 3 4 5 6 7 8 9 Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]] Constraints: 1 <= nums.length <= 10 -10 <= nums[i] <= 10 All the numbers of nums are unique....

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

1877. Minimize Maximum Pair Sum in Array

1877. Minimize Maximum Pair Sum in Array The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs. For example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8. Given an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:...

<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