Skip to main content

Palantir Coding Interview Questions

25 Palantir coding interview problems with full optimal solutions — 15 easy, 7 medium, 3 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Palantir interviewer values, and a FAQ section.

  • #1easyfrequently asked

    1. Two Sum

    Given an array of integers and a target, return indices of the two numbers that sum to target. Palantir asks this early as a warm-up to gauge whether you reach for hash-map lookups immediately or default to nested loops, since their ETL pipelines join entities by key constantly.

  • #2easyfrequently asked

    2. Valid Parentheses

    Determine if a string of brackets is balanced and properly nested. Palantir uses this to probe whether you reach for a stack immediately, since their Foundry expression parser and ontology query language need balanced delimiter validation.

  • #3easysometimes asked

    3. Merge Two Sorted Lists

    Merge two sorted linked lists into one sorted list. Palantir asks this to gauge pointer hygiene since their ETL transforms frequently merge sorted streams of records by primary key.

  • #4easysometimes asked

    4. Remove Duplicates from Sorted Array

    In-place de-duplicate a sorted array and return the new length. Palantir asks this to test the two-pointer pattern, which is the foundation of any de-dup pass over a sorted entity-resolution candidate stream.

  • #5easyrarely asked

    5. Remove Element

    Remove all occurrences of a value from an array in-place and return the new length. Palantir asks this to test the same two-pointer pattern used in filter-stage transforms of their Foundry data pipelines.

  • #6easysometimes asked

    6. Search Insert Position

    Find the index where a target should be inserted in a sorted array. Palantir uses this as a binary-search litmus test before harder lower-bound problems on time-series telemetry indices.

  • #7easysometimes asked

    7. Maximum Subarray

    Find the contiguous subarray with the largest sum. Palantir asks this because Kadane's algorithm illustrates the running-state pattern they expect in streaming aggregations over time-series telemetry.

  • #8easyrarely asked

    8. Plus One

    Increment a number represented as an array of digits. Palantir asks this to gauge attention to carry propagation, which mirrors how their telemetry counters roll over.

  • #9easysometimes asked

    9. Merge Sorted Array

    Merge two sorted arrays in-place where the first has extra space at the end. Palantir asks this to test the right-to-left two-pointer trick, which prevents overwriting unread data — a pattern they use in in-place ETL compaction.

  • #10easysometimes asked

    10. Binary Tree Inorder Traversal

    Return the inorder traversal of a binary tree's values. Palantir asks this to test whether you can write iterative tree traversal — a primitive for walking ontology graphs without stack overflow on deep hierarchies.

  • #11easysometimes asked

    11. Same Tree

    Given the roots of two binary trees p and q, write a function to check if they are the same. Palantir asks this to verify that you reason about tree equality recursively the same way they compare two versions of an ontology snapshot during a Foundry branch merge.

  • #12easysometimes asked

    12. Maximum Depth of Binary Tree

    Given the root of a binary tree, return its maximum depth. Palantir uses this to gauge whether you treat tree depth as a recursive max problem — the same primitive they use to compute the longest dependency chain in an ETL DAG before deciding scheduler timeouts.

  • #13easyfrequently asked

    13. Best Time to Buy and Sell Stock

    Given an array prices where prices[i] is the price of a given stock on day i, find the maximum profit from a single buy/sell. Palantir uses this to test whether you spot the running-min-then-diff streaming pattern they apply to anomaly detection across time-series rows in a Foundry dataset.

  • #14easysometimes asked

    14. Single Number

    Given a non-empty array of integers where every element appears twice except for one, find that single one. Palantir asks this to see if you reach for XOR — a constant-space trick they value when streaming dedup logic runs on row-level entity resolution in Foundry.

  • #15easysometimes asked

    15. Majority Element

    Given an array of size n, return the element that appears more than n/2 times. Palantir asks this to test whether you know Boyer-Moore voting — an O(1)-space streaming primitive they care about because it generalizes to finding the dominant entity ID across a sharded dataset without a shuffle.

  • #16mediumfrequently asked

    16. Number of Islands

    Given a 2D grid of '1's (land) and '0's (water), count the number of islands. Palantir asks this to verify you write iterative flood-fill cleanly — the same connected-components primitive their entity-resolution pipelines use to cluster duplicate records into a single canonical entity in the ontology.

  • #17mediumfrequently asked

    17. Course Schedule

    Given n courses with prerequisite pairs, determine if you can finish all courses. Palantir asks this because it's literally the same cycle-detection check their Foundry build engine runs before scheduling an ETL DAG — any cycle and the pipeline rejects the build.

  • #18mediumfrequently asked

    18. Course Schedule II

    Return the order in which you should take courses to finish them all; if impossible, return []. Palantir asks this as the natural follow-up to cycle detection — the actual execution order is what their Foundry scheduler emits when it serializes an ETL DAG into a runnable task list.

  • #19mediumsometimes asked

    19. Kth Largest Element in an Array

    Find the kth largest element in an unsorted array. Palantir asks this to test whether you reach for a min-heap of size k — the same streaming primitive their dashboards use to compute top-k entities by row count without scanning the whole dataset twice.

  • #20mediumfrequently asked

    20. Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor of two given nodes. Palantir asks this because it's the kernel of their ontology permission resolver — to determine the closest shared parent of two entities so row-level ACL checks can short-circuit at the right scope.

  • #21mediumsometimes asked

    21. Longest Increasing Subsequence

    Given an integer array nums, return the length of the longest strictly increasing subsequence. Palantir asks this to see whether you know the O(n log n) patience-sort trick — they care because the same algorithm powers monotone trend extraction over a sorted-by-time partition in a Foundry transform.

  • #22mediumsometimes asked

    22. Critical Connections in a Network

    Find all critical edges (bridges) in an undirected network whose removal disconnects it. Palantir asks this because their ontology team uses Tarjan's bridge algorithm to flag dependency edges in an ETL DAG whose removal would silo a downstream pipeline — bridges are blast-radius signals.

  • #23hardsometimes asked

    23. Binary Tree Maximum Path Sum

    A path in a binary tree is any sequence of nodes connected by edges; return the maximum sum across all such paths. Palantir asks this to see whether you separate the value RETURNED from a recursive call from the value RECORDED at each node — the same split they use when computing aggregated weights along ontology paths under row-level ACL.

  • #24hardsometimes asked

    24. Alien Dictionary

    Given a list of words sorted lexicographically by an alien language, derive the character order. Palantir asks this because it's the textbook example of inferring a partial order from observed pairs — exactly what their ontology system does when reconciling type hierarchies from disparate source systems during entity resolution.

  • #25hardrarely asked

    25. Longest Cycle in a Graph

    Given a directed graph where each node has at most one outgoing edge, return the length of the longest cycle. Palantir asks this because their ontology validator must detect cycles in foreign-key constraints — and when each entity points to exactly one parent, the cycle search shape is precisely this problem.

Palantir Coding Interview Questions — Full Solutions — InterviewChamp.AI