← Together AI Interview Insights

Together AI·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Interviewed at together.ai and got a graph problem I've seen before but still managed to overthink it in the moment.

Questions Asked (1)

Q1

Given a set of pods where each pod can depend on other pods, detect whether the dependency graph contains a cycle.

Algorithms & Data Structures
Author's notes

Classic cycle detection, basically Course Schedule from leetcode.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the pods and dependencies as a directed graph and use DFS with a recursion stack or Kahn's algorithm to detect cycles. Clearly state the time and space complexity, and discuss how you would handle edge cases like disconnected components or self-loops.

Pro tip: Mention that this is essentially cycle detection in a directed graph, and relate it to real-world scenarios like deadlock detection or build dependency resolution. Also, briefly note that you can optimize by returning early once a cycle is found.

1. Clarify the problem

Confirm that the input is a directed graph where nodes are pods and edges represent dependencies. Ask if the graph can have self-loops or multiple edges, and whether you need to return the cycle or just a boolean.

2. Choose an algorithm

Decide between DFS with a recursion stack (colors: white, gray, black) or Kahn's algorithm (topological sort). Explain the trade-offs: DFS is simpler to implement recursively, while Kahn's is iterative and can also provide a topological order.

3. Walk through the algorithm

Describe the steps: for DFS, mark nodes as visiting/visited and detect a back edge; for Kahn's, compute in-degrees, repeatedly remove nodes with in-degree 0, and check if all nodes are processed. Use a small example to illustrate.

4. Analyze complexity and edge cases

State that both approaches run in O(V+E) time and O(V) space. Discuss handling disconnected graphs (loop over all nodes), self-loops, and large graphs (recursion depth limits for DFS).

5. Conclude and extend

Summarize that cycle detection is straightforward with these methods. Optionally, mention how to find and return the actual cycle if needed, or how to handle dynamic updates to the graph.

Key Points to Mention

  • Directed graph representation (adjacency list)
  • DFS with recursion stack (white-gray-black coloring)
  • Kahn's algorithm (BFS-based topological sort)
  • Time and space complexity: O(V+E) time, O(V) space
  • Handling disconnected components and self-loops
  • Real-world relevance: deadlock detection, build systems, dependency resolution

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