Vladimir Reshetnikov <v.reshetni...@gmail.com> writes: > Please help me to write the following algorithm: > Call a sequence of integers a zig-zag sequence if the differences between > successive numbers strictly alternate between positive and negative (for > example, > 5, 7,3,9,-1,4,3,6,0). The first difference may be either positive or > negative. Given a sequence of integers and a constant integer M, return a > zig-zag > subsequence with the maximal sum of absolute values of its differences, such > that an absolute value of each difference is greater or equal to M. > > Thanks > Vladimir > > Try dynamic programming. Complexity of the algorithm would be O(n^3).
-Raghav Kumar Gautam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---