JetBrains Coding Interview Questions
25 JetBrains coding interview problems with full optimal solutions — 9 easy, 12 medium, 4 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an JetBrains interviewer values, and a FAQ section.
- #1easyfoundational
1. Two Sum
Find two indices whose values sum to a target, used at JetBrains to gauge baseline data-structure fluency before symbol-table style problems.
- #2easyfoundational
2. Valid Parentheses
Determine if a string of brackets is balanced — the bread-and-butter check inside every JetBrains parser before AST construction.
- #3easyfoundational
3. Same Tree
Check whether two binary trees are structurally and value-equal node-by-node — JetBrains uses this to gauge whether you can compare PSI subtrees for incremental reparse.
- #4easyfoundational
4. Best Time to Buy and Sell Stock
Find the max profit from one buy and one sell over a price array — a single-pass scan that mirrors the streaming token analyses inside JetBrains lexers.
- #5easyfoundational
5. Single Number
Find the one element that appears once when all others appear twice — JetBrains uses this to test XOR fluency, a primitive in their hash-based PSI fingerprints.
- #5easyfoundational
5. Valid Palindrome
Check whether a sanitized string reads identically forward and backward — JetBrains uses this to gauge two-pointer discipline before deeper string-scanning problems.
- #6easyfoundational
6. Linked List Cycle
Detect whether a linked list contains a cycle — JetBrains uses this to gauge whether you can spot graph cycles in symbol-resolution chains.
- #7easyfoundational
7. Min Stack
Design a stack supporting push/pop/top/getMin all in O(1) — JetBrains uses this to gauge whether you can maintain auxiliary invariants in scope-stack data structures.
- #8easyfoundational
8. Majority Element
Find the element that appears more than n/2 times — JetBrains uses this to test whether you can collapse counters in constant space using the Boyer-Moore vote.
- #9mediumfoundational
9. Number of Islands
Count connected land components in a 2D grid — JetBrains uses this to gauge graph-traversal fluency before any code-graph clustering follow-up.
- #10mediumfoundational
10. Kth Largest Element in an Array
Return the kth largest element without fully sorting — JetBrains uses this to gauge whether you can pick the right partial-sort primitive for top-N completion ranking.
- #11mediumfoundational
11. Product of Array Except Self
Build an output array where each index is the product of all other elements — JetBrains uses this to test prefix/suffix sweep skills before AST-attribute propagation problems.
- #12mediumfoundational
12. Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence — JetBrains uses this to test whether you reach for binary-search patience-sort over naive DP.
- #13mediumfoundational
13. Coin Change
Find the minimum number of coins to make a given amount — JetBrains uses this to gauge bottom-up DP discipline before tackling cost-driven refactor recommenders.
- #14mediumfoundational
14. Top K Frequent Elements
Return the k most frequent elements — JetBrains uses this to test bucket-sort intuition behind their frequency-based identifier ranking.
- #15mediumfoundational
15. Partition Equal Subset Sum
Decide whether an array can be split into two equal-sum subsets — JetBrains uses this to test subset-sum DP space optimization, a primitive in their refactor cost balancing.
- #16mediumfoundational
16. 01 Matrix
Compute the distance from each cell to the nearest 0 — JetBrains uses this to test multi-source BFS, the primitive behind their reachability analyses on call graphs.
- #17mediumfoundational
17. Max Area of Island
Find the largest connected island in a grid — JetBrains uses this to test whether you can attach an aggregator to a DFS traversal, the way their inspections sum metrics over PSI subtrees.
- #18mediumfoundational
18. Rotting Oranges
Compute the minutes until all oranges rot via 4-directional spread — JetBrains uses this to test level-based BFS, the primitive behind their incremental-rebuild scheduling.
- #19mediumfoundational
19. Capacity to Ship Packages Within D Days
Find the minimum daily ship capacity to deliver all packages within D days — JetBrains uses this to test binary-search-on-answer, the technique behind their build-time autotuner.
- #20mediumfoundational
20. Longest Common Subsequence
Find the longest sequence appearing as a subsequence in both strings — JetBrains uses this to test the DP foundation under their diff and merge tooling.
- #21hardfoundational
21. Binary Tree Maximum Path Sum
Find the maximum path sum where a path is any node-to-node sequence — JetBrains uses this to test whether you can separate a recursive contribution from a global answer over an AST.
- #22hardfoundational
22. Find Median from Data Stream
Maintain a running median over a stream of integers — JetBrains uses this to test two-heap balance, the same trick behind their incremental indexer's latency percentile sampler.
- #23hardfoundational
23. Serialize and Deserialize Binary Tree
Encode a binary tree to a string and decode it back losslessly — JetBrains uses this to test tree-serialization design, mirroring how PSI stubs hit disk and rehydrate.
- #24hardfoundational
24. LFU Cache
Design an O(1) least-frequently-used cache — JetBrains uses this to test layered data-structure design, the kind powering their PSI stub and reference caches.