Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
557
8.41k
### Instruction: Title: Swap Nodes in Pairs Description: Given a linked list, swap every two adjacent nodes and return its head. Example 1: Input: head = [1,2,3,4] Output: [2,1,4,3] Example 2: Input: head = [] Output: [] Example 3: Input: head = [1] Output: [1] Constraints: The number of nodes in the list is in th...
### Instruction: Title: Convert Sorted List to Binary Search Tree Description: Given the `head` of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees o...
### Instruction: Title: Two Sum IV - Input is a BST Description: Given the `root` of a Binary Search Tree and a target number `k`, return `true` if there exist two elements in the BST such that their sum is equal to the given target. Example 1: Input: root = [5,3,6,2,4,null,7], k = 9 Output: true Example 2: Input: r...
### Instruction: Title: Cracking the Safe Description: There is a box protected by a password. The password is a sequence of `n` digits where each digit can be one of the first `k` digits `0, 1, ..., k-1`. While entering a password, the last `n` digits entered will automatically be matched against the correct password...
### Instruction: Title: Count All Valid Pickup and Delivery Options Description: Given `n` orders, each order consist in pickup and delivery services. Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). Since the answer may be too large, return it modulo 10^9 + 7. ...
### Instruction: Title: Hamming Distance Description: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers `x` and `y`, calculate the Hamming distance. Note: 0 ≤ `x`, `y` < 231. Example: Input: x = 1, y = 4 Output: 2 Explanation: 1 ...
### Instruction: Title: Equal Rational Numbers Description: Given two strings `s` and `t`, each of which represents a non-negative rational number, return `true` if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number. A rational number can be ...
### Instruction: Title: Minimum Falling Path Sum II Description: Given a square grid of integers `arr`, a falling path with non-zero shifts is a choice of exactly one element from each row of `arr`, such that no two elements chosen in adjacent rows are in the same column. Return the minimum sum of a falling path with ...
### Instruction: Title: Camelcase Matching Description: A query word matches a given `pattern` if we can insert lowercase letters to the pattern word so that it equals the `query`. (We may insert each character at any position, and may insert 0 characters.) Given a list of `queries`, and a `pattern`, return an `answer`...
### Instruction: Title: Two Sum Less Than K Description: Given an array `nums` of integers and integer `k`, return the maximum `sum` such that there exists `i < j` with `nums[i] + nums[j] = sum` and `sum < k`. If no `i`, `j` exist satisfying this equation, return `-1`. Example 1: Input: nums = [34,23,1,24,75,33,54,8]...
### Instruction: Title: Simplified Fractions Description: Given an integer `n`, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to `n`. The fractions can be in any order. Example 1: Input: n = 2 Output: ["1/2"] Explanation: "1/2" is the only unique...
### Instruction: Title: Next Greater Element II Description: Given a circular integer array `nums` (i.e., the next element of `nums[nums.length - 1]` is `nums[0]`), return the next greater number for every element in `nums`. The next greater number of a number `x` is the first greater number to its traversing-order ne...
### Instruction: Title: Count Vowels Permutation Description: Given an integer `n`, your task is to count how many strings of length `n` can be formed under the following rules: Each character is a lower case vowel (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`) Each vowel `'a'` may only be followed by an `'e'`. Each vowel `'e'` ...
### Instruction: Title: Before and After Puzzle Description: Given a list of `phrases`, generate a list of Before and After puzzles. A phrase is a string that consists of lowercase English letters and spaces only. No space appears in the start or the end of a phrase. There are no consecutive spaces in a phrase. Befor...
### Instruction: Title: Stone Game Description: Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones `piles[i]`. The objective of the game is to end with the most stones. The total number of stones is odd, so there a...
### Instruction: Title: Circular Array Loop Description: You are playing a game involving a circular array of non-zero integers `nums`. Each `nums[i]` denotes the number of indices forward/backward you must move if you are located at index `i`: If `nums[i]` is positive, move `nums[i]` steps forward, and If `nums[i]` is...
### Instruction: Title: Apply Discount Every n Orders Description: There is a sale in a supermarket, there will be a `discount` every `n` customer. There are some products in the supermarket where the id of the `i-th` product is `products[i]` and the price per unit of this product is `prices[i]`. The system will coun...
### Instruction: Title: Remove Duplicates from Sorted List II Description: Given the `head` of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Example 1: Input: head = [1,2,3,3,4,4,5] Output: [1,2,5] Exam...
### Instruction: Title: Numbers At Most N Given Digit Set Description: Given an array of `digits` which is sorted in non-decreasing order. You can write numbers using each `digits[i]` as many times as we want. For example, if `digits = ['1','3','5']`, we may write numbers such as `'13'`, `'551'`, and `'1351315'`. Retu...
### Instruction: Title: Flood Fill Description: An `image` is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate `(sr, sc)` representing the starting pixel (row and column) of the flood fill, and a pixel value `newColor`, "flood fill" th...
### Instruction: Title: To Lower Case Description: Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Input: "Hello" Output: "hello" Example 2: Input: "here" Output: "here" Example 3: Input: "LOVELY" Output: "lovely" Difficulty: Easy (Hint: Related...
### Instruction: Title: Add Two Numbers II Description: You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not conta...
### Instruction: Title: Snakes and Ladders Description: On an N x N `board`, the numbers from `1` to `N*N` are written boustrophedonically starting from the bottom left of the board, and alternating direction each row. For example, for a 6 x 6 board, the numbers are written as follows: You start on square `1` of the b...
### Instruction: Title: Maximum Performance of a Team Description: There are `n` engineers numbered from 1 to `n` and two arrays: `speed` and `efficiency`, where `speed[i]` and `efficiency[i]` represent the speed and efficiency for the i-th engineer respectively. Return the maximum performance of a team composed of at ...
### Instruction: Title: Smallest Range II Description: Given an array `A` of integers, for each integer `A[i]` we need to choose either `x = -K` or `x = K`, and add `x` to `A[i] (only once)`. After this process, we have some array `B`. Return the smallest possible difference between the maximum value of `B` and the m...
### Instruction: Title: Find the Town Judge Description: In a town, there are `N` people labelled from `1` to `N`. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is...
### Instruction: Title: Kth Missing Positive Number Description: Given an array `arr` of positive integers sorted in a strictly increasing order, and an integer `k`. Find the `kth` positive integer that is missing from this array. Example 1: Input: arr = [2,3,4,7,11], k = 5 Output: 9 Explanation: The missing positiv...
### Instruction: Title: 3Sum Smaller Description: Given an array of `n` integers `nums` and an integer `target`, find the number of index triplets `i`, `j`, `k` with `0 <= i < j < k < n` that satisfy the condition `nums[i] + nums[j] + nums[k] < target`. Follow up: Could you solve it in `O(n2)` runtime? Example 1: Inp...
### Instruction: Title: Maximum Value at a Given Index in a Bounded Array Description: You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (0-indexed) that satisfies the following conditions: `nums.length == n` `nums[i]` is a positive integer where `0 <= i < n`. `ab...
### Instruction: Title: Maximum Product of Three Numbers Description: Given an integer array `nums`, find three numbers whose product is maximum and return the maximum product. Example 1: Input: nums = [1,2,3] Output: 6 Example 2: Input: nums = [1,2,3,4] Output: 24 Example 3: Input: nums = [-1,-2,-3] Output: -6 Co...
### Instruction: Title: Shortest Palindrome Description: You are given a string `s`. You can convert `s` to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation. Example 1: Input: s = "aacecaaa" Output: "aaacecaaa" Example 2: Input: s = "abc...
### Instruction: Title: Sentence Similarity Description: We can represent a sentence as an array of words, for example, the sentence `"I am happy with leetcode"` can be represented as `arr = ["I","am",happy","with","leetcode"]`. Given two sentences `sentence1` and `sentence2` each represented as a string array and giv...
### Instruction: Title: Pacific Atlantic Water Flow Description: You are given an `m x n` integer matrix `heights` representing the height of each unit cell in a continent. The Pacific ocean touches the continent's left and top edges, and the Atlantic ocean touches the continent's right and bottom edges. Water can onl...
### Instruction: Title: Perfect Rectangle Description: Given an array `rectangles` where `rectangles[i] = [xi, yi, ai, bi]` represents an axis-aligned rectangle. The bottom-left point of the rectangle is `(xi, yi)` and the top-right point of it is `(ai, bi)`. Return `true` if all the rectangles together form an exact ...
### Instruction: Title: Subarray Product Less Than K Description: Your are given an array of positive integers `nums`. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than `k`. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 Explanation: Th...
### Instruction: Title: Shortest Path in a Grid with Obstacles Elimination Description: Given a `m * n` grid, where each cell is either `0` (empty) or `1` (obstacle). In one step, you can move up, down, left or right from and to an empty cell. Return the minimum number of steps to walk from the upper left corner `(0, ...
### Instruction: Title: Find K Closest Elements Description: Given a sorted integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ascending order. An integer `a` is closer to `x` than an integer `b` if: `|a - x| < |b - x|`, or `|a - x| =...
### Instruction: Title: Palindrome Permutation II Description: Given a string s, return all the palindromic permutations (without duplicates) of it. You may return the answer in any order. If `s` has no palindromic permutation, return an empty list. Example 1: Input: s = "aabb" Output: ["abba","baab"] Example 2: In...
### Instruction: Title: Count Nice Pairs in an Array Description: You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is nice if it satisfies all of the...
### Instruction: Title: Squares of a Sorted Array Description: Given an integer array `nums` sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: After squaring, the array becomes [16,1...
### Instruction: Title: Strange Printer Description: There is a strange printer with the following two special requirements: The printer can only print a sequence of the same character each time. At each turn, the printer can print new characters starting from and ending at any places, and will cover the original exis...
### Instruction: Title: Longest Increasing Path in a Matrix Description: Given an `m x n` integers `matrix`, return the length of the longest increasing path in `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wr...
### Instruction: Title: Degree of an Array Description: Given a non-empty array of non-negative integers `nums`, the degree of this array is defined as the maximum frequency of any one of its elements. Your task is to find the smallest possible length of a (contiguous) subarray of `nums`, that has the same degree as `...
### Instruction: Title: Frog Jump Description: A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of `stones`' positions (in units) in sorted ascending order, d...
### Instruction: Title: Design Underground System Description: An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from one station to another. Implement the `UndergroundSystem` class: `void checkI...
### Instruction: Title: Shortest Distance from All Buildings Description: You are given an `m x n` grid `grid` of values `0`, `1`, or `2`, where: each `0` marks an empty land that you can pass by freely, each `1` marks a building that you cannot pass through, and each `2` marks an obstacle that you cannot pass through....
### Instruction: Title: Water Bottles Description: Given `numBottles` full water bottles, you can exchange `numExchange` empty water bottles for one full water bottle. The operation of drinking a full water bottle turns it into an empty bottle. Return the maximum number of water bottles you can drink. Example 1: In...
### Instruction: Title: Accounts Merge Description: Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge these accounts. Two accounts ...
### Instruction: Title: Can You Eat Your Favorite Candy on Your Favorite Day? Description: You are given a (0-indexed) array of positive integers `candiesCount` where `candiesCount[i]` represents the number of candies of the `ith` type you have. You are also given a 2D array `queries` where `queries[i] = [favoriteTypei...
### Instruction: Title: Longest Happy Prefix Description: A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself). Given a string `s`. Return the longest happy prefix of `s` . Return an empty string if no such prefix exists. Example 1: Input: s = "level" Output: "l" Expl...
### Instruction: Title: Insert Delete GetRandom O(1) Description: Implement the `RandomizedSet` class: `RandomizedSet()` Initializes the `RandomizedSet` object. `bool insert(int val)` Inserts an item `val` into the set if not present. Returns `true` if the item was not present, `false` otherwise. `bool remove(int val...
### Instruction: Title: Insert Interval Description: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Input: intervals = [[1,3],[6,9]], newInterval = [2,5] Output...
### Instruction: Title: Number of Different Subsequences GCDs Description: You are given an array `nums` that consists of positive integers. The GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly. For example, the GCD of the sequence `[4,6,16]` is `2`. ...
### Instruction: Title: Invert Binary Tree Description: Given the `root` of a binary tree, invert the tree, and return its root. Example 1: Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: Input: root = [2,1,3] Output: [2,3,1] Example 3: Input: root = [] Output: [] Constraints: The number of nodes ...
### Instruction: Title: Trim a Binary Search Tree Description: Given the `root` of a binary search tree and the lowest and highest boundaries as `low` and `high`, trim the tree so that all its elements lies in `[low, high]`. Trimming the tree should not change the relative structure of the elements that will remain in ...
### Instruction: Title: Number of Sub-arrays With Odd Sum Description: Given an array of integers `arr`. Return the number of sub-arrays with odd sum. As the answer may grow large, the answer must be computed modulo `10^9 + 7`. Example 1: Input: arr = [1,3,5] Output: 4 Explanation: All sub-arrays are [[1],[1,3],[1,3...
### Instruction: Title: Minimum Possible Integer After at Most K Adjacent Swaps On Digits Description: Given a string `num` representing the digits of a very large integer and an integer `k`. You are allowed to swap any two adjacent digits of the integer at most `k` times. Return the minimum integer you can obtain al...
### Instruction: Title: Brace Expansion II Description: Under a grammar given below, strings can represent a set of lowercase words. Let's use `R(expr)` to denote the set of words the expression represents. Grammar can best be understood through simple examples: Single letters represent a singleton set containing tha...
### Instruction: Title: Check If a Word Occurs As a Prefix of Any Word in a Sentence Description: Given a `sentence` that consists of some words separated by a single space, and a `searchWord`. You have to check if `searchWord` is a prefix of any word in `sentence`. Return the index of the word in `sentence` where `s...
### Instruction: Title: Scramble String Description: We can scramble a string s to get a string t using the following algorithm: If the length of the string is 1, stop. If the length of the string is > 1, do the following: Split the string into two non-empty substrings at a random index, i.e., if the string is `s`, ...
### Instruction: Title: Valid Palindrome Description: Given a string `s`, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "rac...
### Instruction: Title: Furthest Building You Can Reach Description: You are given an integer array `heights` representing the heights of buildings, some `bricks`, and some `ladders`. You start your journey from building `0` and move to the next building by possibly using bricks or ladders. While moving from building...
### Instruction: Title: Delete Leaves With a Given Value Description: Given a binary tree `root` and an integer `target`, delete all the leaf nodes with value `target`. Note that once you delete a leaf node with value `target`, if it's parent node becomes a leaf node and has the value `target`, it should also be delet...
### Instruction: Title: Find Kth Largest XOR Coordinate Value Description: You are given a 2D `matrix` of size `m x n`, consisting of non-negative integers. You are also given an integer `k`. The value of coordinate `(a, b)` of the matrix is the XOR of all `matrix[i][j]` where `0 <= i <= a < m` and `0 <= j <= b < n` (...
### Instruction: Title: Max Sum of Rectangle No Larger Than K Description: Given an `m x n` matrix `matrix` and an integer `k`, return the max sum of a rectangle in the matrix such that its sum is no larger than `k`. It is guaranteed that there will be a rectangle with a sum no larger than `k`. Example 1: Input: mat...
### Instruction: Title: Count Univalue Subtrees Description: Given the `root` of a binary tree, return the number of uni-value subtrees. A uni-value subtree means all nodes of the subtree have the same value. Example 1: Input: root = [5,1,5,5,5,null,5] Output: 4 Example 2: Input: root = [] Output: 0 Example 3: Inp...
### Instruction: Title: Maximize Number of Nice Divisors Description: You are given a positive integer `primeFactors`. You are asked to construct a positive integer `n` that satisfies the following conditions: The number of prime factors of `n` (not necessarily distinct) is at most `primeFactors`. The number of nice d...
### Instruction: Title: Reduce Array Size to The Half Description: Given an array `arr`. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integers of the array are removed. Example 1: Input: arr = [3,3,3,3...
### Instruction: Title: Find All The Lonely Nodes Description: In a binary tree, a lonely node is a node that is the only child of its parent node. The root of the tree is not lonely because it does not have a parent node. Given the `root` of a binary tree, return an array containing the values of all lonely nodes in ...
### Instruction: Title: Change Minimum Characters to Satisfy One of Three Conditions Description: You are given two strings `a` and `b` that consist of lowercase letters. In one operation, you can change any character in `a` or `b` to any lowercase letter. Your goal is to satisfy one of the following three conditions:...
### Instruction: Title: Design Circular Deque Description: Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations: `MyCircularDeque(k)`: Constructor, set the size of the deque to be k. `insertFront()`: Adds an item at the front of Deque. Return t...
### Instruction: Title: Surrounded Regions Description: Given an `m x n` matrix `board` containing `'X'` and `'O'`, capture all regions surrounded by `'X'`. A region is captured by flipping all `'O'`s into `'X'`s in that surrounded region. Example 1: Input: board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","...
### Instruction: Title: IP to CIDR Description: Given a start IP address `ip` and a number of ips we need to cover `n`, return a representation of the range as a list (of smallest possible length) of CIDR blocks. A CIDR block is a string consisting of an IP, followed by a slash, and then the prefix length. For exampl...
### Instruction: Title: Reverse String II Description: Given a string `s` and an integer `k`, reverse the first `k` characters for every `2k` characters counting from the start of the string. If there are fewer than `k` characters left, reverse all of them. If there are less than `2k` but greater than or equal to `k` ...
### Instruction: Title: Valid Word Abbreviation Description: Given a non-empty string `s` and an abbreviation `abbr`, return whether the string matches with the given abbreviation. A string such as `"word"` contains only the following valid abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "...
### Instruction: Title: Search in a Binary Search Tree Description: You are given the `root` of a binary search tree (BST) and an integer `val`. Find the node in the BST that the node's value equals `val` and return the subtree rooted with that node. If such a node does not exist, return `null`. Example 1: Input: ro...
### Instruction: Title: Distinct Subsequences Description: Given two strings `s` and `t`, return the number of distinct subsequences of `s` which equals `t`. A string's subsequence is a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characte...
### Instruction: Title: Target Sum Description: You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols `+` and `-`. For each integer, you should choose one from `+` and `-` as its new symbol. Find out how many ways to assign symbols to make sum of integers equal to targ...
### Instruction: Title: Bricks Falling When Hit Description: You are given an `m x n` binary `grid`, where each `1` represents a brick and `0` represents an empty space. A brick is stable if: It is directly connected to the top of the grid, or At least one other brick in its four adjacent cells is stable. You are also...
### Instruction: Title: Reverse Words in a String II Description: Given a character array `s`, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in `s` will be separated by a single space. Example 1: Input: s = ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u",...
### Instruction: Title: Count Pairs With XOR in a Range Description: Given a (0-indexed) integer array `nums` and two integers `low` and `high`, return the number of nice pairs. A nice pair is a pair `(i, j)` where `0 <= i < j < nums.length` and `low <= (nums[i] XOR nums[j]) <= high`. Example 1: Input: nums = [1,4,2...
### Instruction: Title: Rotting Oranges Description: You are given an `m x n` `grid` where each cell can have one of three values: `0` representing an empty cell, `1` representing a fresh orange, or `2` representing a rotten orange. Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange bec...
### Instruction: Title: Check if Number is a Sum of Powers of Three Description: Given an integer `n`, return `true` if it is possible to represent `n` as the sum of distinct powers of three. Otherwise, return `false`. An integer `y` is a power of three if there exists an integer `x` such that `y == 3x`. Example 1: ...
### Instruction: Title: Find Elements in a Contaminated Binary Tree Description: Given a binary tree with the following rules: `root.val == 0` If `treeNode.val == x` and `treeNode.left != null`, then `treeNode.left.val == 2 * x + 1` If `treeNode.val == x` and `treeNode.right != null`, then `treeNode.right.val == 2 * x ...
### Instruction: Title: Array of Doubled Pairs Description: Given an array of integers `arr` of even length, return `true` if and only if it is possible to reorder it such that `arr[2 * i + 1] = 2 * arr[2 * i]` for every `0 <= i < len(arr) / 2`. Example 1: Input: arr = [3,1,3,6] Output: false Example 2: Input: arr =...
### Instruction: Title: Count The Repetitions Description: Define `S = [s,n]` as the string S which consists of n connected strings s. For example, `["abc", 3]` ="abcabcabc". On the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For...
### Instruction: Title: Flip String to Monotone Increasing Description: A string of `'0'`s and `'1'`s is monotone increasing if it consists of some number of `'0'`s (possibly 0), followed by some number of `'1'`s (also possibly 0.) We are given a string `S` of `'0'`s and `'1'`s, and we may flip any `'0'` to a `'1'` or ...
### Instruction: Title: Substring with Concatenation of All Words Description: You are given a string `s` and an array of strings `words` of the same length. Return all starting indices of substring(s) in `s` that is a concatenation of each word in `words` exactly once, in any order, and without any intervening charact...
### Instruction: Title: Product of Array Except Self Description: Given an integer array `nums`, return an array `answer` such that `answer[i]` is equal to the product of all the elements of `nums` except `nums[i]`. The product of any prefix or suffix of `nums` is guaranteed to fit in a 32-bit integer. Example 1: In...
### Instruction: Title: Previous Permutation With One Swap Description: Given an array of positive integers `arr` (not necessarily distinct), return the lexicographically largest permutation that is smaller than `arr`, that can be made with exactly one swap (A swap exchanges the positions of two numbers `arr[i]` and `a...
### Instruction: Title: Count Ways to Distribute Candies Description: There are `n` unique candies (labeled `1` through `n`) and `k` bags. You are asked to distribute all the candies into the bags such that every bag has at least one candy. There can be multiple ways to distribute the candies. Two ways are considered ...
### Instruction: Title: Pseudo-Palindromic Paths in a Binary Tree Description: Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of pseudo-palindromic pat...
### Instruction: Title: Element Appearing More Than 25% In Sorted Array Description: Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time. Return that integer. Example 1: Input: arr = [1,2,2,6,6,6,6,7,10] Output: 6 Constraints: `1 <= ...
### Instruction: Title: Longest Valid Parentheses Description: Given a string containing just the characters `'('` and `')'`, find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()". Example 2: Input...
### Instruction: Title: Maximum Score Words Formed by Letters Description: Given a list of `words`, list of single `letters` (might be repeating) and `score` of every character. Return the maximum score of any valid set of words formed by using the given letters (`words[i]` cannot be used two or more times). It is n...
### Instruction: Title: Summary Ranges Description: You are given a sorted unique integer array `nums`. Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of `nums` is covered by exactly one of the ranges, and there is no integer `x` such that `x` is in one...
### Instruction: Title: Campus Bikes Description: On a campus represented as a 2D grid, there are `N` workers and `M` bikes, with `N <= M`. Each worker and bike is a 2D coordinate on this grid. Our goal is to assign a bike to each worker. Among the available bikes and workers, we choose the (worker, bike) pair with th...
### Instruction: Title: Minimum Difference Between Largest and Smallest Value in Three Moves Description: Given an array `nums`, you are allowed to choose one element of `nums` and change it by any value in one move. Return the minimum difference between the largest and smallest value of `nums` after perfoming at most...
### Instruction: Title: K-Concatenation Maximum Sum Description: Given an integer array `arr` and an integer `k`, modify the array by repeating it `k` times. For example, if `arr = [1, 2]` and `k = 3 `then the modified array will be `[1, 2, 1, 2, 1, 2]`. Return the maximum sub-array sum in the modified array. Note th...
### Instruction: Title: X of a Kind in a Deck of Cards Description: In a deck of cards, each card has an integer written on it. Return `true` if and only if you can choose `X >= 2` such that it is possible to split the entire deck into 1 or more groups of cards, where: Each group has exactly `X` cards. All the cards ...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3

Models trained or fine-tuned on SahibJParmar/Leetcode