Search is not available for this dataset
source stringclasses 2
values | task_type stringclasses 1
value | in_source_id stringlengths 1 88 | prompt stringlengths 241 14.3k | gold_standard_solution stringlengths 0 30.1k ⌀ | verification_info stringlengths 88 74M | metadata stringlengths 62 154 | problem_id stringlengths 5 9 |
|---|---|---|---|---|---|---|---|
apps | verifiable_code | 334 | Solve the following coding problem using the programming language Python:
Given a string s and an array of integers cost where cost[i] is the cost of deleting the ith character in s.
Return the minimum cost of deletions such that there are no two identical letters next to each other.
Notice that you will delete the ch... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minCost', 'input': ['"abaac"', [1, 2, 3, 4, 5]], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters/'} | vfc_700 |
apps | verifiable_code | 335 | Solve the following coding problem using the programming language Python:
You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.
You have a collection of rods which can be welded together. For e... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'tallestBillboard', 'input': [[1, 2, 3, 6]], 'output': 6}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/tallest-billboard/'} | vfc_701 |
apps | verifiable_code | 336 | Solve the following coding problem using the programming language Python:
Given two equal-size strings s and t. In one step you can choose any character of t and replace it with another character.
Return the minimum number of steps to make t an anagram of s.
An Anagram of a string is a string that contains the same ch... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minSteps', 'input': ['"bab"', '"aba"'], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/'} | vfc_702 |
apps | verifiable_code | 337 | Solve the following coding problem using the programming language Python:
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].
You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey wit... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'canCompleteCircuit', 'input': [[1, 2, 3, 4, 5], [3, 4, 5, 1, 2]], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/gas-station/'} | vfc_703 |
apps | verifiable_code | 338 | Solve the following coding problem using the programming language Python:
Given the strings s1 and s2 of size n, and the string evil. Return the number of good strings.
A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findGoodStrings', 'input': [2, '"aa"', '"da"', '"b"'], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-all-good-strings/'} | vfc_704 |
apps | verifiable_code | 339 | Solve the following coding problem using the programming language Python:
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Type 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.l... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numTriplets', 'input': [[7, 4], [5, 2, 8, 9]], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/'} | vfc_705 |
apps | verifiable_code | 340 | Solve the following coding problem using the programming language Python:
Given an absolute path for a file (Unix-style), simplify it.
For example,
path = "/home/", => "/home"
path = "/a/./b/../../c/", => "/c"
Corner Cases:
Did you consider the case where path = "/../"?
In this case, you should retur... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'simplifyPath', 'input': ['"/home/"'], 'output': '/"/home/"'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/simplify-path/'} | vfc_706 |
apps | verifiable_code | 341 | Solve the following coding problem using the programming language Python:
Write a program to find the n-th ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
Example:
Input: n = 10
Output: 12
Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly num... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'nthUglyNumber', 'input': [10], 'output': 12}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/ugly-number-ii/'} | vfc_707 |
apps | verifiable_code | 342 | Solve the following coding problem using the programming language Python:
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:
You receive a valid board, made of only battleships or empty slots.
... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'countBattleships', 'input': [[['"X"', '"."', '"."', '"X"'], ['"."', '"."', '"."', '"X"'], ['"."', '"."', '"."', '"X"'], [], []]], 'output': 0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/battleships-in-a-board/'} | vfc_708 |
apps | verifiable_code | 343 | Solve the following coding problem using the programming language Python:
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.
Example 1:
Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4.
Example 2:
Input: n = 13
Output: 2
Explanation: 13... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numSquares', 'input': [12], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/perfect-squares/'} | vfc_709 |
apps | verifiable_code | 344 | Solve the following coding problem using the programming language Python:
We are given an array A of N lowercase letter strings, all of the same length.
Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
For example, if we have an array A = ["babca","bba... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minDeletionSize', 'input': [['"babca"', '"bbazb"']], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/delete-columns-to-make-sorted-iii/'} | vfc_710 |
apps | verifiable_code | 345 | Solve the following coding problem using the programming language Python:
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays.
Note:
If n is the length of array, ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'splitArray', 'input': [[7, 2, 5, 10, 8], 2], 'output': 18}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/split-array-largest-sum/'} | vfc_711 |
apps | verifiable_code | 346 | Solve the following coding problem using the programming language Python:
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
Return the number of nice sub-arrays.
Example 1:
Input: nums = [1,1,2,1,1], k = 3
Output: 2
Explanation: The only sub-arra... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numberOfSubarrays', 'input': [[1, 1, 2, 1, 1], 3], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/count-number-of-nice-subarrays/'} | vfc_712 |
apps | verifiable_code | 347 | Solve the following coding problem using the programming language Python:
Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the substring of the second string.
Example 1:
Input:s1 = "ab" s2 = "eidbaooo"
Output:... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'checkInclusion', 'input': ['"ab"', '"eidbaooo"'], 'output': False}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/permutation-in-string/'} | vfc_713 |
apps | verifiable_code | 348 | Solve the following coding problem using the programming language Python:
Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still a... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maximumSum', 'input': [[1, -2, 0, 3]], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/'} | vfc_714 |
apps | verifiable_code | 349 | Solve the following coding problem using the programming language Python:
Given an array nums of integers, you can perform operations on the array.
In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to nums[i] - 1 or nums[i] + 1.
You start with 0... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'deleteAndEarn', 'input': [[2, 3, 4]], 'output': 6}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/delete-and-earn/'} | vfc_715 |
apps | verifiable_code | 350 | Solve the following coding problem using the programming language Python:
Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K.
(For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.)
Return t... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'subarraysWithKDistinct', 'input': [[1, 2, 1, 2, 3], 2], 'output': 7}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/subarrays-with-k-different-integers/'} | vfc_716 |
apps | verifiable_code | 351 | Solve the following coding problem using the programming language Python:
On a broken calculator that has a number showing on its display, we can perform two operations:
Double: Multiply the number on the display by 2, or;
Decrement: Subtract 1 from the number on the display.
Initially, the calculator is displaying ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'brokenCalc', 'input': [2, 3], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/broken-calculator/'} | vfc_717 |
apps | verifiable_code | 352 | Solve the following coding problem using the programming language Python:
Given a list of words, each word consists of English lowercase letters.
Let's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'longestStrChain', 'input': [['"a"', '"b"', '"ba"', '"bca"', '"bda"', '"bdca"']], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/longest-string-chain/'} | vfc_718 |
apps | verifiable_code | 353 | Solve the following coding problem using the programming language Python:
Given an array of integers nums and an integer target.
Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal than target.
Since the answer may be too large, return it modu... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numSubseq', 'input': [[3, 5, 6, 7], 9], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/'} | vfc_719 |
apps | verifiable_code | 354 | Solve the following coding problem using the programming language Python:
A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times.
Given an array of integers rollMax and a... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'dieSimulator', 'input': [2, [1, 1, 2, 2, 2, 3]], 'output': 34}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/dice-roll-simulation/'} | vfc_720 |
apps | verifiable_code | 355 | Solve the following coding problem using the programming language Python:
Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.
Note: 1 ≤ k ≤ n ≤ 109.
Example:
Input:
n: 13 k: 2
Output:
10
Explanation:
The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findKthNumber', 'input': [13, 2], 'output': 10}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/'} | vfc_721 |
apps | verifiable_code | 356 | Solve the following coding problem using the programming language Python:
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted from left to right.
The first integer of each row is greater than the last integ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'searchMatrix', 'input': [[[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 50], [], []], 3], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/search-a-2d-matrix/'} | vfc_722 |
apps | verifiable_code | 357 | Solve the following coding problem using the programming language Python:
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
There is at least one empty seat, and at least one person sitt... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maxDistToClosest', 'input': [[1, 0, 0, 0, 1, 0, 1]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/maximize-distance-to-closest-person/'} | vfc_723 |
apps | verifiable_code | 358 | Solve the following coding problem using the programming language Python:
To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).
Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. Th... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findReplaceString', 'input': ['"abcd"', [0, 2], ['"a"', ' "cd"'], ['"eee"', ' "ffff"']], 'output': '"abcd"'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-and-replace-in-string/'} | vfc_724 |
apps | verifiable_code | 359 | Solve the following coding problem using the programming language Python:
Given a square array of integers A, we want the minimum sum of a falling path through A.
A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different f... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minFallingPathSum', 'input': [[[1, 2, 3], [4, 5, 6], [7, 8, 9], [], []]], 'output': 12}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-falling-path-sum/'} | vfc_725 |
apps | verifiable_code | 360 | Solve the following coding problem using the programming language Python:
A conveyor belt has packages that must be shipped from one port to another within D days.
The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by wei... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'shipWithinDays', 'input': [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5], 'output': 15}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/'} | vfc_726 |
apps | verifiable_code | 361 | Solve the following coding problem using the programming language Python:
Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile the rectangle.
Example 1:
Input: n = 2, m = 3
Output: 3
Explanation: 3 squares are necessary to cover the rectangle.
2 (squares of 1x1)
1 (square of 2... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'tilingRectangle', 'input': [2, 3], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/'} | vfc_727 |
apps | verifiable_code | 362 | Solve the following coding problem using the programming language Python:
There are n people and 40 types of hats labeled from 1 to 40.
Given a list of list of integers hats, where hats[i] is a list of all hats preferred by the i-th person.
Return the number of ways that the n people wear different hats to each other.... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numberWays', 'input': [[[3, 4], [4, 5], [5], [], []]], 'output': 0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other/'} | vfc_728 |
apps | verifiable_code | 363 | Solve the following coding problem using the programming language Python:
Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)
A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.
Return the number of land squares in the grid... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numEnclaves', 'input': [[[0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [], []]], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-enclaves/'} | vfc_729 |
apps | verifiable_code | 364 | Solve the following coding problem using the programming language Python:
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available.
You need to determine whether it is possible to measure exactly z litres using these two jugs.
If z liters of water is measurable, you... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'canMeasureWater', 'input': [3, 5, 4], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/water-and-jug-problem/'} | vfc_730 |
apps | verifiable_code | 365 | Solve the following coding problem using the programming language Python:
Let's define a function countUniqueChars(s) that returns the number of unique characters on s, for example if s = "LEETCODE" then "L", "T","C","O","D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'uniqueLetterString', 'input': ['"ABC"'], 'output': 33}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/'} | vfc_731 |
apps | verifiable_code | 366 | Solve the following coding problem using the programming language Python:
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.
Example 1:
Input:
s = "aaabb", k = 3
Output:
3
The longest substring is "aaa", as... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'longestSubstring', 'input': ['"aaabb"', 3], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/'} | vfc_732 |
apps | verifiable_code | 367 | Solve the following coding problem using the programming language Python:
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
Example 1:
Input: [1... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findDuplicate', 'input': [[1, 3, 4, 2, 2]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-the-duplicate-number/'} | vfc_733 |
apps | verifiable_code | 368 | Solve the following coding problem using the programming language Python:
A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfactio... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maxSatisfaction', 'input': [[-8, -7, -1, 0, 5]], 'output': 14}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/reducing-dishes/'} | vfc_734 |
apps | verifiable_code | 369 | Solve the following coding problem using the programming language Python:
Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbours of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighboors if they share one edge.
Return the mini... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minFlips', 'input': [[[0, 0], [0, 1], [], []]], 'output': 5}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/'} | vfc_735 |
apps | verifiable_code | 370 | Solve the following coding problem using the programming language Python:
Given a non-empty array of unique positive integers A, consider the following graph:
There are A.length nodes, labelled A[0] to A[A.length - 1];
There is an edge between A[i] and A[j] if and only if A[i] and A[j] share a common factor greater t... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'largestComponentSize', 'input': [[4, 6, 15, 35]], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/largest-component-size-by-common-factor/'} | vfc_736 |
apps | verifiable_code | 371 | Solve the following coding problem using the programming language Python:
We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the sequence 1->5->7->1->5->7->1->... forever.
We start ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numBusesToDestination', 'input': [[[1, 2, 7], [3, 6, 7], [], []], 1, 6], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/bus-routes/'} | vfc_737 |
apps | verifiable_code | 372 | Solve the following coding problem using the programming language Python:
Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'isMatch', 'input': ['"aa"', '"a"'], 'output': False}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/regular-expression-matching/'} | vfc_738 |
apps | verifiable_code | 373 | Solve the following coding problem using the programming language Python:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most k transactions.
Note:
You may not engage in multiple transactions at the same time... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maxProfit', 'input': [2, [2, 4, 1]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/'} | vfc_739 |
apps | verifiable_code | 374 | Solve the following coding problem using the programming language Python:
Given an array A of strings, find any smallest string that contains each string in A as a substring.
We may assume that no string in A is substring of another string in A.
Example 1:
Input: ["alex","loves","leetcode"]
Output: "alexlovesleetco... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'shortestSuperstring', 'input': [['"alex"', '"loves"', '"leetcode"']], 'output': '"leetcode"loves"alex"'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-the-shortest-superstring/'} | vfc_740 |
apps | verifiable_code | 375 | Solve the following coding problem using the programming language Python:
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.
Return 0 if the array contains less than 2 elements.
Example 1:
Input: [3,6,9,1]
Output: 3
Explanation: The sorted form of the array is ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maximumGap', 'input': [[3, 6, 9, 1]], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/maximum-gap/'} | vfc_741 |
apps | verifiable_code | 376 | Solve the following coding problem using the programming language Python:
Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], ..., A[N-1] in clockwise order.
Suppose you triangulate the polygon into N-2 triangles. For each triangle, the value of that triangle is the product of the labels of ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minScoreTriangulation', 'input': [[1, 2, 3]], 'output': 6}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-score-triangulation-of-polygon/'} | vfc_742 |
apps | verifiable_code | 377 | Solve the following coding problem using the programming language Python:
A positive integer is magical if it is divisible by either A or B.
Return the N-th magical number. Since the answer may be very large, return it modulo 10^9 + 7.
Example 1:
Input: N = 1, A = 2, B = 3
Output: 2
Example 2:
Input: N = 4, A ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'nthMagicalNumber', 'input': [1, 2, 3], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/nth-magical-number/'} | vfc_743 |
apps | verifiable_code | 378 | Solve the following coding problem using the programming language Python:
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.
Note:
Each of the array element will not exceed 100.
The array size will ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'canPartition', 'input': [[1, 5, 5, 11]], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/partition-equal-subset-sum/'} | vfc_744 |
apps | verifiable_code | 379 | Solve the following coding problem using the programming language Python:
You are given two sorted arrays of distinct integers nums1 and nums2.
A valid path is defined as follows:
Choose array nums1 or nums2 to traverse (from index-0).
Traverse the current array from left to right.
If you are reading any value that i... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maxSum', 'input': [[2, 4, 5, 8, 10], [4, 6, 8, 9]], 'output': 30}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/get-the-maximum-score/'} | vfc_745 |
apps | verifiable_code | 380 | Solve the following coding problem using the programming language Python:
Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.
IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, sepa... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'validIPAddress', 'input': ['"172.16.254.1"'], 'output': 'Neither'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/validate-ip-address/'} | vfc_746 |
apps | verifiable_code | 381 | Solve the following coding problem using the programming language Python:
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.
Example:
Input: s = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: t... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minSubArrayLen', 'input': [7, [2, 3, 1, 2, 4, 3]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-size-subarray-sum/'} | vfc_747 |
apps | verifiable_code | 382 | Solve the following coding problem using the programming language Python:
A peak element is an element that is greater than its neighbors.
Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findPeakElement', 'input': [[1, 2, 3, 1]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-peak-element/'} | vfc_748 |
apps | verifiable_code | 383 | Solve the following coding problem using the programming language Python:
(This problem is the same as Minimize Malware Spread, with the differences bolded.)
In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j] = 1.
Some nodes initial are initially infected by malware. ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minMalwareSpread', 'input': [[[1, 1, 0], [1, 1, 0], [0, 0, 1], [], []], [0, 1]], 'output': 0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimize-malware-spread-ii/'} | vfc_749 |
apps | verifiable_code | 384 | Solve the following coding problem using the programming language Python:
Given an array of integers A, consider all non-empty subsequences of A.
For any sequence S, let the width of S be the difference between the maximum and minimum element of S.
Return the sum of the widths of all subsequences of A.
As the answer ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'sumSubseqWidths', 'input': [[1, 2, 3]], 'output': 6}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/sum-of-subsequence-widths/'} | vfc_750 |
apps | verifiable_code | 385 | Solve the following coding problem using the programming language Python:
Given two positive integers n and k.
A factor of an integer n is defined as an integer i where n % i == 0.
Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factor... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'kthFactor', 'input': [12, 3], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/the-kth-factor-of-n/'} | vfc_751 |
apps | verifiable_code | 386 | Solve the following coding problem using the programming language Python:
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' may onl... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'countVowelPermutation', 'input': [1], 'output': 5}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/count-vowels-permutation/'} | vfc_752 |
apps | verifiable_code | 387 | Solve the following coding problem using the programming language Python:
In a special ranking system, each voter gives a rank from highest to lowest to all teams participated in the competition.
The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first positio... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'rankTeams', 'input': [['"ABC"', '"ACB"', '"ABC"', '"ACB"', '"ACB"']], 'output': '"ACB'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/rank-teams-by-votes/'} | vfc_753 |
apps | verifiable_code | 388 | Solve the following coding problem using the programming language Python:
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.
According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'hIndex', 'input': [[0, 1, 3, 5, 6]], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/h-index/'} | vfc_754 |
apps | verifiable_code | 389 | Solve the following coding problem using the programming language Python:
In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)
Return true if and only if after such a move, it is possible that the average value of B is equal to the average value of C,... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'splitArraySameAverage', 'input': [[1, 2, 3, 4, 5, 6, 7, 8]], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/split-array-with-same-average/'} | vfc_755 |
apps | verifiable_code | 390 | Solve the following coding problem using the programming language Python:
Alice and Bob take turns playing a game, with Alice starting first.
Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.
Also, if a pla... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'winnerSquareGame', 'input': [1], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/stone-game-iv/'} | vfc_756 |
apps | verifiable_code | 391 | Solve the following coding problem using the programming language Python:
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 bec... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'getMaxRepetitions', 'input': ['"acb"', 4, '"ab"', 2], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/count-the-repetitions/'} | vfc_757 |
apps | verifiable_code | 392 | Solve the following coding problem using the programming language Python:
Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s).
Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numWays', 'input': ['"10101"'], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-ways-to-split-a-string/'} | vfc_758 |
apps | verifiable_code | 393 | Solve the following coding problem using the programming language Python:
Write a program to find the n-th ugly number.
Ugly numbers are positive integers which are divisible by a or b or c.
Example 1:
Input: n = 3, a = 2, b = 3, c = 5
Output: 4
Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'nthUglyNumber', 'input': [3, 2, 3, 5], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/ugly-number-iii/'} | vfc_759 |
apps | verifiable_code | 394 | Solve the following coding problem using the programming language Python:
Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.
You may assume the array's length is at m... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minMoves2', 'input': [[1, 2, 3]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/'} | vfc_760 |
apps | verifiable_code | 395 | Solve the following coding problem using the programming language Python:
You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered j... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'oddEvenJumps', 'input': [[10, 13, 12, 14, 15]], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/odd-even-jump/'} | vfc_761 |
apps | verifiable_code | 396 | Solve the following coding problem using the programming language Python:
Given a positive integer K, you need find the smallest positive integer N such that N is divisible by K, and N only contains the digit 1.
Return the length of N. If there is no such N, return -1.
Example 1:
Input: 1
Output: 1
Explanation: The... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'smallestRepunitDivByK', 'input': [1], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/smallest-integer-divisible-by-k/'} | vfc_762 |
apps | verifiable_code | 397 | Solve the following coding problem using the programming language Python:
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.
Example:
Input: 13
Output: 6
Explanation: Digit 1 occurred in the following numbers: 1, 10, 11, 12, 13.
Write your solutio... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'countDigitOne', 'input': [13], 'output': 6}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-digit-one/'} | vfc_763 |
apps | verifiable_code | 398 | Solve the following coding problem using the programming language Python:
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example 1:
Input:nums = [1,1,1], k = 2
Output: 2
Note:
The length of the array is in range [1, 20,000].
The range... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'subarraySum', 'input': [[1, 1, 1], 2], 'output': 2}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/subarray-sum-equals-k/'} | vfc_764 |
apps | verifiable_code | 399 | Solve the following coding problem using the programming language Python:
A message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given a non-empty string containing only digits, determine the total number of ways to decode it.
Example 1:
In... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numDecodings', 'input': ['"12"'], 'output': 0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/decode-ways/'} | vfc_765 |
apps | verifiable_code | 400 | Solve the following coding problem using the programming language Python:
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].
... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'largestRectangleArea', 'input': [[2, 1, 5, 6, 2, 3, -1]], 'output': 10}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/largest-rectangle-in-histogram/'} | vfc_766 |
apps | verifiable_code | 401 | Solve the following coding problem using the programming language Python:
Given an array nums of integers, we need to find the maximum possible sum of elements of the array such that it is divisible by three.
Example 1:
Input: nums = [3,6,5,1,8]
Output: 18
Explanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (m... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'maxSumDivThree', 'input': [[3, 6, 5, 1, 8]], 'output': 18}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/greatest-sum-divisible-by-three/'} | vfc_767 |
apps | verifiable_code | 402 | Solve the following coding problem using the programming language Python:
In a 1 million by 1 million grid, the coordinates of each grid square are (x, y) with 0 <= x, y < 10^6.
We start at the source square and want to reach the target square. Each move, we can walk to a 4-directionally adjacent square in the grid t... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'isEscapePossible', 'input': [[[0, 1], [1, 0], [], []], [0, 0], [0, 2]], 'output': False}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/escape-a-large-maze/'} | vfc_768 |
apps | verifiable_code | 403 | Solve the following coding problem using the programming language Python:
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.
Formally the function should:
Return true if there exists i, j, k
such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1
else ret... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'increasingTriplet', 'input': [[1, 2, 3, 4, 5]], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/increasing-triplet-subsequence/'} | vfc_769 |
apps | verifiable_code | 404 | Solve the following coding problem using the programming language Python:
We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?
Note that our partition must use every number in A, and that scores are... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'largestSumOfAverages', 'input': [[9, 1, 2, 3, 9], 3], 'output': 20.0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/largest-sum-of-averages/'} | vfc_770 |
apps | verifiable_code | 405 | Solve the following coding problem using the programming language Python:
Alice plays the following game, loosely based on the card game "21".
Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, she gains an integer number of points randomly from the range [1, W], where W... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'new21Game', 'input': [10, 1, 10], 'output': 1.0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/new-21-game/'} | vfc_771 |
apps | verifiable_code | 406 | Solve the following coding problem using the programming language Python:
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:
Only one letter can be changed at a time.
Each transformed word must... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'ladderLength', 'input': ['"hit"', '"cog"', ['"hot"', '"dot"', '"dog"', '"lot"', '"log"', '"cog"']], 'output': 5}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/word-ladder/'} | vfc_772 |
apps | verifiable_code | 407 | Solve the following coding problem using the programming language Python:
Given a balanced parentheses string S, compute the score of the string based on the following rule:
() has score 1
AB has score A + B, where A and B are balanced parentheses strings.
(A) has score 2 * A, where A is a balanced parentheses string... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'scoreOfParentheses', 'input': ['"()"'], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/score-of-parentheses/'} | vfc_773 |
apps | verifiable_code | 408 | Solve the following coding problem using the programming language Python:
Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute diffe... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findBestValue', 'input': [[4, 9, 3], 10], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/sum-of-mutated-array-closest-to-target/'} | vfc_774 |
apps | verifiable_code | 409 | Solve the following coding problem using the programming language Python:
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 that t... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'kConcatenationMaxSum', 'input': [[1, 2], 3], 'output': 9}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/k-concatenation-maximum-sum/'} | vfc_775 |
apps | verifiable_code | 410 | Solve the following coding problem using the programming language Python:
The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:
if x is even then x = x / 2
if x is odd then x = 3 * x + 1
For example, the power of x = 3 is 7 because 3 needs 7 steps to beco... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'getKth', 'input': [12, 15, 2], 'output': 13}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/sort-integers-by-the-power-value/'} | vfc_776 |
apps | verifiable_code | 411 | Solve the following coding problem using the programming language Python:
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
Note:
The same word in the dictionary may be re... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'wordBreak', 'input': ['"leetcode"', ['"leet"', '"code"']], 'output': False}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/word-break/'} | vfc_777 |
apps | verifiable_code | 412 | Solve the following coding problem using the programming language Python:
You have d dice, and each die has f faces numbered 1, 2, ..., f.
Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target.
Example 1:
Input: d = 1, f = 6, target... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numRollsToTarget', 'input': [1, 6, 3], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/'} | vfc_778 |
apps | verifiable_code | 413 | Solve the following coding problem using the programming language Python:
Given a palindromic string palindrome, replace exactly one character by any lowercase English letter so that the string becomes the lexicographically smallest possible string that isn't a palindrome.
After doing so, return the final string. If ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'breakPalindrome', 'input': ['"abccba"'], 'output': 'aabccba"'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/break-a-palindrome/'} | vfc_779 |
apps | verifiable_code | 414 | Solve the following coding problem using the programming language Python:
Given an integer array arr of distinct integers and an integer k.
A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and r... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'getWinner', 'input': [[5, 1, 2, 3, 4, 6, 7], 2], 'output': 5}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-the-winner-of-an-array-game/'} | vfc_780 |
apps | verifiable_code | 415 | Solve the following coding problem using the programming language Python:
We have two integer sequences A and B of the same non-zero length.
We are allowed to swap elements A[i] and B[i]. Note that both elements are in the same index position in their respective sequences.
At the end of some number of swaps, A and B ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'minSwap', 'input': [[1, 3, 5, 4], [1, 2, 3, 7]], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/'} | vfc_781 |
apps | verifiable_code | 416 | Solve the following coding problem using the programming language Python:
A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.
The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph.
Mouse starts at node 1 and goes first, Cat starts ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'catMouseGame', 'input': [[[2, 5], [3], [0, 4, 5], [1, 4, 5], [2, 3], [0, 2, 3], [], []]], 'output': 0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/cat-and-mouse/'} | vfc_782 |
apps | verifiable_code | 417 | Solve the following coding problem using the programming language Python:
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0
Example 2:... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findMedianSortedArrays', 'input': [[1, 3], [2]], 'output': 2.0}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/median-of-two-sorted-arrays/'} | vfc_783 |
apps | verifiable_code | 418 | Solve the following coding problem using the programming language Python:
Given a positive integer n and you can do operations as follow:
If n is even, replace n with n/2.
If n is odd, you can replace n with either n + 1 or n - 1.
What is the minimum number of replacements needed for n to become 1?
Example... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'integerReplacement', 'input': [8], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/integer-replacement/'} | vfc_784 |
apps | verifiable_code | 419 | Solve the following coding problem using the programming language Python:
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the i-th round, you toggle e... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'bulbSwitch', 'input': [3], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/bulb-switcher/'} | vfc_785 |
apps | verifiable_code | 420 | Solve the following coding problem using the programming language Python:
Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.
Example 1:
Input: s = "eleetminicoworoep"
Output: 13
Explanat... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'findTheLongestSubstring', 'input': ['"eleetminicoworoep"'], 'output': 13}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts/'} | vfc_786 |
apps | verifiable_code | 421 | Solve the following coding problem using the programming language Python:
Given a string s, return the last substring of s in lexicographical order.
Example 1:
Input: "abab"
Output: "bab"
Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'lastSubstring', 'input': ['"abab"'], 'output': 'bab"'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/last-substring-in-lexicographical-order/'} | vfc_787 |
apps | verifiable_code | 422 | Solve the following coding problem using the programming language Python:
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab"
Note: "aba" is also a valid answer.
Example 2:
Input: "cbbd"
Output: "bb"
Write y... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'longestPalindrome', 'input': ['"babad"'], 'output': 'bab'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/longest-palindromic-substring/'} | vfc_788 |
apps | verifiable_code | 423 | Solve the following coding problem using the programming language Python:
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.
Example 1:
Input... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'longestSubsequence', 'input': [[1, 2, 3, 4], 1], 'output': 4}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference/'} | vfc_789 |
apps | verifiable_code | 424 | Solve the following coding problem using the programming language Python:
You are given two images img1 and img2 both of size n x n, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)
We translate one image however we choose (sliding it left, right, up, or down any... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'largestOverlap', 'input': [[[1, 1, 0], [0, 1, 0], [0, 1, 0], [], []], [[0, 0, 0], [0, 1, 1], [0, 0, 1], [], []]], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/image-overlap/'} | vfc_790 |
apps | verifiable_code | 425 | Solve the following coding problem using the programming language Python:
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
Return the quotient after dividing dividend by divisor.
The integer division should truncate toward zero.
Example 1:
Input... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'divide', 'input': [10, 3], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/divide-two-integers/'} | vfc_791 |
apps | verifiable_code | 426 | Solve the following coding problem using the programming language Python:
Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero.
Return true if and only if we can do this in a way such that the resulting number is a power of 2.
... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'reorderedPowerOf2', 'input': [1], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/reordered-power-of-2/'} | vfc_792 |
apps | verifiable_code | 427 | Solve the following coding problem using the programming language Python:
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.
Example ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'countOrders', 'input': [1], 'output': 1}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/'} | vfc_793 |
apps | verifiable_code | 428 | Solve the following coding problem using the programming language Python:
We are given a 2-dimensional grid. "." is an empty cell, "#" is a wall, "@" is the starting point, ("a", "b", ...) are keys, and ("A", "B", ...) are locks.
We start at the starting point, and one move consists of walking one space in one of the ... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'shortestPathAllKeys', 'input': [['"@.a.#"', '"###.#"', '"b.A.B"']], 'output': 8}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/shortest-path-to-get-all-keys/'} | vfc_794 |
apps | verifiable_code | 429 | Solve the following coding problem using the programming language Python:
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess mat... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'getHint', 'input': ['"1807"', '"7810"'], 'output': '3A3B'}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/bulls-and-cows/'} | vfc_795 |
apps | verifiable_code | 430 | Solve the following coding problem using the programming language Python:
Given a string S, count the number of distinct, non-empty subsequences of S .
Since the result may be large, return the answer modulo 10^9 + 7.
Example 1:
Input: "abc"
Output: 7
Explanation: The 7 distinct subsequences are "a", "b", "c", "ab",... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'distinctSubseqII', 'input': ['"abc"'], 'output': 30}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/distinct-subsequences-ii/'} | vfc_796 |
apps | verifiable_code | 431 | Solve the following coding problem using the programming language Python:
Given an array of integers A, find the sum of min(B), where B ranges over every (contiguous) subarray of A.
Since the answer may be large, return the answer modulo 10^9 + 7.
Example 1:
Input: [3,1,2,4]
Output: 17
Explanation: Subarrays are [3]... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'sumSubarrayMins', 'input': [[3, 1, 2, 4, 0]], 'output': 17}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/sum-of-subarray-minimums/'} | vfc_797 |
apps | verifiable_code | 432 | Solve the following coding problem using the programming language Python:
Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers
Return True if its possible otherwise return False.
Example 1:
Input: nums = [1,2,3,3,4,4,5,6], k = 4
... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'isPossibleDivide', 'input': [[1, 2, 3, 3, 4, 4, 5, 6], 4], 'output': True}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/'} | vfc_798 |
apps | verifiable_code | 433 | Solve the following coding problem using the programming language Python:
Given an array of integers arr and two integers k and threshold.
Return the number of sub-arrays of size k and average greater than or equal to threshold.
Example 1:
Input: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4
Output: 3
Explanation: S... | null | {'test_cases': [{'type': 'function_call', 'fn_name': 'numOfSubarrays', 'input': [[2, 2, 2, 2, 5, 5, 5, 8], 3, 4], 'output': 3}], 'language': 'Python'} | {'difficulty': 'interview', 'problem_url': 'https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/'} | vfc_799 |