6 kyu
Crossing the river and its tributaries
24 of 47rPersival
Description:
Description
The travelers decided to take a trip along the river, which has many tributaries. They plan to start their trip somewhere on the left bank and end up on the right bank. Since crossing the river and its tributaries isn't easy, they want to keep the number of crossings as low as possible. Before the trip, they checked the map and wrote down the order of the tributaries flowing into the river along the entire route.
Input
You're given a string containing only the uppercase characters L
, R
and B
, where:
L
represents a tributary on the left bank,R
represents a tributary on the right bank, andB
represents tributaries on both banks.
Constraints
0 <= path.length() <= 1000
Example
If the input string is LLBR
, the travelers need to cross the river and two right-side tributaries to finish on the right bank. The total number of crossings will be 3
.
Good luck!
Algorithms
Strings
Performance
Similar Kata:
Stats:
Created | Aug 7, 2022 |
Published | Aug 7, 2022 |
Warriors Trained | 336 |
Total Skips | 87 |
Total Code Submissions | 438 |
Total Times Completed | 47 |
C++ Completions | 24 |
Java Completions | 17 |
JavaScript Completions | 16 |
Total Stars | 10 |
% of votes with a positive feedback rating | 90% of 20 |
Total "Very Satisfied" Votes | 16 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 13 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |