|
0
When u is the root,it's useless to do operation on u Can you explain why? |
|
0
these lower bounds are obtained by applying conditions of x>=0 and y>=0 in obtained equations |
|
+3
How is this pref[i]/i coming, I understand that if all i-1 are filled, then each second i unit of water falls into ith one. But the the i-1 vessels would not be filled simultaneously, may be (i-1) gets filled first and some amount falls from that to ith one, I mean it's vaguely clear how it's coming but i dont feel any strong maths , can anyone please explain |
|
+3
I have somewhat different idea for C, Some observations we can make: 1)In string s, if we have a 'c' at some position,then characters to left of it always remain left and characters to right of it always remain right.Similarly in string t, if we have 'a' at some position. 2)From 1 we can immediately say that if there is index i such that s[i]='c' & t[i]='a' ,then answer never exists. 3)strings should be anagram of each other Now suppose that i is first index where a 'c'occurs in string s and j is first index where 'a' occurs in second string,and since i!=j(2nd condition) ,wlog suppose i>j ,then we can use first i-1 characters of s to match first j characters of t,this can easily checked if count a,b,c in s till i-1 is greater or equal to count of a,b,c in t till j,now we reduce frequency count of a,b,c in string s. This works because till i-1 we have only 'a' and 'b' in s and since they can cross each other i would be able to achieve any configuration of 'a'and 'b' to match first j characters of t.Now we move to next 'a' in t(because i>j) and disregard first j characters of both strings For example: bcaabababc cbbababaac we start from left i=2 and j=4 count of a,b,c in s=0,1,1 till i and count of a,b,c in t=0,2,1 till j-1 and count in t is greater or equal we move to next 'c'(because i<j) and disregard first 2 characters now i=10 and j=4, count a,b,c in s=4,3,0 till i-1 and count of a,b,c in t=1,1,0 .Again condition is true,we move to next 'a' in t. i=10,j=6 count of a,b,c in s=3,2,0 till i-1 and count of a,b,c in t till j is 1,1,0.Again condition comes to be true. move to next 'a' in t. i=10 j=8 (a,b,c) in s is(2,1,0) and in t is(1,1,0). Again true. move to next 'a' in t .in s (1,0,0) and in t (1,0,0) .Again true and we dont have any more 'a' to move for . and hence we terminate and we can say it is possible to interconvert s and t |
|
0
Thnx |
|
0
Can you please explain how you used binary search I thought of doing so, searching for optimal distance but got dtucked on how to verify if the rhombus around all black points intersect at some pointfor current mid |
|
0
I thought like if I want to pair smallest element of A then with which element of B it should be paired with, most obvious choice seemed to be smallest elemnt of B, because if smallest element of A gave answer with any other elemnt of B then it would be give positive answer with smallest too, and if did not give answer with any other then I am not making answer worse by pairing it with smallest element of B as there are chances that it would give positive answer with smallest element of B, By positive answer I mean conditon of A[i]>B[i] is true |