319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Example 2: n == height.length 1 <= n <= 2 * 10^4 0 <= height[i] <= 10^5
Sign in to solveGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can…
Sign in to solveImplement a caching layer service that sits between your API and database, using Redis-like semantics. The cache should support TTL-based expiration, multiple caching strategies (cache-aside, write-through), and handle common cache…
Sign in to solveBuild a collaborative filtering recommendation engine using user-based cosine similarity. Given a user-item rating matrix, predict ratings for items a user hasn't rated and recommend the top items. Compute cosine similarity between the…
Sign in to solveSuppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 times.…
Sign in to solveYou are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). The rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another…
Sign in to solveKoko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of…
Sign in to solveCreate production-ready Kubernetes manifests for deploying a containerized application. Your configuration must include a Deployment, Service, HorizontalPodAutoscaler, and Ingress. Given an application configuration, generate complete…
Sign in to solveEach node in a tree can be one of three types: 'Root': If the node is the root of the tree. 'Inner': If the node is neither a leaf nor a root. 'Leaf': If the node is a leaf node. Write a solution to report the type of each node in the Tree…
Sign in to solveRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M. | Symbol | Value | |--------|-------| | I | 1 | | V | 5 | | X | 10 | | L | 50 | | C | 100 | | D | 500 | | M | 1000 | For example, 2 is written as II in…
Sign in to solveGiven two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. Example 1: Example 2: 1 <= preorder.length…
Sign in to solveA Segment Tree is a powerful data structure that allows for efficient range queries and range updates. In this challenge, you will implement a Segment Tree that supports two operations on an array nums: update(l, r, val): Increment all…
Sign in to solve