Node *LCA(node *root, node *e1, node *e2, int x)
{
Node *temp =NULL;
Int y = 0;
If (root-left) temp = LCA(root-left, e1, e2, y);
x+=y;
if (temp) return temp;
if (x==2) return node;
This is a beautiful way to express the algorithm. The magic that Don
has omitted is that just as in normal binary search, you can
hypthesize that A[i] is the k'th element meaning that A[1..i-1] = k,
which forces you to conclude the other k-i elements must be in the
prefix of B, which is
Given a string of lowercase characters, reorder them such that the same
characters are at least distance d from each other.
Input: { a, b, b }, distance = 2
Output: { b, a, b }
How to approach this question ?
--
You received this message because you are subscribed to the Google Groups
hi don i have now implemented it with bfs but it's still giving wrong
answer can you please tell the test case
#includestdio.h
int a[1000100][2];
int visited[1000100],i,q[1000100];
int main()
{
int f,s,g,u,d;
scanf(%d%d%d%d%d,f,s,g,u,d);
for( i = 1 ; i = f;i++)
{
if(i + u
thanx Don.
i think my logic is not so good . now i try to make it using bfs .
*Anshul Agarwal
Nit Allahabad
Computer Science**
*
On Tue, Nov 15, 2011 at 5:36 PM, Don dondod...@gmail.com wrote:
This input
100 1 5 5 91
Should output 20. Yours says Take the stairs.
100 1 5 5 89
Should
Start with counting sort of the input.
Use shuffling algorithm on it.
Store index as cumulative sums of counts.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit