319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null. For example, the following two linked lists begin to intersect…
Sign in to solveGiven an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Input: nums = [0,1,0,3,12] Output:…
Sign in to solveThe DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGTACGTACGT" is a DNA sequence. When studying DNA, it is useful to identify repeated sequences within the DNA. Given a string s…
Sign in to solveThere is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. The island is…
Sign in to solveImplement the K-Means Clustering algorithm from scratch. K-Means partitions data into K clusters by iteratively assigning points to the nearest centroid and updating centroids. Initialize centroids using the first K data points Assign each…
Sign in to solveImplement a memoize function that caches the result of a function call based on its arguments. If the function is called again with the same arguments, the cached result should be returned without re-executing the function. fn — The…
Sign in to solveImplement the Saga pattern for managing distributed transactions across microservices. When a multi-step business process (like placing an order) spans multiple services, you need to ensure that either all steps complete successfully, or…
Sign in to solveGiven a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator. For example, do not use…
Sign in to solveGiven the head of a linked list, return the list after sorting it in ascending order. Example 1: Example 2: Example 3: The number of nodes in the list is in the range [0, 5 * 10^4]. -10^5 <= Node.val <= 10^5 Follow up: Can you sort the…
Sign in to solveGiven the root of a binary tree, invert the tree, and return its root. Example 1: Example 2: Example 3: The number of nodes in the tree is in the range [0, 100]. -100 <= Node.val <= 100
Sign in to solveImplement a class ZeroEvenOdd with three methods that run concurrently. The output should follow the pattern: 0, 1, 0, 2, 0, 3, 0, 4, ... up to n. zero() prints "0" odd() prints odd numbers (1, 3, 5, ...) even() prints even numbers (2, 4,…
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 solve