procedure visit(node root,int c) {
if (root= null)
return 0;
S[c] += n.value;
visit(root-left, c - 1)
visit(root-right, c + 1)
}
On Fri, Oct 21, 2011 at 1:22 PM, Mohak Naik mohak...@gmail.com wrote:
If we want to compute the sum of every column, we can use the following
yea i know 1st Approach is much better and is Only O(N^2) for
precomputing all the values for nck and then O(k) for finding no of
bits set in The Kth number and another loop of O(k) to find the
required number
i posted 2nd approach in the context to vandana's tree approach of
sorting 2^N numbers,
initialize array with 0 and provide appropriate value to c otherwise
it will be negative and
here c is using as index for array.
procedure visit(node root,int s[],int c) {
if (root= null)
return 0;
S[c] += n.value;
visit(root-left, c - 1)
visit(root-right, c + 1)
}
On Fri,
nice idea..
On Oct 20, 11:04 am, SUMANTH M sumanth.n...@gmail.com wrote:
- Take another sum array which contains sums of original array at each
index, here sum[0] = a[0]; sum[1] = a[0] + a[1]
;...sum[i]=a[0]+a[1]+...a[i];
- Traverse the sum array and search for duplicates.
ex: a[] =
@Sunny
Your technique of Inshuffle and Outshuffle are perfect. But how to translate
into the code without using extra space or say even constant space
On Tue, Oct 18, 2011 at 12:43 AM, Dan dant...@aol.com wrote:
I have a hard copy of the book (years back, I implemented a fortran
version of
Can anyone explain why ((n%p)*(m%p))%p will give wrong answer ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
how about this O(nm) solution?
first create a 26 length int array
for each word, store the number of times each character appears in the word,
in the above 26 length array O(m)...
Insert this value in a trie (insertion=O(m))... example if the sorted string
contains a-4times, b-3 times, c-2 times,
On Sat, Oct 22, 2011 at 9:04 PM, Mad Coder imamadco...@gmail.com wrote:
Can anyone explain why ((n%p)*(m%p))%p will give wrong answer ?
Lets say, n = 10^15 , m = 10^15 and p = 10^18
So,
n%p = 10^15
m%p = 10^15
And the intermediate result (n%p)*(m%p) will overflow the long long range.