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
@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
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
@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
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
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
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:
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