Re: [algogeeks] MS Q

2012-01-10 Thread Ramakant Sharma
0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 -- 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] MS Q

2012-01-10 Thread Ramakant Sharma
@atul: 0 0 0 0 0 0 --0 1 0 0 1 0 count=2 0 1 1 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 --0 1 1 1 1 1 count=2 (will not change) but there is only one islandso it wouldnt work... am i right? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] MS Q

2012-01-09 Thread Ramakant Sharma
Scan the matrix row wise left to right for each arr[i][j] if(arr[i][j]==1) { if (!(arr[i-1][j]==1||arr[i][j-1]==1)) count++; } ///also chk for baundary values accordingly 1 1 0 0 1 1 0 0 0 0 1 1 i think it should work.. -- You received this message because you are subscribed to the

Re: [algogeeks] MS Q

2012-01-09 Thread Ramakant Sharma
@atul: no..my approach was wrongwe have to check recursively...as sravan said -- 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: i cannot solve this written test question

2011-11-13 Thread Ramakant Sharma
start from rightmost digit find:i th positionsuch that ele[i]!=9 find j th position i ele[j]!=0 decrement jth position element and increment i th position element. . . ex:ele=134 i=0,---no j found i=1,j=0 ==143 ele=23998 i=0,---no j found i=1,---ele[i]=9 i=2,---ele[i]=9 i=3,j=0 ==24997 ele 8000100

Re: [algogeeks] Re: Array Problem??

2011-11-09 Thread Ramakant Sharma
for second part maintain an array of c[n-1] elements initialized to 1. for given count in B[i] from i=o,start counting 1's in c. at that (count)==b[i]+1,assume at c[j] set c[j]=0 and a[i]=j; its O(n2) :-( -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: question

2011-09-22 Thread Ramakant Sharma
starting from right find first digit less then right most digit,if no any digit is less,then move to next right most and compair when found exchange those no, now sort the no.s up to that index of the given no which is exchanged: Ex: 43987723893239876 first required sequence:

Re: [algogeeks] Re: microsoft interview

2011-09-11 Thread Ramakant Sharma
for(i=0;im;i++) for(j=0;jn;j++) { if(arr[i][j]==1) for(k=0;kn;k++) arr[i][k]+=1; } for(i=0;in;i++) for(j=0;jm;j++) { if(arr[j][i]==2) for(k=0;km;k++) arr[k][i]=1; } -- You received this message because you are subscribed to the Google Groups