319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character Example…
Sign in to solveYou have a graph of n nodes. You are given an integer n and an array edges where edges[i] = [ai, bi] indicates that there is an edge between ai and bi in the graph. Return the number of connected components in the graph. Example 1: Example…
Sign in to solveGiven the root of a binary tree, return the inorder traversal of its nodes' values. An inorder traversal visits the nodes in the following order: Left subtree Root node Right subtree Input: root = [1, null, 2, 3] Output: [1, 3, 2]…
Sign in to solveIf the customer's preferred delivery date is the same as the order date, then the order is called immediate; otherwise, it is called scheduled. The first order of a customer is the order with the earliest order date that the customer made.…
Sign in to solveYou are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example…
Sign in to solveGiven a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) Example 1: Example 2: Example 3: The number…
Sign in to solveGiven an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: After squaring, the array becomes…
Sign in to solveImplement a promiseAny function that behaves like Promise.any. It takes an array of promises and returns a single promise that: Resolves with the value of the first promise that fulfills. Rejects with an AggregateError containing all…
Sign in to solve(customer_id, year) is the primary key. Each row contains the customer ID, the year, and the revenue for that customer in that year. Revenue can be negative (refunds/losses). Write a SQL query to find customers whose total revenue across…
Sign in to solveYou 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 and return it. Example 1: Example 2: Example 3: k == lists.length 0 <= k <= 10^4 0 <=…
Sign in to solveThere is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings words from the alien language's dictionary, where the strings in words are sorted…
Sign in to solveThe Lowest Common Ancestor (LCA) of two nodes $u$ and $v$ in a rooted tree is the deepest node that is an ancestor of both $u$ and $v$. While a simple recursive approach can find the LCA in $O(N)$ time per query, Binary Lifting allows us…
Sign in to solve