Practice Arena
Solve exercises, validate code, earn scores and build a persistent proof-of-work history.
Calculate Running Total with SUM() OVER() (Variation #2)
### Calculate Running Total with SUM() OVER() (Variation #2) Compute cumulative running daily revenue using window aggregation. Write an optimal, production-ready solution adhering to SQL best practices and type boundaries.
Calculate Running Total with SUM() OVER() (Variation #3)
### Calculate Running Total with SUM() OVER() (Variation #3) Compute cumulative running daily revenue using window aggregation. Write an optimal, production-ready solution adhering to SQL best practices and type boundaries.
Calculate Running Total with SUM() OVER() (Variation #4)
### Calculate Running Total with SUM() OVER() (Variation #4) Compute cumulative running daily revenue using window aggregation. Write an optimal, production-ready solution adhering to SQL best practices and type boundaries.
Flatten Deeply Nested Arrays
Write a function `flattenArray(arr)` that takes an array containing arbitrarily nested arrays and returns a single, completely flat 1-dimensional array. ### Requirements: - Do not use built-in `Array.prototype.flat(Infinity)`. - Handle empty arrays, single numbers, and arrays nested 5+ levels deep. - Preserve the original ordering of elements.
Fix Async Closure Loop Bug
The provided function is intended to create an array of timer callbacks that print indices 0 through 4. However, due to `var` function-scoping, every callback prints `5`. Fix the code so that each callback retains its respective loop index `0, 1, 2, 3, 4`.
Implement Debounce Function
Implement a `debounce(fn, delay)` function. The returned debounced function should delay invoking `fn` until after `delay` milliseconds have elapsed since the last time the debounced function was called.
Two Sum in Linear Time
Given an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. ### Constraints: - Exactly one valid solution exists. - Time complexity must be O(N) using a dictionary lookup table.
Valid Parentheses Stack Validator
Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. An input string is valid if: 1. Open brackets are closed by the same type of brackets. 2. Open brackets are closed in the correct order. 3. Every close bracket has a corresponding open bracket.
Find Department Top Earners with DENSE_RANK
Write a SQL query to find all employees who earn the highest or second highest salary in their respective departments. Table `employees` columns: - `id` (INT) - `name` (VARCHAR) - `salary` (INT) - `department_id` (INT) Return columns `department_id`, `name`, `salary` ordered by `department_id ASC`, `salary DESC`.
Calculate 7-Day User Retention Cohort
Calculate the percentage of users who returned to perform an activity within 7 days of their initial signup date.
Implement Array.prototype.myMap Polyfill (Variation #1)
### Implement Array.prototype.myMap Polyfill (Variation #1) Write a custom polyfill for Array.map from scratch. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Implement Array.prototype.myMap Polyfill (Variation #2)
### Implement Array.prototype.myMap Polyfill (Variation #2) Write a custom polyfill for Array.map from scratch. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Implement Array.prototype.myMap Polyfill (Variation #3)
### Implement Array.prototype.myMap Polyfill (Variation #3) Write a custom polyfill for Array.map from scratch. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Implement Array.prototype.myMap Polyfill (Variation #4)
### Implement Array.prototype.myMap Polyfill (Variation #4) Write a custom polyfill for Array.map from scratch. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Deep Object Comparison (isEqual) (Variation #1)
### Deep Object Comparison (isEqual) (Variation #1) Compare two arbitrary nested objects for value equality. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Deep Object Comparison (isEqual) (Variation #2)
### Deep Object Comparison (isEqual) (Variation #2) Compare two arbitrary nested objects for value equality. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Deep Object Comparison (isEqual) (Variation #3)
### Deep Object Comparison (isEqual) (Variation #3) Compare two arbitrary nested objects for value equality. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.
Deep Object Comparison (isEqual) (Variation #4)
### Deep Object Comparison (isEqual) (Variation #4) Compare two arbitrary nested objects for value equality. Write an optimal, production-ready solution adhering to JavaScript best practices and type boundaries.