Given an array of positive integersContinue reading “[Leetcode]1590. Make Sum Divisible by P”`nums`

, remove thesmallestsubarray (possiblyempty) such that thesumof the remaining elements is divisible by`p`

. It isnotallowed to remove the whole array. Returnthe length of the smallest subarray that you need to remove, or`-1`

if it's impossible. Asubarrayis defined as a contiguous block of elements in the array.

## [Leetcode]421. Maximum XOR of Two Numbers in an Array

Given aContinue reading “[Leetcode]421. Maximum XOR of Two Numbers in an Array”non-emptyarray of numbers, a_{0}, a_{1}, a_{2}, … , a_{n-1}, where 0 ≤ a_{i}< 2^{31}. Find the maximum result of a_{i}XOR a_{j}, where 0 ≤i,j<n. Could you do this in O(n) runtime?

## [Leetcode]560. Subarray Sum Equals K

Given an array of integers and an integerContinue reading “[Leetcode]560. Subarray Sum Equals K”k, you need to find the total number of continuous subarrays whose sum equals tok.Example 1:Input:nums = [1,1,1], k = 2Output:2

## [Leetcode]1. Two Sum

Given an array of integers, returnContinue reading “[Leetcode]1. Two Sum”indicesof the two numbers such that they add up to a specific target. You may assume that each input would haveone solution, and you may not use theexactlysameelement twice.Example:Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0,1].

## [Leetcode]1497. Check If Array Pairs Are Divisible by k

Given an array of integersContinue reading “[Leetcode]1497. Check If Array Pairs Are Divisible by k”`arr`

of even length`n`

and an integer`k`

. We want to divide the array into exactly`n / 2`

pairs such that the sum of each pair is divisible by`k`

. ReturnTrueIf you can find a way to do that orFalseotherwise.Example 1:Input:arr = [1,2,3,4,5,10,6,7,8,9], k = 5Output:trueExplanation:Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).