Hello community,
Recently I cam across 4 questions(A hiring challenge from Hacker Earth which is over now!) to which I could not find solutions. I tried my best during contest to come with solutions but I was unable to do so. It would be great if you guys could help me provide a solution for these problems(also a generic solution for similar kind of problems) Would really help me a lot. I dont remember the exact problem but I would try to provide the best description to my knowledge.
Problem 1:
We have to distribute N coins to S students such that each gets distinct number of coins while maximizing S. We have to find S. For eg. if N is 5 then S is 2 because (2,3). Its not mandatory to distribute all N coins.
Problem 2:
Swapping the segments: given array of size n and q queries with each query containing l1,r1,l2,r2 A[l1:r1] should be swapped with A[l2,r2] After Q queries we should print the final array.
Problem 3:
Given a string s we need to find two subsequence s1=s2 and maximize |s1+s2|. For eg: aabababb the answer is 6 s1=aab and s2=aab