Skip to main content

Linear Coding Interview Questions

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

Showing 11 problems of 25

  • #15mediumfrequently asked

    15. 3Sum

    Find all unique triplets in an array that sum to zero. Linear asks this to see if you know the 'anchor + two-pointer' pattern and can handle duplicate elimination cleanly — a level above Two Sum that exposes real interview preparation.

  • #49mediumfrequently asked

    49. Group Anagrams

    Group strings that are anagrams of each other. Linear uses this to see if you can design a canonical key for grouping — sorted string vs. character frequency array — and articulate the trade-off between the two.

  • #56mediumfrequently asked

    56. Merge Intervals

    Given a list of intervals, merge all overlapping ones. Linear asks this to test sorting-as-preprocessing and clean interval comparison logic — a practical problem that maps directly to scheduling and event systems, fitting for a project management tool company.

  • #98mediumfrequently asked

    98. Validate Binary Search Tree

    Check that every node in a binary tree satisfies the BST property. Linear uses this to see if you avoid the common trap of only comparing a node to its direct parent — the BST constraint is global, not local.

  • #146mediumfrequently asked

    146. LRU Cache

    Design a cache that evicts the least-recently-used item when it's full. Linear asks this because it's a real design problem embedded in a coding question — you need to compose a hash map and a doubly-linked list to hit O(1) get and put.

  • #200mediumfrequently asked

    200. Number of Islands

    Count connected components of '1's in a 2D grid. Linear uses this as a graph traversal benchmark — both DFS and BFS are accepted, but the interviewer wants to hear you name the approach and explain the visited-cell marking strategy.

  • #207mediumfrequently asked

    207. Course Schedule

    Detect whether a set of course prerequisites forms a cycle. Linear asks this to test directed-graph cycle detection — can you reach for DFS with three-color marking or Kahn's topological sort, and explain the difference?

  • #238mediumfrequently asked

    238. Product of Array Except Self

    Return an array where each element is the product of all other elements, without using division and in O(n). Linear asks this to see if you can find the 'prefix and suffix product' insight — a classic example of precomputed auxiliary arrays.

  • #322mediumfrequently asked

    322. Coin Change

    Find the minimum number of coins to make a given amount. Linear asks this as a benchmark DP problem — it separates candidates who pattern-match 'unbounded knapsack' from those who just try greedy and hit the wrong answer.

  • #347mediumfrequently asked

    347. Top K Frequent Elements

    Return the k most frequent elements in an array. Linear uses this to probe your knowledge of heaps vs. bucket sort — both O(n log k) and O(n) solutions exist, and the interviewer wants to see if you know both.

Linear Coding Interview Questions — Full Solutions — InterviewChamp.AI