← Microsoft Interview Insights

Microsoft·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Two coding problems for a Microsoft SWE round, both required. The CSV one was more involved than I expected, and the DNA fragment problem had a few follow-ups that pushed into graph territory. Not a lot of behavioral stuff, just straight implementation.

Questions Asked (4)

Q1

Build an in-memory table initialized from a CSV string. You have to write the CSV parser yourself, supporting quoted fields, embedded commas, escaped quotes, and newlines inside quotes. Then expose a query API with column projection and a predicate function per row.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The parser part is what trips people up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and edge cases, then design a state-machine-based CSV parser that handles quoted fields, embedded commas, escaped quotes, and newlines inside quotes. After parsing, implement a Table class with projection and predicate filtering, discussing trade-offs like memory usage and API design.

Pro tip: Demonstrate production awareness by discussing how you'd handle malformed CSV input gracefully and how the design would extend to streaming or larger datasets, showing you think beyond the immediate problem.

1. Clarify requirements and edge cases

Ask about CSV format specifics (e.g., delimiter, quote character, escaping rules) and expected behaviors for malformed input. Confirm the query API expectations: projection returns new table or view? Predicate applied per row?

2. Design the CSV parser

Outline a state machine that tracks whether you're inside quotes, handling escaped quotes by doubling. Explain how to accumulate characters and split rows/fields correctly, including newlines within quotes.

3. Implement the in-memory table

Store parsed data as a list of rows (each row a list of strings) and column headers. Consider using a simple class with methods for projection and filtering.

4. Implement query API

For projection, create a new table with selected columns. For predicate, iterate rows, apply the predicate function, and return matching rows (possibly as a new table). Discuss whether to return views or copies.

5. Discuss trade-offs and extensions

Talk about time/space complexity, memory efficiency, and how the design could be extended to support streaming, indexing, or more complex queries. Mention testing strategies for edge cases.

Key Points to Mention

  • State machine for parsing quoted fields and escaped quotes
  • Handling newlines inside quoted fields
  • Memory considerations: storing all data in memory vs. streaming
  • API design: projection and predicate as pure functions, returning new tables or views
  • Error handling for malformed CSV (e.g., unclosed quotes)
  • Testing edge cases: empty fields, quoted commas, escaped quotes, multiline fields

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given a list of fragments each with start, end, and payload fields, where the end of one fragment connects to the start of another, reconstruct the chain and return the payloads concatenated in order.

Algorithms & Data Structures
Author's notes

Pretty clean problem once you see it as a linked list reconstruction.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the fragments as a linked list by building a map from start to fragment and identifying the head as the start that never appears as an end. Then traverse from the head, concatenating payloads, and handle edge cases like cycles or disconnected fragments.

Pro tip: Before coding, clarify with the interviewer whether the fragments are guaranteed to form a single valid chain and whether start/end values are unique; this shows you think about edge cases and data integrity.

1. Clarify assumptions and edge cases

Ask if the chain is guaranteed to be complete, if start/end values are unique, and if there can be cycles or multiple chains. This ensures you handle all scenarios correctly.

2. Build a hash map for quick lookup

Create a dictionary mapping each start value to its fragment, and a set of all end values to identify the head (the start not in the end set).

3. Find the starting fragment

Iterate through fragments to find the one whose start is not present in the set of ends; that's the head of the chain.

4. Traverse and concatenate payloads

Starting from the head, follow the links using the map, appending each payload to a result list, until no next fragment exists or a cycle is detected.

5. Handle edge cases and return result

If the chain is incomplete or cyclic, decide on appropriate behavior (e.g., return partial result or raise error). Join the payloads and return the final string.

Key Points to Mention

  • Time and space complexity: O(n) time and O(n) space using hash maps.
  • Handling cycles: use a visited set or limit iterations to avoid infinite loops.
  • Multiple chains or disconnected fragments: discuss how to detect and handle them.
  • Data validation: check for duplicate starts or ends that could break the chain.
  • Alternative approaches: sorting by start/end or topological sort if fragments are not strictly linear.
  • Real-world application: this is similar to reassembling packets or log entries in distributed systems.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Follow-up: what if each fragment only has two endpoint labels and no explicit direction? Treat each fragment as an undirected edge and reconstruct any valid Eulerian path using all fragments.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the fragments as an undirected multigraph where each fragment is an edge between its two endpoint labels. Check that the graph is connected (ignoring isolated vertices) and has 0 or 2 vertices of odd degree; then use Hierholzer's algorithm to construct an Eulerian path, treating edges as undirected and using all fragments exactly once.

