Divide And Conquer Problems
Master divide and conquer problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 42 problems in this category.
Total Problems: 42
Easy: 5
Medium: 22
Hard: 15
Showing 42 of 42 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Divide And Conquer LeetCode Problems List
- 4. Median of Two Sorted Arrays - Hard - Divide And ConquerGiven two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity shou... Topics: Array, Binary Search, Divide and Conquer
- 53. Maximum Subarray - Medium - Divide And ConquerGiven an integer array nums, find the subarray with the largest sum, and return its sum.... Topics: Array, Divide and Conquer, Dynamic Programming
- 347. Top K Frequent Elements - Medium - Divide And ConquerGiven an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.... Topics: Array, Hash Table, Divide and Conquer, Sorting, Heap (Priority Queue), Bucket Sort, Counting, Quickselect
- 1014. K Closest Points to Origin - Medium - Divide And ConquerGiven an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0... Topics: Array, Math, Divide and Conquer, Geometry, Sorting, Heap (Priority Queue), Quickselect
- 23. Merge k Sorted Lists - Hard - Divide And ConquerYou are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list ... Topics: Linked List, Divide and Conquer, Heap (Priority Queue), Merge Sort
- 169. Majority Element - Easy - Divide And ConquerGiven an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume t... Topics: Array, Hash Table, Divide and Conquer, Sorting, Counting
- 215. Kth Largest Element in an Array - Medium - Divide And ConquerGiven an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order... Topics: Array, Divide and Conquer, Sorting, Heap (Priority Queue), Quickselect
- 190. Reverse Bits - Easy - Divide And ConquerReverse bits of a given 32 bits signed integer.... Topics: Divide and Conquer, Bit Manipulation
- 108. Convert Sorted Array to Binary Search Tree - Easy - Divide And ConquerGiven an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.... Topics: Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
- 105. Construct Binary Tree from Preorder and Inorder Traversal - Medium - Divide And ConquerGiven two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the sa... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 148. Sort List - Medium - Divide And ConquerGiven the head of a linked list, return the list after sorting it in ascending order.... Topics: Linked List, Two Pointers, Divide and Conquer, Sorting, Merge Sort
- 106. Construct Binary Tree from Inorder and Postorder Traversal - Medium - Divide And ConquerGiven two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 315. Count of Smaller Numbers After Self - Hard - Divide And ConquerGiven an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 948. Sort an Array - Medium - Divide And ConquerGiven an array of integers nums, sort the array in ascending order and return it. You must solve the problem without using any built-in functions in O... Topics: Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort
- 1285. Balance a Binary Search Tree - Medium - Divide And ConquerGiven the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any o... Topics: Divide and Conquer, Greedy, Tree, Depth-First Search, Binary Search Tree, Binary Tree
- 2526. Longest Increasing Subsequence II - Hard - Divide And ConquerYou are given an integer array nums and an integer k. Find the longest subsequence of nums that meets the following requirements: The subsequence is s... Topics: Array, Divide and Conquer, Dynamic Programming, Binary Indexed Tree, Segment Tree, Queue, Monotonic Queue
- 395. Longest Substring with At Least K Repeating Characters - Medium - Divide And ConquerGiven a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is grea... Topics: Hash Table, String, Divide and Conquer, Sliding Window
- 954. Maximum Sum Circular Subarray - Medium - Divide And ConquerGiven a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums. A circular array means the end of th... Topics: Array, Divide and Conquer, Dynamic Programming, Queue, Monotonic Queue
- 218. The Skyline Problem - Hard - Divide And ConquerA city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and ... Topics: Array, Divide and Conquer, Binary Indexed Tree, Segment Tree, Line Sweep, Heap (Priority Queue), Ordered Set
- 109. Convert Sorted List to Binary Search Tree - Medium - Divide And ConquerGiven the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree.... Topics: Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
- 324. Wiggle Sort II - Medium - Divide And ConquerGiven an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... You may assume the input array always has a valid answer.... Topics: Array, Divide and Conquer, Greedy, Sorting, Quickselect
- 240. Search a 2D Matrix II - Medium - Divide And ConquerWrite an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in... Topics: Array, Binary Search, Divide and Conquer, Matrix
- 2113. Find the Kth Largest Integer in the Array - Medium - Divide And ConquerYou are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros. Return the string that repre... Topics: Array, String, Divide and Conquer, Sorting, Heap (Priority Queue), Quickselect
- 191. Number of 1 Bits - Easy - Divide And ConquerGiven a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).... Topics: Divide and Conquer, Bit Manipulation
- 968. Beautiful Array - Medium - Divide And ConquerAn array nums of length n is beautiful if: nums is a permutation of the integers in the range [1, n]. For every 0 <= i < j < n, there is no index k wi... Topics: Array, Math, Divide and Conquer
- 2109. Find Array Given Subset Sums - Hard - Divide And ConquerYou are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the... Topics: Array, Divide and Conquer
- 925. Construct Binary Tree from Preorder and Postorder Traversal - Medium - Divide And ConquerGiven two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the pos... Topics: Array, Hash Table, Divide and Conquer, Tree, Binary Tree
- 327. Count of Range Sum - Hard - Divide And ConquerGiven an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) ... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 3423. Maximum Sum of Subsequence With Non-adjacent Elements - Hard - Divide And ConquerYou are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi]. For query i, we first set nu... Topics: Array, Divide and Conquer, Dynamic Programming, Segment Tree
- 307. Range Sum Query - Mutable - Medium - Divide And ConquerGiven an integer array nums, handle multiple queries of the following types: Update the value of an element in nums. Calculate the sum of the elements... Topics: Array, Divide and Conquer, Design, Binary Indexed Tree, Segment Tree
- 493. Reverse Pairs - Hard - Divide And ConquerGiven an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where: 0 <= i < j < nums.length and nums... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 772. Construct Quad Tree - Medium - Divide And ConquerGiven a n * n matrix grid of 0's and 1's only. We want to represent grid with a Quad-Tree. Return the root of the Quad-Tree representing grid. A Quad-... Topics: Array, Divide and Conquer, Tree, Matrix
- 3941. Number of Integers With Popcount-Depth Equal to K II - Hard - Divide And ConquerYou are given an integer array nums. For any positive integer x, define the following sequence: p0 = x pi+1 = popcount(pi) for all i >= 0, where popco... Topics: Array, Divide and Conquer, Binary Indexed Tree, Segment Tree
- 1772. Create Sorted Array through Instructions - Hard - Divide And ConquerGiven an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums.... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 654. Maximum Binary Tree - Medium - Divide And ConquerYou are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create... Topics: Array, Divide and Conquer, Stack, Tree, Monotonic Stack, Binary Tree
- 2513. Number of Pairs Satisfying Inequality - Hard - Divide And ConquerYou are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that: 0 <= i < j... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 2280. Count Good Triplets in an Array - Hard - Divide And ConquerYou are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1]. A good triplet is a set of 3 dis... Topics: Array, Binary Search, Divide and Conquer, Binary Indexed Tree, Segment Tree, Merge Sort, Ordered Set
- 1873. Longest Nice Substring - Easy - Divide And ConquerA string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice beca... Topics: Hash Table, String, Divide and Conquer, Bit Manipulation, Sliding Window
- 1692. Number of Ways to Reorder Array to Get Same BST - Hard - Divide And ConquerGiven an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the eleme... Topics: Array, Math, Divide and Conquer, Dynamic Programming, Tree, Union Find, Binary Search Tree, Memoization, Combinatorics, Binary Tree
- 372. Super Pow - Medium - Divide And ConquerYour task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.... Topics: Math, Divide and Conquer
- 3955. Threshold Majority Queries - Hard - Divide And ConquerYou are given an integer array nums of length n and an array queries, where queries[i] = [li, ri, thresholdi]. Return an array of integers ans where a... Topics: Array, Hash Table, Binary Search, Divide and Conquer, Counting, Prefix Sum
- 3822. Fill a Special Grid - Medium - Divide And ConquerYou are given a non-negative integer n representing a 2n x 2n grid. You must fill the grid with integers from 0 to 22n - 1 to make it special. A grid ... Topics: Array, Divide and Conquer, Matrix
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems