id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

norm.krumpe@muohio.edu > countPairs
prev  |  next  |  chance

Return a count of the number of characters in the string that are followed immediately by the same character. For example, countMatches("abbacccdd") should return 4 because the first b is followed by a b, the first c is followed by a c, the second c is followed by a c, and the first d is followed by a d.


countPairs("abbacccdd") → 4
countPairs("abab") → 0
countPairs("xxx") → 2

...Save, Compile, Run (ctrl-enter)

int countPairs(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy