Re: [algogeeks] Re: direct i ..ques

2011-07-27 Thread SkRiPt KiDdIe
C(n+1,2)^2 -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] DE Shaw - Data Structure Section Qn

2011-07-27 Thread SkRiPt KiDdIe
I think Ordered array Search time = O(logn) whereas for bucket complexity=O(sqrt(n)) as it is unordered. -- 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

Re: [algogeeks] Question

2011-07-27 Thread SkRiPt KiDdIe
use unsubscribe link at bottom of mail. -- 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 algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] puzzle

2011-07-27 Thread SkRiPt KiDdIe
(nxn) = 2^((n-1)^2) -- 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 algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] How to staore

2011-07-26 Thread SkRiPt KiDdIe
We can store their freq. as in run-length encoding, each dig freq. would require 1/2 byte storage .10 digits would require 5 bytes = 2 integer type variables or LL int .Digit seq. don't need to be stored coz they appear one after another beginning from 1. -- You received this message because you

Re: [algogeeks] problem tree minimum sum in binary

2011-07-26 Thread SkRiPt KiDdIe
for(i=sz-2;i=0;i--) for(j=0;j=i;j++) ar[i][j]+=min(ar[i+1][j],ar[i+1][j+1]); coutar[0][0]; is this fine.? -- 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

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff int mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re )continue;

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff ll mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re )continue;

Re: [algogeeks] Re: please help

2011-07-26 Thread SkRiPt KiDdIe
#includecmath #includecstdio #includeiostream #includestring using namespace std; #define ll long long int #define INF 0x7fff ll mask(ll x,string str,ll dist) { ll re=INF,y=0,len; len=str.size(); for(int i=0;ilen;i++) if( !(x(1LLi)) || str[(i+dist)%len]re

Re: [algogeeks] Re: Nagarro Coding Round Ques......

2011-07-26 Thread SkRiPt KiDdIe
I dint get wat are you speaking of.each alphabet is mapped onto ascii_val-'a' ie ascii of a=97. now check for odd and even occurence is performed. Work it on paper u'll get it. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Question

2011-07-25 Thread SkRiPt KiDdIe
How much time does he reach home is a bad question to ask. Say i walk 90-x minutes before i meet my driver.If i had walked x more minutes the driver would have reached my office. I save the driver's x minutes which he takes for onwards journey from the point of meet.Eventually i save 20 min

Re: [algogeeks] Question

2011-07-25 Thread SkRiPt KiDdIe
How much time does he reach home is a bad question to ask. Say i walk 90-x minutes before i meet my driver.If i had walked x more minutes the driver would have reached my office. I save the driver's x minutes which he takes for onwards journey from the point of meet.Eventually i save 20 min

Re: [algogeeks] Nagarro Coding Round Ques......

2011-07-25 Thread SkRiPt KiDdIe
str[i]-'a' th bit is toggled. -- 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 algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] Interleaving two strings using recursion

2011-07-24 Thread SkRiPt KiDdIe
Can u specify an Xample. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] Nagarro Coding Round Ques......

2011-07-24 Thread SkRiPt KiDdIe
#includestring using namespace std; int main() { int x=0; string str; cinstr;//only lowercase for(int i=0;istr.size();i++) x^=(1(str[i]-97)); if(str.size()1) { if(!(x(x-1)))coutPalindrome\n; else coutNot palindrome\n; } else {if(!x)coutPalindrome\n; else coutNot palindrome\n;

Re: [algogeeks] Nagarro Coding Round Ques......

2011-07-24 Thread SkRiPt KiDdIe
check power of 2. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread SkRiPt KiDdIe
Worst case 99 get released. Is that correct..? -- 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

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread SkRiPt KiDdIe
I smell something BONe - Y :P -- 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 algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] Unique characters in a string

2011-07-22 Thread SkRiPt KiDdIe
Use 8 mask integers or 4 LL to cover the complete ascii range. -- 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

Re: [algogeeks] Re: Microsoft Question!

2011-07-21 Thread SkRiPt KiDdIe
To get complete 32 bit inverse : x=((x1)0x) | ((x1)0x); x=((x2)0x) | ((x2)0x); x=((x4)0x0F0F0F0F) | ((x4)0xF0F0F0F0); x=((x8)0x00FF00FF) | ((x8)0xFF00FF00); x=((x16)0x) | ((x16)0x); -- You received this

Re: [algogeeks] Re: Microsoft Question!

