Sum Tokens with Error Count

JavaScript Medium 3 views
Back to Questions

Problem Description

One line has space separated tokens. Add only tokens that are valid finite numbers. Count bad tokens (NaN/Infinity/non-number). Print: sum badCount.

Input Format

One line tokens.

Output Format

One line: sum badCount.

Sample Test Case

Input:
10 2 abc -1 NaN 5
Output:
16 2

Constraints

Total characters up to 2e5.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next