index = 0 1 2 3 4 5 6 ar = 0 1 2 -4 -3 6 -3 sumar = 0 1 3 -1 -4 2 -1
first index where we get the number which has already appeared in sumar will be the last index of sub array whose sum will be zero and (index of first apperance of this number + 1) in sumar will be the start index. so start index = 3 + 1 = 4; last index = 6; By set or treeMap we can solve it in O(nlogn) and by hashMap we can solve it in O(n). -- 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.