@above person ur solution is O(n^3) in worst case !let's say the row[] and col[] arrays formed are
col[]=123 124 125 126 row[]=127 , 128, 129,126 every element of row[] traverses through n elements of the array col[] and and makes O(n) comparisons in the worst case . Thus , each traversal requires O(n^2) time , and there can be O(n^3) traversals , so , time taken will be O(n^3). However sorting one of these arrays ,makes the time complexity as O(n^2log n) On Jan 26, 3:03 pm, bittu <shashank7andr...@gmail.com> wrote: > As Navies it can be done in O(n^2) > > Make numbers by using every elements in the row in array row[]. > Similarly convert column elements into numbers and put them in array > col[]. Now compare both the arrays where the number matches print the > index of both row[] and col[] array... > > eg:- > 2, 3, 4 > 3, 4, 5 > 6, 5, 1 > > col[] contains 236, 345, and 451 and row[] contains 234, 345, and 651. > On Comparison both has 345 as common total with index (1,1) and is the > desired answer. > > use 2d matrix..makes it easy > > Time Complexity is at Most O(n^2) > > Thanks & Regards > Shashank Mani " Best Way to Escape From the Problem is to Solve It" -- 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 group at http://groups.google.com/group/algogeeks?hl=en.