contest

[Solved] Apple Redistribution into Boxes leetcode C++,JAVA, Python

Apple Redistribution

You are given an array apple of size n and an array capacity of size m. There are n packs where the ith pack contains apple[i] apples. There are m boxes as well, and the ith box has a capacity of capacity[i] apples. Return the minimum number of boxes you need to select to redistribute these n packs of apples into boxes. Note that, apples…

[Solved] Minimize XOR LeetCode Contest Problem

[Solved] Minimize XOR LeetCode Contest Problem

Given two positive integers num1 and num2, find the integer x such that: x has the same number of set bits as num2, and The value x XOR num1 is minimal. Note that XOR is the bitwise XOR operation. Return the integer x. The test cases are generated such that x is uniquely determined. The number of set…

[Solved] Maximum Segment Sum After Removals LeetCode Contest

[Solved] Maximum Segment Sum After Removals LeetCode Contest

You are given two 0-indexed integer arrays nums and removeQueries, both of length n. For the ith query, the element in nums at the index removeQueries[i] is removed, splitting nums into different segments. A segment is a contiguous sequence of positive integers in nums. A segment sum is the sum of every element in a segment. Return an integer array answer, of length n,…

[Solved] Shifting Letters II LeetCode Contest

[Solved] Shifting Letters II LeetCode Contest

You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusive) forward if directioni = 1, or shift the characters backward if directioni = 0. Shifting a character forward means replacing it…

[Solved] Time Needed to Rearrange a Binary String LeetCode Contest

[Solved] Time Needed to Rearrange a Binary String LeetCode Contest

You are given a binary string s. In one second, all occurrences of “01” are simultaneously replaced with “10”. This process repeats until no occurrences of “01” exist. Return the number of seconds needed to complete this process. Time Needed to Rearrange a Binary String LeetCode Contest Example 1: Input: s = “0110101”…