Xai

Xai Software Engineer Onsite Coding Questions

19+ questions from real Xai Software Engineer Onsite Coding rounds, reported by candidates who interviewed there.

19
Questions
7
Topic Areas
10+
Sources

What does the Xai Onsite Coding round test?

The Xai onsite coding round is the core technical evaluation. Software Engineer candidates typically see 2-3 algorithm and data structure problems. Problems range from medium to hard difficulty, and interviewers evaluate both correctness and code quality.

Top Topics in This Round

Xai Software Engineer Onsite Coding Questions

## Problem Design a durable (persistent) cache that survives process restarts, combining in-memory speed with disk-backed durability. ## Likely LeetCode equivalent No confident LC match. ## Tags hash_table, design, xai, cache

## Problem Build a `DynamicBatcher` that collects incoming requests and flushes them as a batch either when the batch reaches `max_size` items or after `max_wait_ms` milliseconds since the first request in the batch arrived — whichever comes first. ```python class DynamicBatcher: def __init__(self, max_size: int, max_wait_ms: int, process_batch: Callable[[list], list]): ... def submit(self, request: dict) -> Future: """ Returns a Future that resolves when the batch containing this request has been processed. """ ``` **Example behavior:** ``` batcher = DynamicBatcher(max_size=10, max_wait_ms=50, process_batch=db_bulk_insert) f1 = batcher.submit({"id": 1, "data": "..."}) f2 = batcher.submit({"id": 2, "data": "..."}) # If 8 more arrive within 50ms -> all 10 flushed together # If timeout hits first -> flush whatever is pending ``` ## Follow-ups 1. How do you associate each request's Future with its position in the batch result list? 2. What threading model do you use — a background flusher thread, asyncio, or something else? 3. How do you handle partial batch failures where some items succeed and others fail? 4. If the process_batch function is slow and requests pile up, how do you add backpressure?

## Problem Design a real-time audio broadcasting system (similar to Twitter Spaces) handling large concurrent audiences. ## Likely LeetCode equivalent No LC equivalent; system design question. ## Tags system_design, xai, real_time, audio

## Problem: Implement Two Distributed Matrix Multiplication Strategies (DP and FSDP) Using a Communication Simulator You need to implement distributed matrix multiplication **C = A @ B** in a simulat

## Problem: Design a Restorable (Checkpointable) Iterator Design an iterator wrapper `RestorableIterator` that wraps an existing iterator (or an array/list). In addition to normal iteration via `next

## Token Limiter (Rate limiting / quota) Implement a **Token Limiter** component that limits token (quota) consumption for a subject (e.g., userId / apiKey / tenant) under a given rule set. > Note:

## Problem: Unflatten a Nested Template Structure Given a flat list of integers and a nested template structure, refill the template’s leaf integer positions in order to produce a new object with the

## Problem: Flatten a Nested Structure When working with hierarchical data, you may need to convert a nested structure into a flat list. ### Input Given a nested Python-like data structure `structur

Conduct research and machine learning coding

Find the kth largest element in a data stream. Implement stream processing to handle the kth largest element in each time window of a large data stream. Use a queue to manage the time window and bucke

Handwrite a parallelized sort algorithm. ### Sample Input ``` 32 12 45 78 23 56 2 98 65 ``` ### Sample Output ``` 2 12 23 32 45 56 65 78 98 ``` ### Test Cases **Case 1** Input: ``` 32 12 45 78 23

Design a rate limiter to control request flow. Limit the frequency of requests within a given time window. ### Sample Input ``` max_requests=10\ntime_window=60 ``` ### Sample Output ``` true\ntrue\n

Design a key-value store system. It should support basic add, delete, and find operations while considering performance. ### Sample Input ``` add key1 value1\nfind key1\ndelete key1\nfind key1\n ```

Given an integer array, sort it. You are required to use multithreading to complete the sorting. ### Sample Input ``` 8 4 10 3 6 9 ``` ### Sample Output ``` 3 4 6 8 9 10 ``` ### Test Cases **Case

Given a list of integers that represent the capacity of rice bags, design an algorithm to determine how to select bags such that their total capacity exceeds a given target. Output the sequence of sel

