319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
You are given the root node of a binary search tree (BST) and a val to insert into the tree. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. There may exist…
Sign in to solveGiven a string s, find the length of the longest substring without repeating characters. A substring is a contiguous non-empty sequence of characters within a string. Example 1: Example 2: Example 3: 0 <= s.length <= 5 * 10^4 s consists of…
Sign in to solveSimulate water molecule formation. There are two kinds of threads: hydrogen and oxygen. Your goal is to group these threads to form water molecules (H2O). Each molecule needs exactly 2 hydrogen atoms and 1 oxygen atom. A barrier mechanism…
Sign in to solveDesign and implement a fully RESTful API for a blog platform. The API should support creating, reading, updating, and deleting blog posts and comments, following REST best practices including proper HTTP methods, status codes, and resource…
Sign in to solveImplement a Disjoint Set Union (DSU) data structure, also known as Union-Find. The DSU should support the following operations efficiently: find(i): Determine which set an element i belongs to. Return the "representative" or "root" of that…
Sign in to solveThe next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For…
Sign in to solveSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or…
Sign in to solveYou are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money…
Sign in to solveDesign a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the…
Sign in to solveGiven an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Example 2: Example 3: 1 <= nums.length <= 6 -10 <= nums[i] <= 10 All the integers of nums are unique.
Sign in to solveA tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes labeled from 0 to n - 1, and an array of n - 1 edges…
Sign in to solveImplement a drag-and-drop list reordering system. Build a DragDropList class that manages list items and supports reordering through drag-and-drop operations. Your implementation should handle: Reordering — Move an item from one position…
Sign in to solve