2011-07-21 Thread SkRiPt KiDdIe
Solution assuming MSB the last digit x=((x1)0x) | ((x1)0x); x=((x2)0x) | ((x2)0x); x=((x4)0x0F0F0F0F) | ((x4)0xF0F0F0F0); x=((x8)0x00FF00FF) | ((x8)0xFF00FF00); x=((x16)0x) | ((x16)0x);

Re: [algogeeks] Coding..........

2011-07-21 Thread SkRiPt KiDdIe
Div n Conquer O(nlogn) Thanks -- 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 algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] TREES

2011-07-21 Thread SkRiPt KiDdIe
vectorint v[HMAX]; Fill(ar,0,n-1,0);//main() call void Fill(int ar[],int start,int end,int idx) { if(startend)return; v[idx].push_back(ar[start]); Fill(ar,start+1,(end+start)/2,idx+1); Fill(ar,(end+start)/2+1,end,idx+1); } ar[] is input array/ v contains

Re: [algogeeks] Re: Find valid anagrams

2011-07-20 Thread SkRiPt KiDdIe
Use trie for dictionary.Use permutaion to generate all anagrams and check finally. -- 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

Re: [algogeeks] Amazon

2011-07-19 Thread SkRiPt KiDdIe
I think equal is referred as congruent. -- 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 algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] Re: how to optimally compute a matrix (nXn) to the power of k?

2011-07-19 Thread SkRiPt KiDdIe
Lishabh nice xplanation bro :) -- 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 algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] Non-redundant permutations of the string

2011-07-19 Thread SkRiPt KiDdIe
#includeiostream #includestring using namespace std; void permute(string str,int x,string print) { int mask=0; if(!x){coutprintendl;return;} for(int i=0;ix;i++) { if(mask(1(str[i]-'a')))continue; if(i i+1x)

Re: [algogeeks] C function prob

2011-07-18 Thread SkRiPt KiDdIe
int generate() { x=bit(); y=bit(); if(x^y == 0) return generate(); return x; } -- 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

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread SkRiPt KiDdIe
Nishant. Your algorithm works for finding repeated nos. in a [n+2] array where [1-n] are present atleast once and the same number is not being repeated twice. Reanalyze the question. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread SkRiPt KiDdIe
@Nishant: 1 4 5 4 5n=5 1 2 3 4 5 after xor i.e. your x1 answer contains (2^3^1^1).The missing elements are included in xor as well along with repeating elements. Hope now you got it. You are giving solution for a question which i have defined in previous post. and your algo will fail when

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread SkRiPt KiDdIe
@Nishant: 1 4 5 4 5n=5 1 2 3 4 5 after xor i.e. your x1 answer contains (2^3^4^5).The missing elements are included in xor as well along with repeating elements. Hope now you got it. You are giving solution for a question which i have defined in previous post. and your algo will

Re: [algogeeks] MICROSOFT!!!!

2011-07-18 Thread SkRiPt KiDdIe
After 22nd plz post ur questions ... !! It wud be of great HelP. -- 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

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SkRiPt KiDdIe
Reading the input will cost n^2 -- 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 algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SkRiPt KiDdIe
nice 1 sunny :) On Mon, Jul 18, 2011 at 11:16 PM, sunny agrawal sunny816.i...@gmail.comwrote: oh common thats what have been discussed above :P On Mon, Jul 18, 2011 at 10:52 PM, sagar pareek sagarpar...@gmail.comwrote: oh common its a very tricky question take 6 variables min0,min1,min2

Re: [algogeeks] Fwd: MICROSOFT INTERNSHIP (Coding round)

2011-07-18 Thread SkRiPt KiDdIe
O(m+n) start at bottomleft corner. If target value is found value move right , if less move above else uve got the number. -- 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

Re: [algogeeks] Add Two Numbers stored in Linked Lists

2011-07-18 Thread SkRiPt KiDdIe
#includecstdlib #includeiostream using namespace std; struct node{ int val; node *next; }; node * Input(int n) { node *temp,*list,*end; int x; for(int i=0;in;i++) { cinx; temp=(node*)malloc(sizeof(node));temp-val=x;temp-next=NULL;

Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree

2011-07-16 Thread SkRiPt KiDdIe
A pre-order traversal which is used to index the (min,max) pair value at each level except the bottom-most level where all the entries are to be printed. O(n) time O(log n) memory. On 7/17/11, swetha rahul swetharahu...@gmail.com wrote: Sagar , Shubam Maheshwari

