FriendFinder
Beginner SRM 2 · 2021-01-13 · by erinn
Problem Statement
You and your friend are waiting in a line. A description of the line is given in the
How far apart are you and your friend in this line?
Constraints
- line will have between 2 and 50 characters, inclusive.
- Each character of line will be '.', 'S', or 'F'.
- 'S' and 'F' will each appear exactly once in line.
"....SF..." Returns: 1
You and your friend are adjacent in this line, thus you are one position away from each other.
"S........F" Returns: 9
You and your friend are at completely opposite ends of this line.
"..F...S.." Returns: 4
You and your friend may appear in either order.
"S........................................F" Returns: 41
".................................FS" Returns: 1
Submissions are judged against all 11 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FriendFinder with a public method int distance(string line) · 11 test cases · 2 s / 256 MB per case