Problem Brief
Game Points Calculation
OA
Write a function:
int solution(vector
that, given an array of integers points and a string tokens, both of length N, returns the total number of points in the game.
Assume that:
- array
pointsand stringtokensare of the same lengthN; Nis an integer within[1, 100];- each element of array
pointsis an integer within the range[1, 1,000]; - string
tokensconsists only of the characters'E'and/or'T'.
Big props to Aura Man!
1Example 1
Input
points = [4, 0, 2, 2], tokens = "TEET"
Output
9
Explanation
Cells 0, 3 and 4 contain tokens. The value of points in these cells is 8. Also, there is one pair of adjacent cells with tokens, which gives 1 extra point. The function should return 9.
2Example 2
Input
points = [3, 2, 1, 2, 2], tokens = "TTTE"
Output
10
Explanation
Cells 0, 1 and 2 contain tokens. The value of points in these cells is 8. Also, there are two pairs of adjacent cells with tokens, which results in 2 extra points. The function should return 10.
3Example 3
Input
points = [2, 2, 2, 2], tokens = "TTTT"
Output
11
Explanation
All cells contain tokens. The function should return 11.