Pro tip: Mention that the path is not unique and that any valid Eulerian path is acceptable; also note that you can start from any odd-degree vertex if two exist, otherwise any vertex with edges, and that using a multiset for adjacency handles parallel edges cleanly.

1. Model as an undirected multigraph

Treat each fragment as an undirected edge between its two endpoint labels. Build an adjacency list or multiset to allow parallel edges and self-loops.

2. Check Eulerian path conditions

Verify the graph is connected (considering only vertices with degree > 0) and count vertices with odd degree. An Eulerian path exists iff there are 0 or 2 odd-degree vertices.

3. Choose a starting vertex

If there are two odd-degree vertices, start at either one; if none, start at any vertex with non-zero degree. This ensures the path can traverse all edges exactly once.

4. Apply Hierholzer's algorithm

Use a stack-based iterative approach: follow edges until stuck, then backtrack and insert vertices into the path. Remove edges as they are used to avoid reusing fragments.

5. Reconstruct and validate the path

Reverse the collected path to get the final sequence of vertices. Verify that all fragments are used exactly once and that consecutive vertices correspond to an edge.

Key Points to Mention

  • Eulerian path existence conditions: connected graph and exactly 0 or 2 odd-degree vertices.
  • Hierholzer's algorithm for efficient O(E) reconstruction using iterative DFS.
  • Handling of parallel edges and self-loops using a multiset or adjacency list with edge counts.
  • Starting vertex selection based on odd-degree vertices.
  • The path is not unique; any valid Eulerian path is acceptable.
  • Edge cases: disconnected graph, isolated vertices, and graphs with no edges.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Second follow-up: the input might contain multiple disconnected chains. How do you detect all components and return the payload sequence for each? Also, how would you detect invalid inputs like cycles, branches, or duplicate edges?

Algorithms & Data StructuresSystem Design
Author's notes

I talked through using union-find or just BFS/DFS per component.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the input as a directed graph and use traversal algorithms to identify connected components and detect structural anomalies. For each component, verify it forms a valid linear chain (no cycles, branches, or duplicate edges) and then extract the payload sequence by following the unique path. Clearly separate the validation phase from the extraction phase to handle invalid inputs gracefully.

Pro tip: Mention that you would first validate the entire graph structure before attempting to extract sequences, as this prevents infinite loops and ensures you only process valid chains. Also, discuss how you would handle edge cases like empty input or self-loops, showing attention to detail.

1. Model the input as a graph

Represent each node and directed edge from the input, ensuring you capture all connections. Use adjacency lists or maps to store outgoing edges per node.

2. Validate graph structure

Check for invalid conditions: cycles (using DFS with recursion stack or Union-Find), branches (nodes with out-degree > 1 or in-degree > 1), and duplicate edges (using a set of edge pairs). If any invalid condition exists, report an error.

3. Find connected components

Treat the graph as undirected to find weakly connected components (e.g., via BFS/DFS or Union-Find). Each component should be a separate chain.

4. Extract payload sequence per component

For each valid component, identify the start node (in-degree 0) and follow the unique outgoing edge until the end, collecting node payloads in order.

5. Handle edge cases and return results

Account for isolated nodes (single-node chains), empty input, and ensure the output is a list of sequences. If any component is invalid, decide whether to skip it or fail entirely based on requirements.

Key Points to Mention

  • Graph representation: adjacency list and in-degree/out-degree tracking
  • Cycle detection: DFS with recursion stack or Union-Find
  • Branch detection: check in-degree and out-degree constraints (each node ≤1 in, ≤1 out)
  • Duplicate edge detection: use a set of (source, target) pairs
  • Connected components: BFS/DFS on undirected version or Union-Find
  • Sequence extraction: start from in-degree 0 node and follow edges

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.