about | help | code help+videos | done | prefs |
Write a method that returns the number of pairs of characters that match coming in from the front and end of the string. This is like counting how much of a palindrome you have from the start and end of the string. A palindrome is a series of characters that is the same forwards and backwards, such as "racecar" or "bob". You are ONLY counting pairs that match from each end of the string. For example, "ABCXJKLLKJCBA" only has THREE pairs that match. Coming in from both ends, once you find a pair that does not match, you stop counting. A single character does not count, such as "X". It has to be paired with another character in a different position. This problem can be solved with or without recursion. Look at the test data for examples. test2024_04_16_APP1SLHL_countPairs("") → 0 test2024_04_16_APP1SLHL_countPairs("J") → 0 test2024_04_16_APP1SLHL_countPairs("JJ") → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 210
Copyright Nick Parlante 2017 - privacy