Median of Parsed Integer Strings
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Rippling OA, reported in November 2025, is sorting the strings instead of the numbers. "10" lands before "2" and your median comes out wrong. The task is simple on paper: parse every string to an integer, find the median, return a double. Then the follow-up asks you to do it from a frequency dictionary. That's the real test. If you blank on the counting approach during the live assessment, StealthCoder runs invisibly as a safety net and gives you the solution while you keep control of the screen.
The problem
You are given a nonempty array values of canonical base-10 signed integer strings. Parse every string and return the median of the resulting multiset as a double. Duplicates are retained. If the number of values is odd, the median is the middle value after sorting. If it is even, the median is the arithmetic mean of the two middle values. Dictionary follow-up After solving the direct list version, explain or implement how the same result can be computed from a frequency dictionary whose keys are parsed integers and whose values are their multiplicities. Median positions must be located by visiting dictionary keys in increasing numeric order. Function parsedMedian(values: String[]) → double Examples Example 1 values = ["10","2","7"] return = 7.0 Parsing and sorting gives [2, 7, 10]. The single middle value is 7. Example 2 values = ["-5","20","3","8"] return = 5.5 The sorted values are [-5, 3, 8, 20]. The two middle values are 3 and 8, so the median is (3 + 8) / 2 = 5.5. Example 3 values = ["4","4","4","9","12","12"] return = 6.5 Duplicates remain in the multiset. The middle positions contain 4 and 9, whose arithmetic mean is 6.5. Constraints 1 <= values.length <= 2 * 10^5. Every values[i] is the canonical base-10 representation of an integer in [-10^4, 10^4]. Zero is written as "0"; nonzero values have no leading zeros, and positive values have no leading plus sign.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Parse each string to an int first. Then pick one of two routes. Route one: sort the ints and read the middle one or two. That's O(n log n) and fine for 2 * 10^5. Route two is the follow-up: values live in [-10^4, 10^4], so build a frequency map, or a count array offset by 10^4, and walk keys in increasing numeric order. Track the running count until you hit the target positions. For even n you need positions n/2 - 1 and n/2 (zero-indexed), and they can land in the same key when duplicates pile up. Pitfalls: lexicographic sort of strings, integer division when averaging (use 2.0 or cast to double), and iterating hash keys in insertion order. Sort the keys or use the offset array. If the walk logic tangles under pressure, StealthCoder is the hedge during the live OA.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Median of Parsed Integer Strings 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Median of Parsed Integer Strings FAQ
How hard is the Rippling parsed median problem really?+
Easy on the core. Parse, sort, take the middle. The follow-up with the frequency dictionary is where people slip, because you must walk keys in numeric order and handle the two middle positions landing on the same key. Expect it to be quick if you've done counting-style medians.
What's the trick to the frequency dictionary version?+
Sort the distinct keys numerically, then accumulate counts until the running total passes the target index. For odd n you need one position. For even n you need two, and both may sit inside one key's multiplicity. Track the first value found, then keep walking if needed.
Why does sorting the raw strings fail?+
String sort is lexicographic, so "10" comes before "2" and "-5" sorts oddly against positives. You must convert every string to an integer before sorting or counting. Do the parse step first and never compare the strings directly.
Can I skip the sort given the constraints?+
Yes. Values fall in [-10^4, 10^4], so a count array of size 20001 with an offset of 10^4 works. You get O(n + range) time and the keys are already in numeric order. That's the cleanest answer to the dictionary follow-up.
How do I prepare in 48 hours for this one?+
Write the sort version, then the count-array version, and test the three given examples plus a single-element case and an all-duplicates case. Check the even-length average returns a double, like 5.5, not a truncated integer. That covers nearly every failure mode.