319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of a number x is the first greater number to its…
Sign in to solveA phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a…
Sign in to solveImplement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implement the MyQueue class: void push(int x) Pushes element x to the…
Sign in to solveGiven 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 of nums between indices left and right inclusive where left <= right. Implement the…
Sign in to solveGiven two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Input: left = 5, right = 7 Output: 4 Explanation: 5 is 101, 6 is 110, 7 is 111. 101 & 110 & 111 = 100…
Sign in to solveGiven the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. Example 1: Example 2:…
Sign in to solveYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may…
Sign in to solveYou are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like with the following restriction: After you sell your…
Sign in to solveGiven an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice. You must write an algorithm that runs in $O(n)$…
Sign in to solveGiven a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Input: nums = [1,1,2] Output: [[1,1,2], [1,2,1], [2,1,1]] Input: nums = [1,2,3] Output:…
Sign in to solve(requester_id, accepter_id) is the primary key. Each row contains the IDs of two users who accepted a friend request and the date it was accepted. Write a SQL query to find the people who have the most friends and the most friends number.…
Sign in to solveA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <=…
Sign in to solve