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!
Examples
01 · Example 1
points = [4, 0, 2, 2] tokens = "TEET" return = 9
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.
02 · Example 2
points = [3, 2, 1, 2, 2] tokens = "TTTE" return = 10
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.
03 · Example 3
points = [2, 2, 2, 2] tokens = "TTTT" return = 11
All cells contain tokens. The function should return 11.
More Google problems
- Periodic Table Word FormationsPHONE SCREEN · Seen Jun 2026
- Fountain SafetyONSITE INTERVIEW · Seen Jun 2026
- Consolidate On-Call RotationsOA · Seen Jun 2026
- Detonate Bombs with Chain ReactionsONSITE INTERVIEW · Seen May 2026
- Evaluate a Nested Math ExpressionONSITE INTERVIEW · Seen May 2026
- Tic-Tac-Toe Game StatusPHONE SCREEN · Seen May 2026
- Longest Dictionary TokenizationPHONE SCREEN · Seen May 2026
- Minimum Cars for Rental RequestsONSITE INTERVIEW · Seen Apr 2026
public googlePointsCalculation (int[] points, String tokens) {
// write your code here
}
points[4, 0, 2, 2]
tokens"TEET"
expected9
sign in to submit