319 challenges in the catalogue. Browse freely; sign in to open the editor and submit.
You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. Find the maximum profit you can achieve. You may complete as many transactions as you like, but…
Sign in to solveThe median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values. For example, for arr = [2,3,4], the median is 3. For example, for…
Sign in to solveYou are given an integer array prices where prices[i] is the price of a given stock on the ith day. On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can…
Sign in to solveWrite a solution to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on someday if they made at least one activity on that day. Return the result table in any order. | Column Name |…
Sign in to solveGiven an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never…
Sign in to solveThere are n cars going to the same destination along a one-lane road. The destination is target miles away. You are given two integer arrays position and speed, both of length n, where position[i] is the position of the ith car and…
Sign in to solveYou are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Example 2: Example 3: 1 <= n <= 45 Can you solve this in O(1)…
Sign in to solveGiven a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity.…
Sign in to solveImplement a complete JWT (JSON Web Token) authentication system for a Node.js/Express API. The system should handle user registration, login, token verification, token refresh, and protecting routes with authentication middleware. User…
Sign in to solveWrite a SQL query to compute the moving average of how much the customer paid in a seven-day window (current day + 6 days before). average_amount should be rounded to two decimal places. Return the result table ordered by visited_on in…
Sign in to solveGiven an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. A subarray is a…
Sign in to solveGiven two integers a and b, return the sum of the two integers without using the operators + and -. Input: a = 1, b = 2 Output: 3 Input: a = 2, b = 3 Output: 5 -1000 <= a, b <= 1000
Sign in to solve