Re: [algogeeks] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space

2012-08-13 Thread vivek rungta
@Navin- Its only for continuous number :- if size of array <= max-min for Non continuous it takes O(R) space complexity as suggested by daksh. where R is range of number. On Mon, Aug 13, 2012 at 2:55 PM, Navin wrote: > @vivek :- what if the array index goes out of bound. > I mean if |max - mi

Re: [algogeeks] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space

2012-08-13 Thread vivek rungta
On Mon, Aug 13, 2012 at 4:39 PM, vivek rungta wrote: > > @Navin- Its only for continuous number :- if size of array >= max-min > for Non continuous it takes O(R) space complexity as suggested by daksh. > where R is range of number. > > > > On Mon, Aug 13, 20

Re: [algogeeks] direct i online test

2012-08-13 Thread vivek rungta
@shobhit No, in question already mention that He knows how to count up beyond five, just not how to write it. On Mon, Aug 13, 2012 at 1:39 PM, SHOBHIT GUPTA wrote: > shouldn't be the sum i.e. 4 taken as 1 ? > > > On Mon, Aug 13, 2012 at 11:06 AM, vivek rungta wrote: > >

Re: [algogeeks] direct i online test

2012-08-13 Thread vivek rungta
if sum is 4 output will be 33 On Mon, Aug 13, 2012 at 10:29 AM, SHOBHIT GUPTA wrote: > what will be the output if the sum is 4 ? > > On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote: > >> A smart 3 year old Sandeep knows counting. But he doesn't know how to >> read and write properly. He has lear

Re: [algogeeks] is given number is lucky..?

2012-08-12 Thread vivek rungta
bool is_lucky(int x){ int pos=x; inr count=2; while(countwrote: > @daksh paaji kya baat hai thanks for the solution. aap har jagah hai :P > > > On Sat, Aug 4, 2012 at 12:21 AM, Daksh Talwar wrote: > >> maintain a bool array of size of limit of int >> store true for lucky numbers >> and then cross

Re: [algogeeks] Re: AMAZON: given col id, print col name in excel

2012-08-12 Thread vivek rungta
its base 26 but little modification in code ... @shiv - nice solution . char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n=(n/26)-1; } while(n) ; for(int i=n-1;i>=0;i--) cout< wrote: > No. It's not base 26 at all. Given input 26, your code will return ba, but > the result should be

Re: [algogeeks] Given an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space

2012-08-12 Thread vivek rungta
Solution for - all number appears two time except three number which appears 1 or 3 times. array indexing method is used to solve in O(n) time complexity and O(1). first find min - O(n) then in for loop 1 to n a[abs(a[i])-min]=-a[abs(a[i])-min]; then find the -ve number in array then answer will

Re: [algogeeks] direct i online test

2012-08-12 Thread vivek rungta
use simple recursive function to solve - int countfun(int sum ){ int i; int count; int total=0; if (sum==0) return 1; for(i=1;i<=3;i++){ if (sum-i<0) break; count=countfun(sum-i); if(i==1) count*=2; total+=count; } return total; } On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote: > A smart 3 ye