Longest Arithmetic Subsequence with Difference Constraint
Given a list of integers nums and an integer diff, return the length of the longest arithmetic subsequence where the difference between each consecutive numb...
Given a list of integers nums and an integer diff, return the length of the longest arithmetic subsequence where the difference between each consecutive numb...
You are given an integer n representing the number of seats in an airplane. The first person has lost their ticket, so they pick a random seat. Everyone else...
Given a list of integers nums, return the number of sublists where the first element and the last element have the same value.
You are given a string s containing "1"s and "0"s. Return the number of substrings that contain only "1"s. Mod the result by 10 ** 9 + 7.
Given an integer n, return whether its prime factors only include 2, 3 or 5.
Given a positive integer num, return the sum of its digits.
Given an integer n, return the sum of the first n positive odd integers.
Consider a complete binary tree of n nodes whose values are 1 to n. The root has value of 1, its left child is 2 and its right child is 3. In general, nodes’...
You can write out a number as a product of prime numbers, which are its prime factors. The same prime factor may occur more than once.
Given a non-negative integer num, return whether it is a palindrome.
You’ve got an integer n representing a chessboard of size n x n. Return the number of ways you can place n rooks, such that no two rooks attack each other.
Given a list of integers nums, split it into two lists of equal size where the absolute difference between each list’s median is as small as possible and ret...
You are given a list of integers nums, and want to make the values equal. Consider an operation where you pick an integer in the list and increment every oth...
Given a single linked list node, representing a binary number with most significant digits first, return it as an integer.
Given a list of [x, y] coordinates in a Cartesian plane, return whether the coordinates form a straight line segment.
You are given integers n, a and b. You are standing in a line of n people. You don’t know which position you’re in, but you know there are at least a people ...
Given an integer n, return its base 3 representation as a string.
Given a non-negative integer n, find a number r such that r * r = n and round down to the nearest integer.
Given a list of positive integers nums, return the largest positive integer that divides each of the integers.
Given a number n, return a list of all prime numbers smaller than or equal to n in ascending order.
You are playing a game against a friend where in each round you pick a number from 1 to k to add to a shared running total that initially starts from 0. The ...
Given a positive integer n, return whether n can be written as the sum of distinct positive factorial numbers.
You are given a list nums of length n + 1 picked from the range 1, 2, ..., n. By the pigeonhole principle, there must be a duplicate. Find and return it. The...
You are given a list of integers nums that used to be an arithmetic sequence. Given that a number was removed, and that the number was not the first or the l...
Given a clock time with hour and integer minutes, determine the smaller angle between the hour and the minute hands and floor it to the nearest integer.
Given an integer n, return whether n = k * k for some integer k.
Given a string s representing a number in base 3 (consisting only of 0, 1, or 2), return its decimal integer equivalent. This should be implemented directly ...