FastPrepFastPrep
Problem Brief

Game Points Calculation

OA

Write a function: int solution(vector &points, string &tokens);

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 points and string tokens are of the same length N;
  • N is an integer within [1, 100];
  • each element of array points is an integer within the range [1, 1,000];
  • string tokens consists 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.
public googlePointsCalculation (int[] points, String tokens) {
  // write your code here
}
Input

points

[4, 0, 2, 2]

tokens

"TEET"

Output

9

Sign in to submit your solution.