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)

#ProblemDifficultyTopics
307Range Sum Query - MutableMediumDesign, Binary Indexed Tree, Segment Tree +2
406Queue Reconstruction by HeightMediumBinary Indexed Tree, Segment Tree, Array +1
673Number of Longest Increasing SubsequenceMediumBinary Indexed Tree, Segment Tree, Array +1
1395Count Number of TeamsMediumBinary Indexed Tree, Segment Tree, Array +1
1409Queries on a Permutation With KeyMediumBinary Indexed Tree, Array, Simulation
2250Count Number of Rectangles Containing Each PointMediumBinary Indexed Tree, Array, Hash Table +2
2424Longest Uploaded PrefixMediumUnion Find, Design, Binary Indexed Tree +5
308Range Sum Query 2D - MutablePremiumMediumDesign, Binary Indexed Tree, Segment Tree +2
2031Count Subarrays With More Ones Than ZerosPremiumMediumBinary Indexed Tree, Segment Tree, Array +5
2907Maximum Profitable Triplets With Increasing Prices IPremiumMediumBinary Indexed Tree, Segment Tree, Array

Hard (22)

#ProblemDifficultyTopics
218The Skyline ProblemHardBinary Indexed Tree, Segment Tree, Array +5
315Count of Smaller Numbers After SelfHardBinary Indexed Tree, Segment Tree, Array +4
327Count of Range SumHardBinary Indexed Tree, Segment Tree, Array +4
493Reverse PairsHardBinary Indexed Tree, Segment Tree, Array +4
1157Online Majority Element In SubarrayHardDesign, Binary Indexed Tree, Segment Tree +2
1505Minimum Possible Integer After at Most K Adjacent Swaps On DigitsHardGreedy, Binary Indexed Tree, Segment Tree +1
1649Create Sorted Array through InstructionsHardBinary Indexed Tree, Segment Tree, Array +4
1964Find the Longest Valid Obstacle Course at Each PositionHardBinary Indexed Tree, Array, Binary Search
2179Count Good Triplets in an ArrayHardBinary Indexed Tree, Segment Tree, Array +4
2193Minimum Number of Moves to Make PalindromeHardGreedy, Binary Indexed Tree, Two Pointers +1
2286Booking Concert Tickets in GroupsHardDesign, Binary Indexed Tree, Segment Tree +1
2407Longest Increasing Subsequence IIHardBinary Indexed Tree, Segment Tree, Queue +4
2426Number of Pairs Satisfying InequalityHardBinary Indexed Tree, Segment Tree, Array +4
2552Count Increasing QuadrupletsHardBinary Indexed Tree, Array, Dynamic Programming +2
2659Make Array EmptyHardGreedy, Binary Indexed Tree, Segment Tree +4
2736Maximum Sum QueriesHardStack, Binary Indexed Tree, Segment Tree +4
2926Maximum Balanced Subsequence SumHardBinary Indexed Tree, Segment Tree, Array +2
2940Find Building Where Alice and Bob Can MeetHardStack, Binary Indexed Tree, Segment Tree +4
683K Empty SlotsPremiumHardBinary Indexed Tree, Segment Tree, Queue +5
2519Count the Number of K-Big IndicesPremiumHardBinary Indexed Tree, Segment Tree, Array +4
2916Subarrays Distinct Element Sum of Squares IIHardBinary Indexed Tree, Segment Tree, Array +1
2921Maximum Profitable Triplets With Increasing Prices IIPremiumHardBinary Indexed Tree, Segment Tree, Array

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.