@amol this is not the behaviour of printf, its totally about the typecasting
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/GPVlt15S3V0J.
To post to this
@Piyush:.. nope is not correct ...
this is right
0 1 2 3
0 1 0 0 0
1 1 0 1 0
2 1 0 1 0
3 1 0 1 0
4 1 0 1 0
use this code to precompute..
A[i,j] = A[i-1, j];
if ( A[i, j] == 0 and j - W[i] =0)
A[i, j] = A[i -1, j - W[i]];
On Tue, Jan 10, 2012
@Ramakant : for which test case your code would fail??
On Tue, Jan 10, 2012 at 1:04 PM, Ramakant Sharma ramakant...@gmail.comwrote:
@atul:
no..my approach was wrongwe have to check recursively...as sravan said
--
You received this message because you are subscribed to the Google
It's painful to see printf being accused for the (un) expected
output..The declaration of printf means that any data type can be
passed to it as argument.Inherently what printf does is print the bytes in
meaningful form according to the first argument which is a string.So its
impossible for
@Ramakan:
for j=0 to col
arr[0][j]=0;
for i=0 to rows
arr[i][0]=0;
assuming that given matrix is surrounded by 0 i.e indexs (i,j) for arr[][]
will start from i=1 = row and j=1 = col.
i guess your approach will work.
--
You received this message because you are subscribed to the Google Groups
sry for last post:
the code bye sravan reddy would not work for negative nos.
but slight modification in if conditions make it work for negative nos too.
by the way nice algo suggested
#includestdio.h
int main(int argc, char **argv){
int a[] = {-2,-3,-4,-19,10};
//int
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
@priyanka..
I don't think it will work...
Say for ex- 1,-1,3,5,1,-3 ... the answer should be (3),(5,1,-3)..
Will the above fix give the correct answer for the given input ??
Also, i see a couple of flaws in the checks...
Say, Left right and p2 = len -1, then it will actually take A[len]
into
@correction..
1) Find the first pair (i,j) such that:
/*
sum( A[0] .. till A[i]) = sum(B[0] ... B[j])
*/
On Jan 10, 6:13 pm, Lucifer sourabhd2...@gmail.com wrote:
@priyanka..
I don't think it will work...
Say for ex- 1,-1,3,5,1,-3 ... the answer should be (3),(5,1,-3)..
Will the
i liked the solution given by the reference i have provided. The thought
process is similar to mazing problem given in horowitz sahani.
nice question, however, how can this be an interview question?
If you give this solution, the interviewer would understand that you knew
the problem and hence
@lucifier :
Please tell how you reduce SuperSum ( k, n) into
SuperSum(k,n) = SuperSum (k-1, n) * (n+k) / (k+1)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
@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
@SAMM
i want to achieve the digitization as shown in the video
http://www.youtube.com/watch?v=yCIeKc__LdM
kindly have a look
On Mon, Jan 9, 2012 at 12:40 AM, SAMM somnath.nit...@gmail.com wrote:
1 month back I wrote C++ code using Magick++ to zoom a image without
distorting the Pixels . In
@Lucifier : your reduced form is not generating right output...
remove modulo and calculate for SuperSum(2,3)
On Tue, Jan 10, 2012 at 6:12 PM, priyanka priyankajag...@gmail.com wrote:
@lucifier :
Please tell how you reduce SuperSum ( k, n) into
SuperSum(k,n) = SuperSum (k-1, n) * (n+k) /
@ Ramakant : yupwont work.
On Tue, Jan 10, 2012 at 7:28 PM, Ramakant Sharma ramakant...@gmail.comwrote:
@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
@atul
First of all, i must say you are really good at catching my editing
mistakes :)..
Correction:
superSum = ( superSum * ( ( n + i )%17 ) ) / (i+1);
On Jan 10, 8:29 pm, atul anand atul.87fri...@gmail.com wrote:
@Lucifier : your reduced form is not generating right output...
remove
@ Ashish : abt the solution given by reference.
well sometimes it depends , interviewer may take it +vely as he can see you
are keen to learn abt different algorithm dats why you knw it...
On Tue, Jan 10, 2012 at 7:28 PM, Ashish Goel ashg...@gmail.com wrote:
i liked the solution given by the
@Lucifier : hehehe...i dont accept solution blindly..may be dats why :D :D
yeah got your editing mistake after i posted it bcoz you where not using i
in the loop so same calculation were goin on.
On Tue, Jan 10, 2012 at 9:05 PM, Lucifer sourabhd2...@gmail.com wrote:
@atul
First of all, i
Suggest an algorithm guyzzz.
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286
*
--
You received this message because you are subscribed to the Google Groups
i dint get...you should provide more details , if it is all 1 then whole
matrix is a max square..
anyways equation to find max sub square is this.
M[i,j]=R[i,j]==0 ? 0 : 1+min(M[i-1][,j] , M[i][j-1], M[i-1][j-1] )
On Tue, Jan 10, 2012 at 10:00 PM, Sanjay Rajpal sanjay.raj...@live.inwrote:
Its a square matrix containing 0s and 1s.
Will u plz elaborate about this equation ?
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286
*
On Tue, Jan 10, 2012 at 8:36 AM,
@priyanka..
SuperSum(k, n) :
For any given base X representation there will be X digits..
Now say, the digits are named as A(i) ... such that,
A1 A2 A3 A(X)...
[ all digits being significant ]
Then SuperSum basically says that what are the no. of (k+1) sized
integers that can formed
@priyanka..
If you are looking for some problem where the same concept has been
applied, then go thru the following link...
http://groups.google.com/group/algogeeks/browse_thread/thread/0751e67f32266e53#
and look for the explanation and code that has been posted for the
following problem:
This is pretty funny because modern ECG machines generate digital
output. You might first look into whether you can get the digits
directly from the machine rather than scans of paper.
But suppose you can't. I assume you asking how to find numerical
coordinates for the curve by scanning and then
Guys,
You are making this way too hard. It's really a graph problem. The
nodes are the 1's and adjacent 1's are connected by undirected edges.
You must count components in the graph. So the algorithm is easy:
Find a component, erase it, repeat. Count components as you go.
What's an efficient
@gene
in that case ur erase() should even consider diagonal elements as well,
else there would be 2 islands in example
surender
On Wed, Jan 11, 2012 at 7:19 AM, Gene gene.ress...@gmail.com wrote:
Guys,
You are making this way too hard. It's really a graph problem. The
nodes are the 1's and
The 1's and 0's are in matrix R. We want to compute an integer matrix
M of the same dimensions as R such that Mij is the size of the largest
square of 1's of which Rij is the bottom right corner. As we go we
can keep track of max(Mij), and this will be the answer.
So how to compute Mij? The
g[][]- given matrix
r[][]- result matrix
copy first row n column from g[][] to r[][]
rest
for i=1 to n-1
for =1 to n-1j
if(g[][])
r[][]=min(r[i][j-1],r[i-1][j],r[i-1][j-1])+1;
else
r[][]=0;
On Wed, Jan 11, 2012 at 10:00 AM, Gene gene.ress...@gmail.com wrote:
The 1's and 0's
I think atul/Ramakanth's approach will work fine, if we include one more
condition
for each arr[i][j]
if(arr[i][j]==1)
{
if (arr[i-1][j]==0 arr[i][j-1]==0 arr[i-1][j-1]==0)
count++;
else if (arr[i-1][j]==1 arr[i][j-1]==1 arr[i-1][j-1]==0)
count--;
}
On Wed, Jan 11, 2012 at 8:10 AM, surender
@Umer : it has 1 island ashish made editing mistake before.
On Wed, Jan 11, 2012 at 11:58 AM, Umer Farooq the.um...@gmail.com wrote:
I still don't get how are they two islands. As long as I have understood,
diagonals abridge the two islands into one. In this case, these two islands
are
Given 2D array.
The rows are sorted in ascending order and the colums are sorted in
ascending order.
We have to sort the whole matrix in ascending array.
We cannot use extra space.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
sort the whole matrix in ascending array means?
can you please explain ?
On Wed, Jan 11, 2012 at 12:53 PM, atul anand atul.87fri...@gmail.comwrote:
Given 2D array.
The rows are sorted in ascending order and the colums are sorted in
ascending order.
We have to sort the whole matrix in
I guess sort the array such that elements are sorted finally in such a way
that if we print them row by row, the result is a sorted array.
K-way merge can be useful.
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra -
33 matches
Mail list logo