Order Pending Transactions by Account Sequence Number

Last updated: November 29, 2026

Quick Overview

An account's next expected sequence number is known, and a client has submitted a batch of signed transactions tagged with sequence numbers, possibly out of order, with duplicates, gaps, and stale entries. Return which transactions can apply now in order, which are blocked behind a gap, which are stale, and the first missing sequence.

Ripple
Coding & Algorithms
Software Engineer
Ripple
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


An account's next expected sequence number is known, and a client has submitted a batch of signed transactions tagged with sequence numbers, possibly out of order, with duplicates, gaps, and stale entries. Return which transactions can apply now in order, which are blocked behind a gap, which are stale, and the first missing sequence.

Sequence numbers are how the XRP Ledger prevents replay and orders an account's transactions, and a client or queueing service must reason about them constantly. This screen question checks hash map fluency and whether you ask the right clarifying questions about duplicates and stale entries before coding.

What the Interviewer Expects
  • Clarify what to do with duplicate sequence numbers and sequences below the current one
  • Use a dictionary keyed by sequence for O(1) lookups
  • Walk forward from the current sequence to find the applicable run
  • Report the first gap so the client knows what to resubmit
  • Keep the output deterministic (sorted blocked list)
Key Topics to Cover
Hash Map
Replay Protection
Ordering
Gap Detection
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would tickets, which let an account reserve sequence numbers out of order, change this?
  • If two different transactions share a sequence, how should a real server pick one?
  • How would you handle a transaction that fails with a fee-claimed result but still consumes its sequence?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs: current_seq (the next sequence the account expects) and a list of (seq, tx_id). Outputs: applicable (a consecutive run starting at current_seq), blocked (valid future sequences stuck...

High-Level Design

One pass to bucket the submissions: stale ones go straight to a list, the rest go into a dictionary keyed by sequence. Then walk s = current_seq, current_seq + 1, ... while s is in the dictionary,...


Submit Your Answer
Markdown supported

Related Questions