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

 

Recursion-1 > countPairs
prev  |  next  |  chance

We'll say that a "pair" in a string is two instances of a char separated by a char. So "AxA" the A's make a pair. Pair's can overlap, so "AxAxA" contains 3 pairs -- 2 for A and 1 for x. Recursively compute the number of pairs in the given string.


countPairs("axa") → 1
countPairs("axax") → 2
countPairs("axbx") → 1

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

public 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: 363.0

Copyright Nick Parlante 2017 - privacy