c++

[Solved] Negative Prefix C++,Java, Python

Negative Prefix

Given an array A[] of N integers. In each operation, Geek can increase the ith element by 1 (i.e set A[i] = A[i]+1 where 1 < i < N).The task is to calculate the minimum number of operations required such that there is no prefix in the array A[] whose sum…

[Solved]  Shortest and Lexicographically Smallest Beautiful String C++, Java , Python

Lexicographically

You are given a binary string s and a positive integer k. A substring of s is beautiful if the number of 1‘s in it is exactly k. Let len be the length of the shortest beautiful substring. Return the lexicographically smallest beautiful substring of string s with length equal to len. If s doesn’t contain a beautiful substring, return an empty string. A…

[Solved] Maximise Sum C++, Java , Python

Maximise Sum

You are given an array A consisting of N positive integers. You are allowed to do the following operation any number of times: Find the maximum value of ∑i=1N​Ai​ that you can achieve after any (possibly zero) number of operations. Input Format Output Format For each test case,…