Re: [algogeeks] Re: another google telephone interview question

2010-05-19 Thread Channa Bankapur
Aarthi, i think you are assuming the K keys are 0 to K-1 so that you can use the array index as its value to count. I doubt of a solution of O(K) space and O(N) time! ./Channa On Wed, May 19, 2010 at 4:39 PM, Aarthi Thangamani < aarthi.thangam...@gmail.com> wrote: > If you are using an extra spa

[algogeeks] Re: 100!

2009-10-11 Thread Channa Bankapur
Project Euler (http://projecteuler.net) has an exciting set of questions. Please don't spoil the fun of it by discussing them here. Once you solve a problem in Project Euler, you get access to the discussion thread of the problem. ./Channa On Sun, Oct 11, 2009 at 10:59 AM, Anil C R wrote: > > P

[algogeeks] Re: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-22 Thread Channa Bankapur
@eSKay, @Ankur, et al., Please be aware that there are non-Indians too in the group. Hi All, Let me try and define the problem precisely (as far as I can). The ATM machines, which we generally see in India have the following behavior when an user tries to withdraw money from their Bank account.

[algogeeks] Re: Missing numbers

2009-08-03 Thread Channa Bankapur
Elegant.. I think it can't be better than this. Identifying that each of them are on different sides of S/2 was the key! On Tue, Aug 4, 2009 at 10:05 AM, Prunthaban Kanthakumar < pruntha...@gmail.com> wrote: > Here is the right answer: > > Find the sum of missing numbers. Call it S (this is a eas

[algogeeks] Re: Missing numbers

2009-07-31 Thread Channa Bankapur
There is something wrong with it. I tried your code like this. int i, n = 8, a[9] = {-1,3,5,1,2,9,10,8,6}; //a[0] is never touched in the logic for(i=1; i<=n ;i++ ) //for ease of understanding starting the array with 1. { if(a[ i ] > n ) continue; else a[ a [ i ] ]*=n; } int x[2], m = 0;

[algogeeks] Re: Missing numbers

2009-07-30 Thread Channa Bankapur
Good catch, Vikram. I had a wrong assumption that the pair (i, sumofXY-i) would uniquely match with xorofXY. Here is a counter example to disprove my solution. Suppose X is 5 (binary 101) and Y is 6 (b 110), whose XOR would be 3 (b 011). But, moving unit bit from 5 to 6, we have a pair 4 (100) and

[algogeeks] Re: Missing numbers

2009-07-29 Thread Channa Bankapur
Here is a pseudocode for one of the solutions sumN = sum of all the elements of the arraysumN2 = sum of 1 to (n+2) sumofXY = sumN2 - sumN /*sum of the interested integers, say x, y*/ xorN = XOR of all the elements of the array xorN2 = XOR of 1 to (n+2) xorofXY = xorN XOR xorN2 /*XOR of x, y*/ for

[algogeeks] Re: FACTS TO MAKE EVERY Indian PROUD

2009-01-25 Thread Channa Bankapur
Please don't post these mails in such groups. How on earth this mail is relevant for algogeeks? Moreover, this mail is years old, and most of these facts are no more true. On Sun, Jan 25, 2009 at 12:56 PM, deepanshu shukla < deepanshus.it...@gmail.com> wrote: > FACTS TO MAKE EVERY Indian PROUD >

[algogeeks] Re: Lucky numbers

2009-01-06 Thread Channa Bankapur
; Pratyush Tewari > > > > On Mon, Jan 5, 2009 at 12:30 AM, Vijay Venkat Raghavan N > wrote: > > Guys this is wrong. Lucky number is basically a prime number if you > observe > > the definition carefully, and this approach of determining primality > > obviously won&#

[algogeeks] Re: Lucky numbers

2009-01-04 Thread Channa Bankapur
Here is the C-version of the same. It tells you whether given n is lucky or not. void luckyOrNot(long int n){ long int n2 = n; int i= 2; while(n2>=i){ if(n2%i == 0){ printf("%ld got unlucky when i was %d\n", n, i); break; } n2 = n2 - (n2/i); i++; } if(n2 wrote: > first n will be the nth number

[algogeeks] Re: insert a node in a Linklist

2008-12-18 Thread Channa Bankapur
It's necessary to handle the scenario of i=0. So, if the node has to be inserted in the beginning of the list, the pointer p to the list has to change. With your suggested solution, it wouldn't be possible to see the changed value of p in the calling function. If you assume you would never insert

[algogeeks] Re: Discussion on unique-elements-in-an-array

2007-11-06 Thread Channa Bankapur
Hi MD, In your last approach, watch out for arbitrarily large values. What would 'N' be? By the way, 'for' loop there should be for 'n', which is the size of array 'a'. A simple array like {20, 5, 123456789} would kill your memory. Hashing approach would be great if we've some idea on nature of th

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Channa Bankapur
0, -20 Now apply the Improvement1 algo and you'll get a sum of 65. Talking about complexity of this method little complex, so i would leave it till it becomes necessary to talk about. Regards, Channa On 10/17/07, Muntasir Azam Khan <[EMAIL PROTECTED]> wrote: > > > > &

[algogeeks] Re: subset with maximum sum.

2007-10-17 Thread Channa Bankapur
Kannan must have meant for "subsequence". Without looking into Kadane's algo, I was trying to put constraints away from brute-force. 1. Terminal numbers of the subsequence has to be non-negative. Proof is - if a terminal number is negative, just exclude that and you'll get a higher sum. Regards, C

[algogeeks] Fwd: [iiscbalaga] Microsoft workshop on Algorithm Complexity and Cryptology

2006-03-02 Thread Channa Bankapur
/   To unsubscribe from this group, send an email to:[EMAIL PROTECTED]   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. -- Thanks & Regards,Channa Bankapur[CHANNABASAVANNA B.S.]Bengalooru, INDIA.My country, right or wrong; if wrong, to be set right; if right, to be