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

50. Pow(x, n)

50. Pow(x, n) Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0....

<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

1004. Max Consecutive Ones III

11004. Max Consecutive Ones III Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,1,1,1] Bolded numbers were flipped from 0 to 1. The longest subarray is underlined....

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

11. Container With Most Water

11. Container With Most Water Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container....

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

159. Longest Substring with At Most Two Distinct Characters

159. Longest Substring with At Most Two Distinct Characters Given a string s, return the length of the longest substring that contains at most two distinct characters. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: s = "eceba" Output: 3 Explanation: The substring is "ece" which its length is 3. Example 2: Input: s = "ccaabbb" Output: 5 Explanation: The substring is "aabbb" which its length is 5....

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

209. Minimum Size Subarray Sum

209. Minimum Size Subarray Sum Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, …, numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The subarray [4,3] has the minimal length under the problem constraint....

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

3. Longest Substring Without Repeating Characters

3. Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. 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 = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1....

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

424. Longest Repeating Character Replacement

424. Longest Repeating Character Replacement You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest substring containing the same letter you can get after performing the above operations. 1 2 3 4 5 6 7 8 9 10 11 12 Example 1: Input: s = "ABAB", k = 2 Output: 4 Explanation: Replace the two 'A's with two 'B's or vice versa....

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

340. Longest Substring with At Most K Distinct Characters

340. Longest Substring with At Most K Distinct Characters Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: s = "eceba", k = 2 Output: 3 Explanation: The substring is "ece" with length 3. Example 2: Input: s = "aa", k = 1 Output: 2 Explanation: The substring is "aa" with length 2....

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

76. Minimum Window Substring

76. Minimum Window Substring Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string “”. The testcases will be generated such that the answer is unique. A substring is a contiguous sequence of characters within the string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Example 1: Input: s = "ADOBECODEBANC", t = "ABC" Output: "BANC" Explanation: The minimum window substring "BANC" includes 'A', 'B', and 'C' from string t....

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

1625. Lexicographically Smallest String After Applying Operations

1625. Lexicographically Smallest String After Applying Operations You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b. You can apply either of the following two operations any number of times and in any order on s: Add a to all odd indices of s (0-indexed). Digits post 9 are cycled back to 0. For example, if s = “3456” and a = 5, s becomes “3951”....

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