keep two var row0 and col0 for checking if there is any 0 in row0flag /col0flag
now walk over elements from 1,1 to n,m and set corresponding entry in 0th row /column if you hit a zero. now walk over zeroth column and rwo and set the complete row/col if a 0 is there in 0th row/col. after this based on row0flag/col0flag, set oth col/row values to 0. Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Mon, Oct 3, 2011 at 12:08 PM, rahul sharma <[email protected]>wrote: > yeah it is wrong......i have a solution but uses 0(n+m) space.....i need it > in 0(n*m) tymand o(1) space > > > On Mon, Oct 3, 2011 at 11:55 AM, shady <[email protected]> wrote: > >> search archives :-/ >> >> >> On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal < >> [email protected]> wrote: >> >>> @rahul sharma, i ran this code, it is producing wrong answer :| >>> >>> check it, http://codepad.org/THv1hJq1 >>> >>> anyone with correct solution? >>> >>> -- >>> 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/-/26XU3UBqZ6EJ. >>> >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
