319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
Write a SQL query to find the Nth highest distinct salary from the Employee table. If there are fewer than N distinct salaries, return NULL. For this problem, assume N = 2 in the examples, but your solution should work for any value of N.…
Sign in to solveGiven an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. You must do it in place. Example 1: Example 2: m == matrix.length n == matrix[0].length 1 <= m, n <= 200 -2^31 <= matrix[i][j] <= 2^31 - 1 A…
Sign in to solveDesign a stack-like data structure to push elements to the stack and pop the most frequent element from the stack. Implement the FreqStack class: FreqStack() constructs an empty frequency stack. push(val) pushes an integer val onto the top…
Sign in to solveThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge…
Sign in to solveDesign a scalable and low-latency News Feed system similar to Facebook's News Feed, Twitter's Timeline, or Instagram's Feed. A news feed is a constantly updating list of stories from people, pages, and groups that a user follows. Publish…
Sign in to solveGiven a reference of a node in a connected#Connected_graph) undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. Example 1: Example 2: Example 3:…
Sign in to solveGiven an array of integers nums, your task is to answer multiple range minimum queries. Each query consists of two indices l and r (l <= r), and you must return the minimum value in the range nums[l...r]. To achieve the best performance…
Sign in to solveYou are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and…
Sign in to solveGiven an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Input:…
Sign in to solveYou are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one…
Sign in to solveIn this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge added. The added edge has two different vertices…
Sign in to solveWrite a function that takes the binary representation of a positive integer n and returns the number of set bits it has (also known as the Hamming weight). Input: n = 11 Output: 3 Explanation: The input binary string 1011 has a total of…
Sign in to solve