problem stringlengths 20 3.95k | answer stringclasses 532
values | task stringclasses 6
values | problem_number int64 1 1.31k | set_number int64 1 5 |
|---|---|---|---|---|
You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7]... | LiveCodeBench | 966 | 2 | |
You are given a 0-indexed array of positive integers nums.
A subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7]... | LiveCodeBench | 966 | 3 | |
You are given a 0-indexed integer array nums and an integer k.
In one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator.
Return the minimum possible value of th... | LiveCodeBench | 967 | 1 | |
You are given a 0-indexed integer array nums and an integer k.
In one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator.
Return the minimum possible value of th... | LiveCodeBench | 967 | 2 | |
You are given a 0-indexed integer array nums and an integer k.
In one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator.
Return the minimum possible value of th... | LiveCodeBench | 967 | 3 | |
You are given an array of positive integers nums of length n.
A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
Conversely, if you have k (k >= 3) positive real numbers a_1, a_2, a_3, ..., a_k where a_1 <= a_2 <= a_3 <= ... <= a_k and... | LiveCodeBench | 968 | 1 | |
You are given an array of positive integers nums of length n.
A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
Conversely, if you have k (k >= 3) positive real numbers a_1, a_2, a_3, ..., a_k where a_1 <= a_2 <= a_3 <= ... <= a_k and... | LiveCodeBench | 968 | 2 | |
You are given an array of positive integers nums of length n.
A polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.
Conversely, if you have k (k >= 3) positive real numbers a_1, a_2, a_3, ..., a_k where a_1 <= a_2 <= a_3 <= ... <= a_k and... | LiveCodeBench | 968 | 3 | |
You are given an array of integers nums of length n.
The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
You need to divide nums into 3 disjoint contiguous subarrays.
Return the minimum possible sum of the cost of these subarrays.
Example 1:
I... | LiveCodeBench | 969 | 1 | |
You are given an array of integers nums of length n.
The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
You need to divide nums into 3 disjoint contiguous subarrays.
Return the minimum possible sum of the cost of these subarrays.
Example 1:
I... | LiveCodeBench | 969 | 2 | |
You are given an array of integers nums of length n.
The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
You need to divide nums into 3 disjoint contiguous subarrays.
Return the minimum possible sum of the cost of these subarrays.
Example 1:
I... | LiveCodeBench | 969 | 3 | |
You are given an array nums of length n and a positive integer k.
A subarray of nums is called good if the absolute difference between its first and last element is exactly k, in other words, the subarray nums[i..j] is good if |nums[i] - nums[j]| == k.
Return the maximum sum of a good subarray of nums. If there are no ... | LiveCodeBench | 970 | 1 | |
You are given an array nums of length n and a positive integer k.
A subarray of nums is called good if the absolute difference between its first and last element is exactly k, in other words, the subarray nums[i..j] is good if |nums[i] - nums[j]| == k.
Return the maximum sum of a good subarray of nums. If there are no ... | LiveCodeBench | 970 | 2 | |
You are given an array nums of length n and a positive integer k.
A subarray of nums is called good if the absolute difference between its first and last element is exactly k, in other words, the subarray nums[i..j] is good if |nums[i] - nums[j]| == k.
Return the maximum sum of a good subarray of nums. If there are no ... | LiveCodeBench | 970 | 3 | |
You are given a string s that consists of lowercase English letters.
A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
Return the length of the longest special substring of s which occurs at least t... | LiveCodeBench | 971 | 1 | |
You are given a string s that consists of lowercase English letters.
A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
Return the length of the longest special substring of s which occurs at least t... | LiveCodeBench | 971 | 2 | |
You are given a string s that consists of lowercase English letters.
A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
Return the length of the longest special substring of s which occurs at least t... | LiveCodeBench | 971 | 3 | |
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:
nums[i + k + 1] > nums[i + k] if pattern[k] == 1.
n... | LiveCodeBench | 972 | 1 | |
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:
nums[i + k + 1] > nums[i + k] if pattern[k] == 1.
n... | LiveCodeBench | 972 | 2 | |
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
A subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:
nums[i + k + 1] > nums[i + k] if pattern[k] == 1.
n... | LiveCodeBench | 972 | 3 | |
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them.
The game proceeds as follows:
Alice takes the first turn.
In each... | LiveCodeBench | 973 | 1 | |
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them.
The game proceeds as follows:
Alice takes the first turn.
In each... | LiveCodeBench | 973 | 2 | |
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them.
The game proceeds as follows:
Alice takes the first turn.
In each... | LiveCodeBench | 973 | 3 | |
You are given a 0-indexed array of positive integers nums.
In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).
Return true if you can sort the array, else return false.
Example 1:
Input: nums = [... | LiveCodeBench | 974 | 1 | |
You are given a 0-indexed array of positive integers nums.
In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).
Return true if you can sort the array, else return false.
Example 1:
Input: nums = [... | LiveCodeBench | 974 | 2 | |
You are given a 0-indexed array of positive integers nums.
In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).
Return true if you can sort the array, else return false.
Example 1:
Input: nums = [... | LiveCodeBench | 974 | 3 | |
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.
Initially, all indices in nums are unmarked. Your task is to mark all indices in nums.
In each second, s, in order from 1 to m (inclusive), you can perform one of the following operations:
Choose an index i in th... | LiveCodeBench | 975 | 1 | |
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.
Initially, all indices in nums are unmarked. Your task is to mark all indices in nums.
In each second, s, in order from 1 to m (inclusive), you can perform one of the following operations:
Choose an index i in th... | LiveCodeBench | 975 | 2 | |
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.
Initially, all indices in nums are unmarked. Your task is to mark all indices in nums.
In each second, s, in order from 1 to m (inclusive), you can perform one of the following operations:
Choose an index i in th... | LiveCodeBench | 975 | 3 | |
You are given a 0-indexed string word and an integer k.
At every second, you must perform the following operations:
Remove the first k characters of word.
Add any k characters to the end of word.
Note that you do not necessarily need to add the same characters that you removed. However, you must perform both operatio... | LiveCodeBench | 976 | 1 | |
You are given a 0-indexed string word and an integer k.
At every second, you must perform the following operations:
Remove the first k characters of word.
Add any k characters to the end of word.
Note that you do not necessarily need to add the same characters that you removed. However, you must perform both operatio... | LiveCodeBench | 976 | 2 | |
You are given a 0-indexed string word and an integer k.
At every second, you must perform the following operations:
Remove the first k characters of word.
Add any k characters to the end of word.
Note that you do not necessarily need to add the same characters that you removed. However, you must perform both operatio... | LiveCodeBench | 976 | 3 | |
You are given a 0-indexed array nums consisting of positive integers.
Initially, you can increase the value of any element in the array by at most 1.
After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elemen... | LiveCodeBench | 977 | 1 | |
You are given a 0-indexed array nums consisting of positive integers.
Initially, you can increase the value of any element in the array by at most 1.
After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elemen... | LiveCodeBench | 977 | 2 | |
You are given a 0-indexed array nums consisting of positive integers.
Initially, you can increase the value of any element in the array by at most 1.
After that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elemen... | LiveCodeBench | 977 | 3 | |
You are given an array of positive integers nums.
You need to select a subset of nums which satisfies the following condition:
You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x^2, x^4, ..., x^k/2, x^k, x^k/2, ..., x^4, x^2, x] (Note that k can be be any non-negative power... | LiveCodeBench | 978 | 1 | |
You are given an array of positive integers nums.
You need to select a subset of nums which satisfies the following condition:
You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x^2, x^4, ..., x^k/2, x^k, x^k/2, ..., x^4, x^2, x] (Note that k can be be any non-negative power... | LiveCodeBench | 978 | 2 | |
You are given an array of positive integers nums.
You need to select a subset of nums which satisfies the following condition:
You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x^2, x^4, ..., x^k/2, x^k, x^k/2, ..., x^4, x^2, x] (Note that k can be be any non-negative power... | LiveCodeBench | 978 | 3 | |
You are given a string s.
Consider performing the following operation until s becomes empty:
For every alphabet character from 'a' to 'z', remove the first occurrence of that character in s (if it exists).
For example, let initially s = "aabcbbca". We do the following operations:
Remove the underlined characters s =... | LiveCodeBench | 979 | 1 | |
You are given a string s.
Consider performing the following operation until s becomes empty:
For every alphabet character from 'a' to 'z', remove the first occurrence of that character in s (if it exists).
For example, let initially s = "aabcbbca". We do the following operations:
Remove the underlined characters s =... | LiveCodeBench | 979 | 2 | |
You are given a string s.
Consider performing the following operation until s becomes empty:
For every alphabet character from 'a' to 'z', remove the first occurrence of that character in s (if it exists).
For example, let initially s = "aabcbbca". We do the following operations:
Remove the underlined characters s =... | LiveCodeBench | 979 | 3 | |
You are given a 0-indexed string array words.
Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:
isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is ... | LiveCodeBench | 980 | 1 | |
You are given a 0-indexed string array words.
Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:
isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is ... | LiveCodeBench | 980 | 2 | |
You are given a 0-indexed string array words.
Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:
isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is ... | LiveCodeBench | 980 | 3 | |
An ant is on a boundary. It sometimes goes left and sometimes right.
You are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element:
If nums[i] < 0, it moves left by -nums[i] units.
If nums[i] >... | LiveCodeBench | 981 | 1 | |
An ant is on a boundary. It sometimes goes left and sometimes right.
You are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element:
If nums[i] < 0, it moves left by -nums[i] units.
If nums[i] >... | LiveCodeBench | 981 | 2 | |
An ant is on a boundary. It sometimes goes left and sometimes right.
You are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element:
If nums[i] < 0, it moves left by -nums[i] units.
If nums[i] >... | LiveCodeBench | 981 | 3 | |
You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any.
Return the number of times the user had to change the key.
Note: Modifiers like shift or caps lock won't be coun... | LiveCodeBench | 982 | 1 | |
You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any.
Return the number of times the user had to change the key.
Note: Modifiers like shift or caps lock won't be coun... | LiveCodeBench | 982 | 2 | |
You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any.
Return the number of times the user had to change the key.
Note: Modifiers like shift or caps lock won't be coun... | LiveCodeBench | 982 | 3 | |
You are given a 0-indexed string array words having length n and containing 0-indexed strings.
You are allowed to perform the following operation any number of times (including zero):
Choose integers i, j, x, and y such that 0 <= i, j < n, 0 <= x < words[i].length, 0 <= y < words[j].length, and swap the characters wor... | LiveCodeBench | 983 | 1 | |
You are given a 0-indexed string array words having length n and containing 0-indexed strings.
You are allowed to perform the following operation any number of times (including zero):
Choose integers i, j, x, and y such that 0 <= i, j < n, 0 <= x < words[i].length, 0 <= y < words[j].length, and swap the characters wor... | LiveCodeBench | 983 | 2 | |
You are given a 0-indexed string array words having length n and containing 0-indexed strings.
You are allowed to perform the following operation any number of times (including zero):
Choose integers i, j, x, and y such that 0 <= i, j < n, 0 <= x < words[i].length, 0 <= y < words[j].length, and swap the characters wor... | LiveCodeBench | 983 | 3 | |
Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:
Choose the first two elements of nums and delete them.
The score of the operation is the sum of the deleted elements.
Your task is to find the maximum number of operations that can be performed, su... | LiveCodeBench | 984 | 1 | |
Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:
Choose the first two elements of nums and delete them.
The score of the operation is the sum of the deleted elements.
Your task is to find the maximum number of operations that can be performed, su... | LiveCodeBench | 984 | 2 | |
Given an array of integers called nums, you can perform the following operation while nums contains at least 2 elements:
Choose the first two elements of nums and delete them.
The score of the operation is the sum of the deleted elements.
Your task is to find the maximum number of operations that can be performed, su... | LiveCodeBench | 984 | 3 | |
You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:
nums1.length == nums2.length == nums.length / 2.
nums1 should contain distinct elements.
nums2 should also contain distinct elements.
Return true if it is possible to split the array, and false ot... | LiveCodeBench | 985 | 1 | |
You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:
nums1.length == nums2.length == nums.length / 2.
nums1 should contain distinct elements.
nums2 should also contain distinct elements.
Return true if it is possible to split the array, and false ot... | LiveCodeBench | 985 | 2 | |
You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:
nums1.length == nums2.length == nums.length / 2.
nums1 should contain distinct elements.
nums2 should also contain distinct elements.
Return true if it is possible to split the array, and false ot... | LiveCodeBench | 985 | 3 | |
You are given two arrays with positive integers arr1 and arr2.
A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.
A common prefix of two integers a and b is an integer c, such that c is ... | LiveCodeBench | 986 | 1 | |
You are given two arrays with positive integers arr1 and arr2.
A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.
A common prefix of two integers a and b is an integer c, such that c is ... | LiveCodeBench | 986 | 2 | |
You are given two arrays with positive integers arr1 and arr2.
A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.
A common prefix of two integers a and b is an integer c, such that c is ... | LiveCodeBench | 986 | 3 | |
You are given a 0-indexed integer array nums, and an integer k.
In one operation, you can remove one occurrence of the smallest element of nums.
Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.
Example 1:
Input: nums = [2,11,10,1,3], k = 10
Output: 3
Ex... | LiveCodeBench | 987 | 1 | |
You are given a 0-indexed integer array nums, and an integer k.
In one operation, you can remove one occurrence of the smallest element of nums.
Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.
Example 1:
Input: nums = [2,11,10,1,3], k = 10
Output: 3
Ex... | LiveCodeBench | 987 | 2 | |
You are given a 0-indexed integer array nums, and an integer k.
In one operation, you can remove one occurrence of the smallest element of nums.
Return the minimum number of operations needed so that all elements of the array are greater than or equal to k.
Example 1:
Input: nums = [2,11,10,1,3], k = 10
Output: 3
Ex... | LiveCodeBench | 987 | 3 | |
You are given a 1-indexed array of distinct integers nums of length n.
You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the i^th operation:
If the last ele... | LiveCodeBench | 988 | 1 | |
You are given a 1-indexed array of distinct integers nums of length n.
You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the i^th operation:
If the last ele... | LiveCodeBench | 988 | 2 | |
You are given a 1-indexed array of distinct integers nums of length n.
You need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the i^th operation:
If the last ele... | LiveCodeBench | 988 | 3 | |
Takahashi and Aoki played N games.
You are given a string S of length N, representing the results of these games.
Takahashi won the i-th game if the i-th character of S is T, and Aoki won that game if it is A.
The overall winner between Takahashi and Aoki is the one who won more games than the other.
If they had the... | LiveCodeBench | 989 | 1 | |
Takahashi and Aoki played N games.
You are given a string S of length N, representing the results of these games.
Takahashi won the i-th game if the i-th character of S is T, and Aoki won that game if it is A.
The overall winner between Takahashi and Aoki is the one who won more games than the other.
If they had the... | LiveCodeBench | 989 | 2 | |
Takahashi and Aoki played N games.
You are given a string S of length N, representing the results of these games.
Takahashi won the i-th game if the i-th character of S is T, and Aoki won that game if it is A.
The overall winner between Takahashi and Aoki is the one who won more games than the other.
If they had the... | LiveCodeBench | 989 | 3 | |
We have a sequence of length N consisting of positive integers: A=(A_1,\ldots,A_N). Any two adjacent terms have different values.
Let us insert some numbers into this sequence by the following procedure.
- If every pair of adjacent terms in A has an absolute difference of 1, terminate the procedure.
- Let A_i, A_{i+1}... | LiveCodeBench | 990 | 1 | |
We have a sequence of length N consisting of positive integers: A=(A_1,\ldots,A_N). Any two adjacent terms have different values.
Let us insert some numbers into this sequence by the following procedure.
- If every pair of adjacent terms in A has an absolute difference of 1, terminate the procedure.
- Let A_i, A_{i+1}... | LiveCodeBench | 990 | 2 | |
We have a sequence of length N consisting of positive integers: A=(A_1,\ldots,A_N). Any two adjacent terms have different values.
Let us insert some numbers into this sequence by the following procedure.
- If every pair of adjacent terms in A has an absolute difference of 1, terminate the procedure.
- Let A_i, A_{i+1}... | LiveCodeBench | 990 | 3 | |
A single-player card game is popular in AtCoder Inc.
Each card in the game has a lowercase English letter or the symbol @ written on it. There is plenty number of cards for each kind.
The game goes as follows.
- Arrange the same number of cards in two rows.
- Replace each card with @ with one of the following cards:... | LiveCodeBench | 991 | 1 | |
A single-player card game is popular in AtCoder Inc.
Each card in the game has a lowercase English letter or the symbol @ written on it. There is plenty number of cards for each kind.
The game goes as follows.
- Arrange the same number of cards in two rows.
- Replace each card with @ with one of the following cards:... | LiveCodeBench | 991 | 2 | |
A single-player card game is popular in AtCoder Inc.
Each card in the game has a lowercase English letter or the symbol @ written on it. There is plenty number of cards for each kind.
The game goes as follows.
- Arrange the same number of cards in two rows.
- Replace each card with @ with one of the following cards:... | LiveCodeBench | 991 | 3 | |
You are given an integer N and a string S consisting of 0, 1, and ?.
Let T be the set of values that can be obtained by replacing each ? in S with 0 or 1 and interpreting the result as a binary integer.
For instance, if S= ?0?, we have T=\lbrace 000_{(2)},001_{(2)},100_{(2)},101_{(2)}\rbrace=\lbrace 0,1,4,5\rbrace.
Pri... | LiveCodeBench | 992 | 1 | |
You are given an integer N and a string S consisting of 0, 1, and ?.
Let T be the set of values that can be obtained by replacing each ? in S with 0 or 1 and interpreting the result as a binary integer.
For instance, if S= ?0?, we have T=\lbrace 000_{(2)},001_{(2)},100_{(2)},101_{(2)}\rbrace=\lbrace 0,1,4,5\rbrace.
Pri... | LiveCodeBench | 992 | 2 | |
You are given an integer N and a string S consisting of 0, 1, and ?.
Let T be the set of values that can be obtained by replacing each ? in S with 0 or 1 and interpreting the result as a binary integer.
For instance, if S= ?0?, we have T=\lbrace 000_{(2)},001_{(2)},100_{(2)},101_{(2)}\rbrace=\lbrace 0,1,4,5\rbrace.
Pri... | LiveCodeBench | 992 | 3 | |
We have a grid with H rows and W columns.
Let (i,j) denote the square at the i-th row from the top and j-th column from the left.
Each square in the grid is one of the following: the start square, the goal square, an empty square, a wall square, and a candy square.
(i,j) is represented by a character A_{i,j}, and is... | LiveCodeBench | 993 | 1 | |
We have a grid with H rows and W columns.
Let (i,j) denote the square at the i-th row from the top and j-th column from the left.
Each square in the grid is one of the following: the start square, the goal square, an empty square, a wall square, and a candy square.
(i,j) is represented by a character A_{i,j}, and is... | LiveCodeBench | 993 | 2 | |
We have a grid with H rows and W columns.
Let (i,j) denote the square at the i-th row from the top and j-th column from the left.
Each square in the grid is one of the following: the start square, the goal square, an empty square, a wall square, and a candy square.
(i,j) is represented by a character A_{i,j}, and is... | LiveCodeBench | 993 | 3 | |
A DDoS-type string is a string of length 4 consisting of uppercase and lowercase English letters satisfying both of the following conditions.
- The first, second, and fourth characters are uppercase English letters, and the third character is a lowercase English letter.
- The first and second characters are equal.
Fo... | LiveCodeBench | 994 | 1 | |
A DDoS-type string is a string of length 4 consisting of uppercase and lowercase English letters satisfying both of the following conditions.
- The first, second, and fourth characters are uppercase English letters, and the third character is a lowercase English letter.
- The first and second characters are equal.
Fo... | LiveCodeBench | 994 | 2 | |
A DDoS-type string is a string of length 4 consisting of uppercase and lowercase English letters satisfying both of the following conditions.
- The first, second, and fourth characters are uppercase English letters, and the third character is a lowercase English letter.
- The first and second characters are equal.
Fo... | LiveCodeBench | 994 | 3 | |
There is an enemy with stamina A. Every time you attack the enemy, its stamina reduces by B.
At least how many times do you need to attack the enemy to make its stamina 0 or less?
Input
The input is given from Standard Input in the following format:
A B
Output
Print the answer.
Constraints
- 1 \le A,B \le 10^{1... | LiveCodeBench | 995 | 1 | |
There is an enemy with stamina A. Every time you attack the enemy, its stamina reduces by B.
At least how many times do you need to attack the enemy to make its stamina 0 or less?
Input
The input is given from Standard Input in the following format:
A B
Output
Print the answer.
Constraints
- 1 \le A,B \le 10^{1... | LiveCodeBench | 995 | 2 | |
There is an enemy with stamina A. Every time you attack the enemy, its stamina reduces by B.
At least how many times do you need to attack the enemy to make its stamina 0 or less?
Input
The input is given from Standard Input in the following format:
A B
Output
Print the answer.
Constraints
- 1 \le A,B \le 10^{1... | LiveCodeBench | 995 | 3 | |
There is a grid with H horizontal rows and W vertical columns. Each cell has a lowercase English letter written on it.
We denote by (i, j) the cell at the i-th row from the top and j-th column from the left.
The letters written on the grid are represented by H strings S_1,S_2,\ldots, S_H, each of length W.
The j-th ... | LiveCodeBench | 996 | 1 | |
There is a grid with H horizontal rows and W vertical columns. Each cell has a lowercase English letter written on it.
We denote by (i, j) the cell at the i-th row from the top and j-th column from the left.
The letters written on the grid are represented by H strings S_1,S_2,\ldots, S_H, each of length W.
The j-th ... | LiveCodeBench | 996 | 2 | |
There is a grid with H horizontal rows and W vertical columns. Each cell has a lowercase English letter written on it.
We denote by (i, j) the cell at the i-th row from the top and j-th column from the left.
The letters written on the grid are represented by H strings S_1,S_2,\ldots, S_H, each of length W.
The j-th ... | LiveCodeBench | 996 | 3 | |
You are given N strings S_1,S_2,\dots,S_N, each of length M, consisting of lowercase English letter. Here, S_i are pairwise distinct.
Determine if one can rearrange these strings to obtain a new sequence of strings T_1,T_2,\dots,T_N such that:
- for all integers i such that 1 \le i \le N-1, one can alter exactly one ... | LiveCodeBench | 997 | 1 | |
You are given N strings S_1,S_2,\dots,S_N, each of length M, consisting of lowercase English letter. Here, S_i are pairwise distinct.
Determine if one can rearrange these strings to obtain a new sequence of strings T_1,T_2,\dots,T_N such that:
- for all integers i such that 1 \le i \le N-1, one can alter exactly one ... | LiveCodeBench | 997 | 2 | |
You are given N strings S_1,S_2,\dots,S_N, each of length M, consisting of lowercase English letter. Here, S_i are pairwise distinct.
Determine if one can rearrange these strings to obtain a new sequence of strings T_1,T_2,\dots,T_N such that:
- for all integers i such that 1 \le i \le N-1, one can alter exactly one ... | LiveCodeBench | 997 | 3 | |
Takahashi has decided to give one gift to Aoki and one gift to Snuke.
There are N candidates of gifts for Aoki,
and their values are A_1, A_2, \ldots,A_N.
There are M candidates of gifts for Snuke,
and their values are B_1, B_2, \ldots,B_M.
Takahashi wants to choose gifts so that the difference in values of the t... | LiveCodeBench | 998 | 1 | |
Takahashi has decided to give one gift to Aoki and one gift to Snuke.
There are N candidates of gifts for Aoki,
and their values are A_1, A_2, \ldots,A_N.
There are M candidates of gifts for Snuke,
and their values are B_1, B_2, \ldots,B_M.
Takahashi wants to choose gifts so that the difference in values of the t... | LiveCodeBench | 998 | 2 | |
Takahashi has decided to give one gift to Aoki and one gift to Snuke.
There are N candidates of gifts for Aoki,
and their values are A_1, A_2, \ldots,A_N.
There are M candidates of gifts for Snuke,
and their values are B_1, B_2, \ldots,B_M.
Takahashi wants to choose gifts so that the difference in values of the t... | LiveCodeBench | 998 | 3 | |
There is an undirected graph with N vertices numbered 1 through N, and initially with 0 edges.
Given Q queries, process them in order. After processing each query,
print the number of vertices that are not connected to any other vertices by an edge.
The i-th query, \mathrm{query}_i, is of one of the following two ki... | LiveCodeBench | 999 | 1 | |
There is an undirected graph with N vertices numbered 1 through N, and initially with 0 edges.
Given Q queries, process them in order. After processing each query,
print the number of vertices that are not connected to any other vertices by an edge.
The i-th query, \mathrm{query}_i, is of one of the following two ki... | LiveCodeBench | 999 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.