Binary Indexed Tree LeetCode Problems: All 32, With Python Solutions
Every problem in this library that LeetCode tags Binary Indexed Tree — 32 in total, 25 of them with a complete Python solution, a worked example and the time and space complexity of the approach.
- 32 problems
- 0 Easy
- 10 Medium
- 22 Hard
Binary Indexed Tree problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Medium (10)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 307 | Range Sum Query - Mutable | Medium | Design, Binary Indexed Tree, Segment Tree +2 |
| 406 | Queue Reconstruction by Height | Medium | Binary Indexed Tree, Segment Tree, Array +1 |
| 673 | Number of Longest Increasing Subsequence | Medium | Binary Indexed Tree, Segment Tree, Array +1 |
| 1395 | Count Number of Teams | Medium | Binary Indexed Tree, Segment Tree, Array +1 |
| 1409 | Queries on a Permutation With Key | Medium | Binary Indexed Tree, Array, Simulation |
| 2250 | Count Number of Rectangles Containing Each Point | Medium | Binary Indexed Tree, Array, Hash Table +2 |
| 2424 | Longest Uploaded Prefix | Medium | Union Find, Design, Binary Indexed Tree +5 |
| 308 | Range Sum Query 2D - MutablePremium | Medium | Design, Binary Indexed Tree, Segment Tree +2 |
| 2031 | Count Subarrays With More Ones Than ZerosPremium | Medium | Binary Indexed Tree, Segment Tree, Array +5 |
| 2907 | Maximum Profitable Triplets With Increasing Prices IPremium | Medium | Binary Indexed Tree, Segment Tree, Array |
Hard (22)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 218 | The Skyline Problem | Hard | Binary Indexed Tree, Segment Tree, Array +5 |
| 315 | Count of Smaller Numbers After Self | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 327 | Count of Range Sum | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 493 | Reverse Pairs | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 1157 | Online Majority Element In Subarray | Hard | Design, Binary Indexed Tree, Segment Tree +2 |
| 1505 | Minimum Possible Integer After at Most K Adjacent Swaps On Digits | Hard | Greedy, Binary Indexed Tree, Segment Tree +1 |
| 1649 | Create Sorted Array through Instructions | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 1964 | Find the Longest Valid Obstacle Course at Each Position | Hard | Binary Indexed Tree, Array, Binary Search |
| 2179 | Count Good Triplets in an Array | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 2193 | Minimum Number of Moves to Make Palindrome | Hard | Greedy, Binary Indexed Tree, Two Pointers +1 |
| 2286 | Booking Concert Tickets in Groups | Hard | Design, Binary Indexed Tree, Segment Tree +1 |
| 2407 | Longest Increasing Subsequence II | Hard | Binary Indexed Tree, Segment Tree, Queue +4 |
| 2426 | Number of Pairs Satisfying Inequality | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 2552 | Count Increasing Quadruplets | Hard | Binary Indexed Tree, Array, Dynamic Programming +2 |
| 2659 | Make Array Empty | Hard | Greedy, Binary Indexed Tree, Segment Tree +4 |
| 2736 | Maximum Sum Queries | Hard | Stack, Binary Indexed Tree, Segment Tree +4 |
| 2926 | Maximum Balanced Subsequence Sum | Hard | Binary Indexed Tree, Segment Tree, Array +2 |
| 2940 | Find Building Where Alice and Bob Can Meet | Hard | Stack, Binary Indexed Tree, Segment Tree +4 |
| 683 | K Empty SlotsPremium | Hard | Binary Indexed Tree, Segment Tree, Queue +5 |
| 2519 | Count the Number of K-Big IndicesPremium | Hard | Binary Indexed Tree, Segment Tree, Array +4 |
| 2916 | Subarrays Distinct Element Sum of Squares II | Hard | Binary Indexed Tree, Segment Tree, Array +1 |
| 2921 | Maximum Profitable Triplets With Increasing Prices IIPremium | Hard | Binary Indexed Tree, Segment Tree, Array |
Keep exploring
All LeetCode topicsEvery tag with a page of its own, with the number of problems behind each.LeetCode patternsThe techniques themselves, with a Python template and complexity for each.Curated study listsBlind 75, NeetCode 150 and three more, grouped by pattern.Easy problemsStart here when the data structure is new rather than the problem.
Other topics
- Array1,569
- String672
- Hash Table588
- Math485
- Dynamic Programming481
- Sorting392
- Greedy346
- Depth-First Search289
- Binary Search253
- Database249
- Tree225
- Breadth-First Search223
- Matrix216
- Two Pointers201
- Bit Manipulation194
- Binary Tree174
- Heap (Priority Queue)163
- Prefix Sum157
- Stack157
- Simulation144
- Graph138
- Counting126
- Design122
- Sliding Window116
When the Binary Indexed Tree problem arrives live
Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.