We got the news that someone was jumping on the positive integer line holding a bag of gold coins. While jumping, he always dropped a gold coin at each position from the start to the end of his jump. We can visit only an integer place and collect the gold coins at that position.
Find the smallest position with the maximum number of coins.
Function Description
In the provided code snippet , implement the provided highjump (…) method to find the smallest position with the maximum number of gold coins. You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE".
There will be multiple test cases running so the Input and Output should match exactly as provided. The base Output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these Output variables.
There are N dishes in a party named with different alphabets kept on the table given by a string S. Your friend has bought a combination of dishes donated by string D on his plate and you want the same combination of dishes for you as well. But you can choose only dishes that are kept consecutively to each other .You can also remove some dishes from the table. Suppose you remove X dishes from the table and the new set of dishes left on the table is string Q.
Find the Maximum number of non-overlapping combinations of dishes some as stringDthat can be found in stringQ, for all values ofXfrom0toN.
Function Description :
In the provided code snippet, Implement the provided maxstring (…) method to find the maximum number of non-overlapping combinations of dishes same as string D that can be found in string Q, for all values of X from 0 to N. You can write your code on the space below the phrase "WRITE YOUR LOGIC HERE".
There is an integer array A of length N and the sum of the elements of array is X. You are given an integer array B of length N, which is given as B [i] = X - A [i], for all 0 <= i <= N - 1.
Find the array A.
Note: For a given array B[i] , there will always be an array A [i]
Function Description :
In the provided code snippet, implement the provided "findarray(...)" method to find A. You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE".
There will be multiple test cases running so the Input and the Output should match exactly as provided. The base output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables.
Question 1
Below is the pseudo code:
int val = 1;
int position = v[0].first;
sort(v.begin(),v.end());
for(int i = 1; i < 2*n;i++)
{
v[i].second += v[i-1].second;
if(v[i].second > val)
{
val = v[i].second;
position = v[i].first;
}
}
Overview
Solution
Thanks for posting the solution of Question 1 !! Could you please post solutions for Questions 2 and 3 as well Manas