319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a…
Sign in to solveGiven a string s, return the longest palindromic substring in s. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string. Example 1: Example 2: 1 <= s.length…
Sign in to solveGiven the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1: Example 2: The number of nodes in the list is in the range [1, 10^5]. 0 <= Node.val <= 9 Could you do it in O(n) time and O(1) space?
Sign in to solveThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.…
Sign in to solveGiven an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with…
Sign in to solveGiven an undirected connected graph with n vertices (numbered 0 to n-1) and a list of edges, where edges[i] = [u, v, weight], find the total weight of the Minimum Spanning Tree (MST). A Minimum Spanning Tree is a subset of the edges of a…
Sign in to solveDesign and implement a URL shortening service similar to bit.ly or TinyURL. The system should generate short, unique aliases for long URLs, resolve short URLs back to originals, handle high read traffic with caching, and provide click…
Sign in to solveYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and…
Sign in to solveGiven the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the target node. You can return the answer in any order. Input: root =…
Sign in to solveWe are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid…
Sign in to solveYou are given an m x n integer array obstacleGrid. There is a robot initially located at the top-left corner (i.e., obstacleGrid[0][0]). The robot tries to move to the bottom-right corner (i.e., obstacleGrid[m - 1][n - 1]). The robot can…
Sign in to solveGiven an integer array nums, find the subarray with the largest sum, and return its sum. A subarray is a contiguous non-empty sequence of elements within an array. Example 1: Example 2: Example 3: 1 <= nums.length <= 10^5 -10^4 <= nums[i]…
Sign in to solve