Find the Longest Substring Containing Vowels in Even Counts Problem

Problem Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, ‘a’, ’e’, ‘i’, ‘o’, and ‘u’ must appear an even number of times. Examples Example 1: Input: s = "eleetminicoworoep" Output: 13 Explanation: The longest substring is "leetminicowor" which contains two each of the vowels: e, i and o and zero of the vowels: a and u. ...

Longest Subarray With Maximum Bitwise AND Problem

Problem You are given an integer array nums of size n. Consider a non-empty subarray from nums that has the maximum possible bitwise AND. In other words, let k be the maximum value of the bitwise AND of any subarray of nums. Then, only subarrays with a bitwise AND equal to k should be considered. Return the length of the longest such subarray. The bitwise AND of an array is the bitwise AND of all the numbers in it. ...

XOR Queries of a Subarray Problem

Problem You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti]. For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ). Return an array answer where answer[i] is the answer to the ith query. Examples Example 1: Input: arr = [1,3,4,8], queries = [ [0,1],[1,2],[0,3],[3,3] ] Output: [2,7,14,8] Explanation: The binary representation of the elements in the array are: 1 = 0001 3 = 0011 4 = 0100 8 = 1000 The XOR values for queries are: [0,1] = 1 xor 3 = 2 [1,2] = 3 xor 4 = 7 [0,3] = 1 xor 3 xor 4 xor 8 = 14 [3,3] = 8 ...

Count Triplets That Can Form Two Arrays of Equal XOR

Problem Given an array of integers arr. We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). Let’s define a and b as follows: a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1] b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k] Note that ^ denotes the bitwise-xor operation. ...

Score After Flipping Matrix Problem

Problem You are given an m x n binary matrix grid. A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0’s to 1’s, and all 1’s to 0’s). Every row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. Return the highest possible score after making any number of moves (including zero moves). ...

Implement Power Function 1

Problem Implement pow(x, n), which calculates x raised to the power n (i.e., x^n). Examples Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 ...

Missing Number Problem

Problem 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. Examples 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]. 2 is the missing number in the range since it does not appear in nums. ...

Binary Watch Problem

Binary Watch Problem Problem A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right. For example, the below binary watch reads "4:51". ...

Bitwise AND of Numbers Range Problem

Problem Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Examples Example 1: Input: left = 5, right = 7 Output: 4 Example 2: Input: left = 0, right = 0 Output: 0 ...

Single Number 2 - All elements except one occur thrice

Problem Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a solution with a linear runtime complexity and use only constant extra space. Examples Example 1: Input : nums = [1, 2, 4, 3, 3, 2, 2, 3, 1, 1] Output : 4 ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy