← Perplexity Interview Insights

Perplexity·Software Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
May 2026

Summary

Perplexity SWE coding round. One question, two parts, and I tripped on edge cases at the end which probably cost me the offer.

Questions Asked (1)

Q1

Given a list of sources that may contain duplicates, first deduplicate them, then reorder the remaining sources based on the order they appear across a set of paragraphs.

Algorithms & Data Structures
Author's notes

Got through the main logic fine, dedup first then figure out the order from the paragraphs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem: deduplicate sources while preserving first occurrence, then reorder based on the order they appear across paragraphs. Propose an efficient algorithm using a hash set for deduplication and a hash map to track first occurrence positions, then sort by those positions. Discuss time/space complexity and edge cases.

Pro tip: Mention that the reordering should be stable and based on the first appearance across paragraphs, and that you can combine deduplication and ordering in one pass to avoid multiple iterations.

1. Clarify requirements and constraints

Ask about input format: are sources strings? Are paragraphs lists of sources? Confirm that deduplication should keep the first occurrence and that reordering is based on the earliest appearance across all paragraphs.

2. Design the algorithm

Use a hash set to track seen sources for deduplication. Use a hash map to store the first index where each unique source appears across paragraphs. Then sort the unique sources by that index.

3. Analyze complexity and optimize

Time complexity: O(N + M log M) where N is total sources and M is unique sources. Space: O(M). Mention that if paragraphs are already in order, you can collect unique sources in order without sorting.

4. Handle edge cases

Consider empty inputs, all duplicates, sources appearing in multiple paragraphs, and large datasets. Discuss stability and whether the original order of paragraphs matters.

5. Test and validate

Walk through a small example to verify correctness. Mention potential pitfalls like case sensitivity or whitespace differences if sources are strings.

Key Points to Mention

  • Hash set for O(1) deduplication checks
  • Hash map to track first occurrence index
  • Sorting unique sources by first occurrence index
  • Time and space complexity analysis
  • Stability and preserving original order of first appearances
  • Edge cases: empty input, all duplicates, sources across multiple paragraphs

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