You are given a string array
events.Initially,
score = 0andcounter = 0. Each element ineventsis one of the following:
"0","1","2","3","4","6": Add that value to the total score."W": Increase the counter by 1. No score is added."WD": Add 1 to the total score."NB": Add 1 to the total score.Process the array from left to right. Stop processing when either:
- All elements in
eventshave been processed, or- The counter becomes 10.
Return an integer array
[score, counter], where:
scoreis the final total score.counteris the final counter value.
1 | class Solution { |