Binary Search, Sorting & Number Conversions
- Write a binary search that finds the first and last copy of a target
- Convert integers to Roman numerals and back with one greedy table
- Write merge sort and quicksort from scratch and explain stability
- Solve the clock-angle and number-to-words problems from older loops
Some Rivian coding rounds wear a vehicle costume, like the EV routing problem in the previous lesson. Plenty of others don't. Entry-level and general software loops in 2026 still hand out a plain LeetCode problem, easy to medium, solved live with an engineer in about 45 to 60 minutes. This lesson covers the ones candidates named.
There are three from the last twelve months. An August 2026 entry-level candidate got a LeetCode question built on binary search. A February 2026 commenter warned an intern applicant to be ready for converting numbers to Roman numerals. And a January 2026 candidate said to be able to write a sorting algorithm from scratch, and to know how a compiler works and the basics of embedded systems. Two older ones follow, the angle between clock hands (2025) and integer to English words (2024).
Rivian LeetCode questions in general rounds
None of these five problems is hard on paper. What trips people is the edge of each one. Binary search fails on an off-by-one, the Roman table fails on 4 and 9, a hand-written sort fails on duplicates, the clock fails at midnight, and number to words fails on zero and on the gaps inside 1,000,010. The interviewer will try those inputs, so try them first.
Candidates in 2025 coded in HackerRank's live pad. In the February 2026 Roman numeral thread, a staff engineer couldn't get HackerRank running and moved the round to Google Docs, so be ready to write clean code with no run button. Where the pad does run tests, failing a few has cost candidates a level. Run your own small cases out loud before you say you're done.
Each problem here has one small idea under it. Binary search keeps a range where the answer must be and halves it. Roman numerals and English words are both a table walked from largest to smallest. Merge sort splits and merges, quicksort partitions. The clock angle is two rates and a subtraction.
Binary search on a sorted array
Binary search has two first-hand Rivian reports, one of them recent. An entry-level candidate in August 2026 said the assessment included "a LeetCode question on binary search." A 2023 intern described one array question solved with binary search, where the interviewers said a hash map "would have lead to a less optimal solution." Neither named the exact problem.
So practice the shape. The problem below is something like what they describe. There's a sorted array and a target, and a dictionary would find the answer in O(n) time while binary search needs O(log n). Finding the first and last copy of the target is a good drill, because it forces you to write the boundary version of binary search, which is the one people get wrong.
First and Last Position in a Sorted Array
Problem
search_range(nums, target). The list nums is sorted in ascending order and can repeat values. Return [first, last], the index of the first and the last copy of target.If
target isn't in the list, return [-1, -1]. Your solution should run in O(log n) time, so a linear scan or a dictionary built from the whole list doesn't count.The two 8s sit at index 3 and index 4.
Write one helper that returns the first index whose value is at least a given number. The first copy of target is that index for target, and the last copy sits one before the index for target + 1.
First and Last Position in a Sorted Array
Click "Run" to execute your code
Integer to Roman numerals
In a February 2026 thread about a Rivian MLOps internship, a commenter told the poster to be ready for "some string conversion to roman letters." The comment doesn't say which direction. Practice both: integer to Roman is the harder one to get right in an interview, and Roman to integer is the natural follow-up.
Integer to Roman
Problem
int_to_roman(num) that returns the Roman numeral for an integer from 1 to 3999.The symbols are I = 1, V = 5, X = 10, L = 50, C = 100, D = 500 and M = 1000. Numerals are written from largest to smallest, so 58 is LVIII. Six values use subtraction instead: 4 is IV, 9 is IX, 40 is XL, 90 is XC, 400 is CD and 900 is CM.
A symbol never repeats more than three times in a row. That's why 4 is IV and not IIII.
50 is L, 5 is V and 3 is III.
Put the six subtractive pairs into the symbol table, then walk the table from largest to smallest and take each value as many times as it fits.
Integer to Roman
Click "Run" to execute your code
Write a sorting algorithm from scratch
A January 2026 software engineer candidate summed up the prep in one line. You need a sorting algorithm you can write from scratch, they said, plus how a compiler works and the core ideas of embedded systems. They didn't say which algorithm. Merge sort and quicksort are the two to have ready, along with why you'd pick one over the other.
That loop leaned toward embedded work, where memory is tight. So expect a question on extra memory as well as on speed. Merge sort is stable and always O(n log n), but it needs an O(n) buffer. Quicksort sorts in place and is usually faster, but it's unstable and has an O(n²) worst case.
Sort an Array From Scratch
Problem
sort_array(nums) that returns the values of nums in ascending order. Don't call sorted, list.sort or any other library sort.The list can be empty, can hold negative numbers and can repeat values. Your sort should run in O(n log n) time.
A plain unsorted list.
Merge sort: sort each half recursively, then merge the two sorted halves by repeatedly taking the smaller front value. A list of zero or one value is already sorted.
Sort an Array From Scratch
Click "Run" to execute your code
Older problems (2024-2025)
These two have one first-hand report each, from 2025 and 2024. Treat them as the same difficulty band as the newer problems, and as practice for the number-conversion edge cases. Neither has shown up in a current report.
Angle between the clock hands (2025)
A Vancouver software engineer who got an offer in August 2025 described something like this: "On a 12-hour analog clock, given time as integers h and m, return the smaller angle between the hour and minute hands in degrees." The hour in that version ran from 0 to 23, and the edge cases named were midnight, noon and one minute to midnight. It wanted an O(1) answer.
Angle Between Clock Hands
Problem
clock_angle(hour, minutes). The time is given on a 24-hour clock, with hour from 0 to 23 and minutes from 0 to 59. Picture that time on an ordinary 12-hour analog clock face.Return the smaller of the two angles between the hour hand and the minute hand, in degrees. The hour hand moves smoothly, so at 3:30 it sits halfway between the 3 and the 4.
The minute hand is at 180 degrees and the hour hand at 105, so the gap is 75.
The minute hand moves 6 degrees a minute. The hour hand moves 30 degrees an hour plus 0.5 degrees a minute. Reduce the hour modulo 12, subtract the two positions and take the smaller of the gap and 360 minus the gap.
Angle Between Clock Hands
Click "Run" to execute your code
% 12 before anything else, and both 0 and 12 land on the top of the dial. The reported edge cases are midnight, noon and one minute to midnight, so run all three out loud. Also say why the hour hand needs the minutes term. At 3:30 it isn't on the 3, and leaving that out is the usual wrong answer.Integer to English words (2024)
A software developer intern in Canada in June 2024 described a question that took numbers and returned "their English versions," like 12 to twelve and 23 to twenty three. It's the same table idea as the Roman numerals problem, scaled up. You handle numbers below a thousand once, then reuse that for thousands, millions and billions.
Integer to English Words
Problem
number_to_words(num) that returns the English words for a whole number from 0 to 2,147,483,647.Capitalize every word and separate words with single spaces. Leave out "and" and hyphens, so 123 is "One Hundred Twenty Three" and 0 is "Zero".
A tens word followed by a ones word.
Write a helper for 0 to 999. Then split the number into groups of three digits from the right and add Thousand, Million or Billion after each group that isn't zero.
Integer to English Words
Click "Run" to execute your code
Common questions
Does Rivian ask LeetCode questions?
Yes, in most software loops. A typical round is one LeetCode easy or medium solved live with an engineer, and in 2026 candidates named binary search, integer to Roman and a sort from scratch. Panel rounds can also bend toward the team's domain, like the EV routing problem or bit manipulation for embedded roles.
Which of these should I practice first?
Binary search. It's the only one here with two first-hand Rivian reports, the newest from August 2026. Then the sort, because writing merge sort and quicksort from memory takes rehearsal. The Roman numeral and clock problems each take one short session once you know the trick.
What language should I use in the Rivian coding interview?
Language follows the role. Embedded and vehicle software loops lean on C and C++, data roles on Python and pandas, full-stack roles on JavaScript. One 2026 candidate wasn't told the language for some rounds ahead of time, so ask your recruiter. All five problems here have starters in six languages.
Key Takeaways
- ✓Binary search has two Rivian reports, newest August 2026. Write the lower-bound version and explain why it beats a hash map.
- ✓Roman numerals and English words are both a value table walked from largest to smallest. Put the special cases in the table.
- ✓For a sort from scratch, write merge sort, then explain quicksort and the trade-off between stability and extra memory.
Rivian interview guideKnow what Rivian asks before you walk in.
28 coding · 4 system design · 37 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.