FastPrepParse a Numeric Toll-Log Timestamp
Problems/Parse a Numeric Toll-Log Timestamp

Parse a Numeric Toll-Log Timestamp

OnePay logoOnePay● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The numeric timestamp repair and two LogEntry tests follow the source at about 95%; the supplied class is already repaired. This finite wrapper exposes its binary32 getter value through double.

A toll-booth log line has four space-separated fields: timestamp licensePlate booth boothType. The timestamp is the number of seconds since the logging software started.

The timestamp is stored as a numeric float rather than as text: the LogEntry constructor parses it with Float.parseFloat, and getTimestamp is a numeric method.

For this exercise, implement a finite getTimestamp(logLine) wrapper: parse the first field as an IEEE 754 single-precision (binary32) numeric value, then return that same value through a double-precision return type. The other three fields do not affect the timestamp.

For this exercise, assume round-to-nearest with ties to even. The returned value reflects single-precision rounding, rather than preserving the exact decimal text. No repository editing or file I/O is required.

Function

getTimestamp(logLine: String) → double

Examples

Example 1

logLine = "44776.619 KTB918 310E MAINROAD"return = 44776.6171875

This test parses 44776.619 as a Java float. Its binary32 numeric value is 44776.6171875, which is returned exactly as a double.

Example 2

logLine = "52160.132 ABC123 400W ENTRY"return = 52160.1328125

This test parses 52160.132 as a Java float, whose value is 52160.1328125.

Example 3

logLine = "0.125 A0 10E EXIT"return = 0.125

One eighth is exactly representable in binary32.

Constraints

  • For this exercise, assume a valid line with exactly four nonempty fields separated by single ASCII spaces, without leading or trailing spaces.
  • The timestamp token is a nonnegative decimal from 0 through 100000, with 1 through 6 integer digits and optionally 1 through 3 fractional digits. Leading zeros are allowed; signs, exponent notation, NaN and infinity are excluded.
  • For this exercise, assume the complete line has at most 100 characters and the other fields are valid toll-log tokens.

More OnePay Phone Screen questions

  • Device Registry OperationsPHONE SCREEN · Seen Sep 2026
  • Count Complete Toll JourneysPHONE SCREEN · Seen Jul 2026
  • Per-Segment SpeedingPHONE SCREEN · Seen Jul 2026
  • Toll Journey FaresPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN
  • Roman to IntegerKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Minimum Difference Between Two Clock TimesMicron Technology · PHONE SCREEN
  • Decimal Digits in OrderZoomInfo · PHONE SCREEN
  • Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
  • Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
  • Integer to String Without Built-insHudson River Trading · PHONE SCREENHudson River Trading interview questions
All OnePay interview questionsSee OnePay hiring insights
Saved
class Solution {
    public double getTimestamp(String logLine) {
        // Write your code here.
        return 0.0;
    }
}
Checking account…