Request for Solutions to few problems stated Below!

Правка en2, от retr0coderxyz, 2020-03-01 08:33:51

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.

My Idea

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.

My Idea

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

My Idea

Problem 4:

Given a character for each node. and given a graph(its guarenteed to be a tree). Q queries with each query giving x y. We have to find for each query a consider a simple path from x->y find the most frequent character along the path. For eg.

6
a b a s q n
(n-1 edges)
1 2
1 3
2 6
3 4
3 5
2
2 3  => a
2 6  => b(print lexicographically smaller in case of tie)
My Idea

Thank you for reading patiently guys, I tried so much to come up with a solution but couldnt so any help would be greatly appreciated guys.

Теги #hackerearth, help needed

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский retr0coderxyz 2020-03-01 08:33:51 1235 (published)
en1 Английский retr0coderxyz 2020-03-01 08:20:26 2042 Initial revision (saved to drafts)