Sum Integer Strings
Updated
Problem statement
Return the sum of the tokens that are complete signed decimal integers. An integer token contains an optional leading + or - followed by at least one ASCII digit. Ignore every other token. Do not trim whitespace. Leading zeros are allowed. An empty token list has sum zero.
Function
sumIntegerStrings(tokens: String[]) → longExamples
Example 1
tokens = ["12","x","-5","+3"]return = 10The three complete integer tokens sum to 10.
Example 2
tokens = [" 7","2.5","","+","04"]return = 4Whitespace, decimals, empty text, and a lone sign are ignored.
Constraints
- For this exercise, assume tokens.length <= 200000, each token has at most 11 characters, and every valid integer token has magnitude at most 10^9.
- Return a signed 64-bit sum.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Is This Date a Weekend?Salesforce · OASalesforce interview questions
- Triple-Position Alphabet EncodingArm · OA
- Closest ColorTwo Sigma · OATwo Sigma interview questions
- Prime Number From a StringAdobe · OAAdobe interview questions
- Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions
- Count Times Using at Most Two DigitsLSEG · OALSEG interview questions
- Valid String CheckUber · OAUber interview questions