| about | help | code help+videos | done | prefs |
Given a string of a's and b's "abbaabababaaaaaababababbba" return the length of the longest sequence of consecutive letters that has equal counts of a and b. This should be done in O(n) time, use a hashMap to help you keep track of things. The hint: treat a as -1 and b as +1, how do you know if a sequence has a balanced section? longestBalanced("a") → 0 longestBalanced("") → 0 longestBalanced("abab") → 4 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy