anshuk2305
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
(m+n)! , but since the order of elements in string 1 n 2 should remain same. No of ways : (m+n)!/(m!xn!)
- anshuk2305 February 12, 2019Comment hidden because of low score. Click to expand.
0
of 0 vote
This could be done by binary approach i guess.
The max distance btw 2 ppl possible is if one sits first & other at last i.e. 0 and n.
So if we have 'c' ppl.
We have a possibility of answer being from 0(all at the same seat) to n(one at start other at end).
low=0, high=n;
if(mid is possible)
then try possibilities > mid; //left=mid+1;
else
try possibilities <mid ; //right=mid-1;
'mid' is possible can be checked if we place c students at distances of mid from one another , such that total distance btw first and last does not exceed n.
Hope it makes sense :P .
Please let me know if doesnot pass for any case.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Doesn't work for - 111
- anshuk2305 March 25, 2019Possible subarrays - {1,1} {1,1} ,{1}{1} .