← Perplexity Interview Insights

Perplexity·Software Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
May 2026

Summary

Coding round at Perplexity for a software engineer role. The problem involved deduplicating sources and then reordering them by their appearance in paragraphs. Finished the code but tripped on edge cases, so probably a rejection.

Questions Asked (1)

Q1

Given a list of sources and a set of paragraphs, first deduplicate the sources, then reorder them according to the sequence in which they appear across the paragraphs.

Algorithms & Data Structures
Author's notes

Got the main logic working but edge cases killed me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem by defining what constitutes a duplicate source (e.g., exact match or normalized) and how to identify source occurrences within paragraphs. Then propose an algorithm that first deduplicates sources using a hash set, and then collects the first occurrence index of each unique source across all paragraphs, finally sorting by that index. Discuss time and space complexity and potential edge cases.

Pro tip: Mention that you would use a stable sort or preserve the original order of first appearances to handle ties, and consider if sources can appear multiple times in a paragraph—only the first occurrence matters for ordering.

1. Clarify requirements and assumptions

Ask about the definition of duplicate sources (exact string match, case-insensitive, etc.) and whether paragraphs are processed in a given order. Confirm that the output should be a list of unique sources ordered by their first appearance across all paragraphs.

2. Deduplicate sources

Use a hash set to iterate through the list of sources and keep only the first occurrence of each unique source. This yields a list of unique sources while preserving their original order.

3. Map sources to first occurrence in paragraphs

Iterate through paragraphs in order, and for each paragraph, scan for any of the unique sources. Record the index (paragraph number and position) of the first time each source is encountered. Use a hash map to store source -> first occurrence index.

4. Sort unique sources by first occurrence

Sort the unique sources based on their recorded first occurrence index. If a source never appears in any paragraph, decide whether to place it at the end or exclude it (clarify with interviewer).

5. Analyze complexity and edge cases

Discuss time complexity: O(S + P*L) where S is number of sources, P is number of paragraphs, L is average paragraph length. Space complexity: O(S). Mention edge cases like empty sources, no paragraphs, sources not appearing, and duplicate sources with different cases.

Key Points to Mention

  • Use a hash set for O(1) average-time deduplication.
  • Preserve the original order of sources during deduplication to maintain stability.
  • Use a hash map to track the first occurrence index of each source across paragraphs.
  • Sorting can be done in O(U log U) where U is number of unique sources.
  • Consider normalization (e.g., lowercasing) if duplicates are case-insensitive.
  • Handle sources that never appear in paragraphs by either appending them or excluding them based on requirements.

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