Reported September 2026
LinkedInstring

Restricted Decimal Number Validator

Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live LinkedIn OA. Under 2s to a working solution.
Founder's read

The LinkedIn OA reported in September 2026 looks like a freebie, and that's the trap. It's a Restricted Decimal Number Validator: take a string, return true only if it fits a tiny grammar. Optional leading minus, digits, optional single decimal point with digits on both sides. Most people write it in five minutes and then fail hidden tests on inputs like "-", ".5", "5.", or the empty string. The pattern is plain string parsing, no cleverness needed. If your head goes blank mid-assessment, StealthCoder is the safety net running invisibly on your screen while you finish the clean version.

The problem

You are given a string toTest. Return true exactly when it represents a number in the restricted decimal grammar below.
An optional minus sign - may appear only as the first character.
At least one ASCII digit must follow the optional sign.
An optional decimal point. may appear at most once, and it must have at least one digit on each side.
No other characters, whitespace, exponent notation, or leading plus sign are accepted.
Leading zeros are allowed.

Function
isNumber(toTest: String) → boolean

Examples
Example 1
toTest = "234"
return = true
Every character is an ASCII digit.
Example 2
toTest = "-455"
return = true
A single leading minus sign is allowed.
Example 3
toTest = "1e2"
return = false
Exponent notation is outside the accepted decimal grammar.
Example 4
toTest = "12^2"
return = false
The caret is not a digit or the optional decimal point.
Example 5
toTest = "23.23"
return = true
There are digits on both sides of the only decimal point.
Example 6
toTest = "2.2.4"
return = false
A valid representation may contain at most one decimal point.

Constraints
0 ≤ toTest.length ≤ 100000
toTest consists of printable ASCII characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to stop thinking in regex and walk the string once with an index. Skip one leading '-' if present. Then scan the rest, counting digits before the dot, tracking whether you've seen a dot, and counting digits after it. Any character that isn't a digit or the first dot returns false. At the end, require at least one digit before the dot, and if a dot was seen, at least one digit after it. The pitfalls are all edge cases: empty string, a lone "-", "-.5", "5.", "--5", and whitespace. Length can hit 100000, so avoid anything recursive and don't build substrings in a loop. Use ASCII comparison, not a locale-aware isDigit that accepts Unicode digits. If you freeze on the boundary checks during the live OA, StealthCoder can hand you the clean single-pass version as a hedge.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Restricted Decimal Number Validator cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as valid number. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass LinkedIn's OA.

LinkedIn reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Restricted Decimal Number Validator FAQ

How hard is the LinkedIn Restricted Decimal Number Validator really?+

Easy on algorithm, annoying on edge cases. It's one linear pass. The fails come from inputs like an empty string, a lone minus sign, a leading or trailing dot, and double dots. Test those by hand before you submit.

What's the trick to this problem?+

Treat it as a tiny state machine. Optional sign, digits, optional dot, digits. Track digit counts before and after the dot. Require at least one digit on each side of the dot, and at least one digit overall.

Should I use a regex?+

You can, something like ^-?\d+(\.\d+)?$ works in principle. But \d may match non-ASCII digits in some languages, so use [0-9]. A manual loop is safer, faster to reason about, and avoids regex quirks on 100000 characters.

Which edge cases will the hidden tests hit?+

Expect empty string, "-", "-.5", ".5", "5.", "1.2.3", "--1", "+1", "1e2", strings with spaces, and long all-digit strings. Leading zeros like "007" and "-0.50" should return true.

How do I prepare in 48 hours for this kind of OA?+

Write this validator from scratch twice without a regex, then do a few similar string parsing problems. Focus on boundary checks and off-by-one handling. Practice listing edge cases before coding, since that's where the points are lost.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with LinkedIn.

OA at LinkedIn?
Invisible during screen share
Get it