1913. Maximum Product Difference Between Two Pairs

1913. Maximum Product Difference Between Two Pairs The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d). For example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16. Given an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized....

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

1071. Greatest Common Divisor of Strings

1071. Greatest Common Divisor of Strings For two strings s and t, we say “t divides s” if and only if s = t + … + t (t concatenated with itself 1 or more times) Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: str1 = "ABCABC", str2 = "ABC" Output: "ABC" Example 2: Input: str1 = "ABABAB", str2 = "ABAB" Output: "AB" Example 3: Input: str1 = "LEET", str2 = "CODE" Output: "" Example 4: Input: str1 = "ABCDEF", str2 = "ABC" Output: "" Constraints:...

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

204. Count Primes

204. Count Primes Count the number of prime numbers less than a non-negative number, n. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. Example 2: Input: n = 0 Output: 0 Example 3: Input: n = 1 Output: 0 Constraints:...

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

83. Remove Duplicates from Sorted List

1625. Lexicographically Smallest String After Applying Operations Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. 1 2 3 4 Example 1: Input: head = [1,1,2] Output: [1,2] 1 2 3 4 Example 2: Input: head = [1,1,2,3,3] Output: [1,2,3] Constraints: The number of nodes in the list is in the range [0, 300]. -100 <= Node....

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

1624. Largest Substring Between Two Equal Characters

1624. Largest Substring Between Two Equal Characters Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring is a contiguous sequence of characters within a string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Example 1: Input: s = "aa" Output: 0 Explanation: The optimal substring here is an empty substring between the two 'a's....

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

206. Reverse Linked List

206. Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list. 1 2 3 4 Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] 1 2 3 4 Example 2: Input: head = [1,2] Output: [2,1] 1 2 3 4 Example 3: Input: head = [] Output: [] Constraints: The number of nodes in the list is the range [0, 5000]. -5000 <= Node....

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

237. Delete Node in a Linked List

237. Delete Node in a Linked List Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. 1 2 3 4 5 Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function....

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

680. Valid Palindrome II

680. Valid Palindrome II Given a string s, return true if the s can be palindrome after deleting at most one character from it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could delete the character 'c'. Example 3: Input: s = "abc" Output: false Constraints:...

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

67. Add Binary

67. Add Binary Given two binary strings a and b, return their sum as a binary string. 1 2 3 4 5 6 7 8 9 Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: 1 <= a.length, b.length <= 104 a and b consist only of ‘0’ or ‘1’ characters. Each string does not contain leading zeros except for the zero itself....

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

1897. Redistribute Characters to Make All Strings Equal

1897. Redistribute Characters to Make All Strings Equal You are given an array of strings words (0-indexed). In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j]. Return true if you can make every string in words equal using any number of operations, and false otherwise. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: words = ["abc","aabc","bc"] Output: true Explanation: Move the first 'a' in words[1] to the front of words[2], to make words[1] = "abc" and words[2] = "abc"....

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

338. Counting Bits"

338. Counting Bits Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 --> 0 1 --> 1 2 --> 10 Example 2: Input: n = 5 Output: [0,1,1,2,1,2] Explanation: 0 --> 0 1 --> 1 2 --> 10 3 --> 11 4 --> 100 5 --> 101 Constraints:...

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

136. Single Number

136. Single Number Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input: nums = [1] Output: 1 Constraints:...

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

190. Reverse Bits

190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer’s internal binary representation is the same, whether it is signed or unsigned. In Java, the compiler represents the signed integers using 2’s complement notation....

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

268. Missing Number

268. Missing Number Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Follow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]....

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

389. Find the Difference

389. Find the Difference You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example 1: Input: s = "abcd", t = "abcde" Output: "e" Explanation: 'e' is the letter that was added....

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