You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is theContinue reading “[Leetcode]1626. Best Team With No Conflicts”sumof scores of all the players in the team. However, the basketball team is not allowed to haveconflicts. Aconflictexists if a younger player has astrictly higherscore than an older player. A conflict doesnotoccur between players of the same age. Given two lists,`scores`

and`ages`

, where each`scores[i]`

and`ages[i]`

represents the score and age of the`i`

player, respectively, return^{th}the highest overall score of all possible basketball teams.

## [Challenge]Minimum adjacent swaps required to Sort Binary array

Given a binary array, task is to sort this binary array using minimum swaps. We are allowed to swap only adjacent elementsContinue reading “[Challenge]Minimum adjacent swaps required to Sort Binary array”

## [Leetcode]179. Largest Number

Given a list of non negative integers, arrange them such that they form the largest number.Continue reading “[Leetcode]179. Largest Number”

## [Leetcode]48. Rotate Image

You are given anContinue reading “[Leetcode]48. Rotate Image”nxn2D`matrix`

representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the imagein-place, which means you have to modify the input 2D matrix directly.DO NOTallocate another 2D matrix and do the rotation.

## [Leetcode]1589. Maximum Sum Obtained of Any Permutation

We have an array of integers,Continue reading “[Leetcode]1589. Maximum Sum Obtained of Any Permutation”`nums`

, and an array of`requests`

where`requests[i] = [start`

. The_{i}, end_{i}]`i`

request asks for the sum of^{th}`nums[start`

. Both_{i}] + nums[start_{i}+ 1] + ... + nums[end_{i}- 1] + nums[end_{i}]`start`

and_{i}`end`

are_{i}0-indexed. Returnthe maximum total sum of all requestsamong all permutationsof`nums`

. Since the answer may be too large, return itmodulo`10`

.^{9}+ 7

## [Leetcode]1590. Make Sum Divisible by P

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]33. Search in Rotated Sorted Array

You are given an integer arrayContinue reading “[Leetcode]33. Search in Rotated Sorted Array”`nums`

sorted in ascending order, and an integer`target`

. Suppose that`nums`

is rotated at some pivot unknown to you beforehand (i.e.,`[0,1,2,4,5,6,7]`

might become`[4,5,6,7,0,1,2]`

).If`target`

is found in the array return its index, otherwise, return`-1`

.

## [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?