add LongestAlternatingSequence java implementation