Won't this recurrence work: s[i] = max(s[i-2], s[i-2]+a[i], a[i-1]) work? I think it works.
On Tue, Jul 19, 2011 at 4:54 PM, oppilas . <jatka.oppimi...@gmail.com>wrote: > New constraint:- > What if the array also contains positive and negative numbers? > > On Tue, Jul 19, 2011 at 4:36 PM, sagar pareek <sagarpar...@gmail.com>wrote: > >> ok ok ok thank you all >> >> >> On Tue, Jul 19, 2011 at 4:35 PM, ankit sambyal <ankitsamb...@gmail.com>wrote: >> >>> @Sagar: 13 is the correct answer. (6+4+3) >>> >>> -- >>> 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. >>> >>> >> >> >> -- >> Regards >> SAGAR PAREEK >> COMPUTER SCIENCE AND ENGINEERING >> NIT ALLAHABAD >> >> -- >> 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. >> > > -- > 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. > -- 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.