java

[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”…