You need to build a Twitter Insight platform that extracts data from the Twitter API and provides insights. The task includes the following features: 1. Implement a feature that retrieves tweets rela

Given a document string and a list of integers nlist, for each n in nlist, compute the most frequent n-gram in the document. Implement a function `find_most_common_ngrams(doc: str, nlist: List[int])

## Problem Given the root of a binary tree, a node is "bad" if its value does not lie within the range `[min_val, max_val]` inherited from its ancestors (similar to BST validity). Remove all bad nodes and their subtrees. Return the modified root. ```python class TreeNode: def __init__(self, val=0, left=None, right=None): ... def remove_bad_nodes( root: TreeNode, min_val: int = float('-inf'), max_val: int = float('inf') ) -> TreeNode | None: pass ``` **Example:** ``` Tree: 5 / \ 1 8 / \ 0 3 Range enforced: left child must be < parent, right child must be > parent Node 8 is bad if 8 > 5 is allowed, but 0 < 1 left of 5... walk through your definition. Output: cleaned tree with only valid-range nodes remaining. ``` ## Follow-ups 1. How does the valid range narrow as you traverse left vs. right? 2. What is the time complexity? Can you do this iteratively? 3. If a bad node has valid children, should the children be re-attached? Why or why not? 4. How would you extend this to an N-ary tree where each child has a specific position constraint?

Implement an in-memory database task with multiple levels of features. The database supports records identified by string keys, each containing multiple string field-value pairs. ### Level 1 - Basic

What to Expect in the Xai Onsite Coding Round

The Xai Software Engineer Onsite Coding round has a specific calibration purpose distinct from other rounds in the loop. Across 19+ verified reports on LeakCode for this exact round type, the consistent expectations: clear scoping of the problem before diving into a solution, explicit reasoning about complexity, structured handling of edge cases, and the ability to discuss trade-offs between two reasonable approaches.

Reports tagged with the Onsite Coding round at Xai show recurring patterns in difficulty and topic distribution. The Onsite Coding round is typically 45-60 minutes; the interviewer is calibrated against a specific rubric. The discriminator between candidates who advance and candidates who do not is rarely the final correctness of the answer. It is the path: did you clarify, did you verbalize your approach, did you handle edge cases, and did you communicate throughout.

How To Prepare for This Specific Round

Filter the questions below to the most recent reports (past 6-12 months). Questions tagged for this exact round type from this exact company at this exact role level are the highest-signal data available. Older reports may reference questions that have since rotated out of the company's pool.

Practice 4-6 representative problems from this set under timed conditions. The goal is not memorization (companies rotate questions); the goal is to internalize the patterns the interviewer typically reaches for and the depth of follow-up to expect. Reports on LeakCode also tag the typical follow-up depth at this round type, which is the discriminating signal between hire and no-hire calibration.

Onsite Coding Round Timing and Format

The Onsite Coding round at Xai typically runs 45-60 minutes. Use the first 2-3 minutes to clarify requirements; you should never start coding or designing without verifying the input/output format, constraints, and edge cases out loud. Use the next 5-7 minutes to verbalize your approach before writing any code. The middle 20-30 minutes are implementation. Reserve the final 10 minutes for testing with concrete examples and discussing optimization or trade-offs.

Time budget discipline is one of the most reliable senior-vs-junior discriminators in this round. Strong candidates verbalize where they are in their budget out loud ("I've used about 20 minutes, I have 15 minutes left for testing and one optimization"). This signals engineering maturity to the interviewer and creates positive feedback they can capture in writing.

Common Failure Modes in This Round

Reports tagged "no hire" at Xai Software Engineer Onsite Coding commonly cite: coding silently without verbalizing approach, jumping to implementation before clarifying requirements, missing edge cases (empty input, single element, very large input), producing working code that the candidate cannot refactor when asked, and failing to test their solution with concrete examples before declaring done.

The single most predictive failure mode in 2025-2026 reports: not asking clarifying questions. Interviewers at all FAANG companies are explicitly trained to weight this dimension. Strong candidates ask 3-5 clarifying questions even on problems that look obvious; weak candidates dive into code immediately. The clarifying-question check is often the first signal recorded in the interviewer's notes.

See All 19 Questions from This Round

Full question text, answer context, and frequency data for subscribers.

Get Access