Re: [algogeeks] Re: Given a BST containing integers, and a value K. You have to find two nodes that give sum = K.

2011-07-16 Thread SkRiPt KiDdIe
Use O(2n) memory , list the in-order traversal of BST say A[0..n]. and K-A[0...n] say B . Now apply standard merge function(Merge sort) on A and B. keeping track of equal found elements during comparison to get the ans. On 7/17/11, sagar pareek sagarpar...@gmail.com wrote: You must take an

Re: [algogeeks] Counting the ways.

2011-07-15 Thread SkRiPt KiDdIe
O(n!) On Fri, Jul 15, 2011 at 12:17 PM, Sarvesh kumar.sarv...@gmail.com wrote: it is simple n*n ways. On Thu, Jul 14, 2011 at 11:36 PM, tendua 6fae1ce6347...@gmail.com wrote: We are given n by n boolean matrix ( n = 20). Output of matrix should be such that every row and every column

[algogeeks] X-AmazoN

2011-07-15 Thread SkRiPt KiDdIe
You are provided with a bit generator which generates 1 and 0 with equal probabilities i.e. (1/2). You are required to design a function which generates numbers form 1-1000 with equal probabilities i.e. (1/1000). -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] X-AmazoN

2011-07-15 Thread SkRiPt KiDdIe
If rand() generates equi-probable numbers within range [1 - n] and n is a multiple of 1000 then your above code will be correct. You should utilize the bit-generator function. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] X-AmazoN

2011-07-15 Thread SkRiPt KiDdIe
its correct. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] X-AmazoN

2011-07-15 Thread SkRiPt KiDdIe
nos [1001,1023] are neglected as if their probabilities are set to zero and recalculated.As nos [1,1000] are only considered and as they are generated with equal probabilities i.e. 1/1024. I feel the above solution to be correct. -- You received this message because you are subscribed to the

Re: [algogeeks] Counting the ways.

2011-07-14 Thread SkRiPt KiDdIe
Will a Back-tracking solution suffice..?? -- 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 algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] puzzle-plz explain stepwise

2011-07-13 Thread SkRiPt KiDdIe
initially he saw say xy then he saw yx now what next does he see...containing only x and y?? Please clarify your question.. On Thu, Jul 14, 2011 at 12:59 AM, udit sharma sharmaudit...@gmail.comwrote: Ans should be 45km/hr. :) -- Regards UDIT DU- MCA -- You received this

Re: [algogeeks] puzzle-plz explain stepwise

2011-07-13 Thread SkRiPt KiDdIe
Relation comes out as : y=6x so x=1 ans y=6. so 1st: 16 (say km) 2nd: 61 3rd: 106 av. speed=(106-16)/2=45 km/hr On Thu, Jul 14, 2011 at 1:13 AM, Siddharth kumar siddhartha.baran...@gmail.com wrote: 1st: xy 2nd: yx 3rd: x0y -- You received this message because you are subscribed to the

Re: [algogeeks] Re: Bit Twiddles

2011-07-11 Thread SkRiPt KiDdIe
are you saying that x finally contains the number of bits that are set to 1..?? On Tue, Jul 12, 2011 at 1:09 AM, Dave dave_and_da...@juno.com wrote: @rShetty: Ask a question. What do you need to know? Dave On Jul 11, 1:26 pm, rShetty rajeevr...@gmail.com wrote: Some more Explanation of

Re: [algogeeks] Re: Bit Twiddles

2011-07-11 Thread SkRiPt KiDdIe
...@juno.com wrote: @SkRiPt: Yes. Dave On Jul 11, 2:43 pm, SkRiPt KiDdIe anuragmsi...@gmail.com wrote: are you saying that x finally contains the number of bits that are set to 1..?? On Tue, Jul 12, 2011 at 1:09 AM, Dave dave_and_da...@juno.com wrote: @rShetty: Ask a question

Re: [algogeeks] Re: Bit Twiddles

2011-07-11 Thread SkRiPt KiDdIe
Got it :) On Tue, Jul 12, 2011 at 1:18 AM, Dave dave_and_da...@juno.com wrote: @SkRiPt: Yes. Dave On Jul 11, 2:43 pm, SkRiPt KiDdIe anuragmsi...@gmail.com wrote: are you saying that x finally contains the number of bits that are set to 1..?? On Tue, Jul 12, 2011 at 1:09 AM