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 an integer sequence A = (A_1, A_2, \dots, A_N).
Calculate the following expression:
\displaystyle \sum_{i=1}^N \sum_{j=i+1}^N \max(A_j - A_i, 0)
The constraints guarantee that the answer is less than 2^{63}.
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Ou... | LiveCodeBench | 1,233 | 1 | |
You are given an integer sequence A = (A_1, A_2, \dots, A_N).
Calculate the following expression:
\displaystyle \sum_{i=1}^N \sum_{j=i+1}^N \max(A_j - A_i, 0)
The constraints guarantee that the answer is less than 2^{63}.
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Ou... | LiveCodeBench | 1,233 | 2 | |
You are given an integer sequence A = (A_1, A_2, \dots, A_N).
Calculate the following expression:
\displaystyle \sum_{i=1}^N \sum_{j=i+1}^N \max(A_j - A_i, 0)
The constraints guarantee that the answer is less than 2^{63}.
Input
The input is given from Standard Input in the following format:
N
A_1 A_2 \dots A_N
Ou... | LiveCodeBench | 1,233 | 3 | |
You have an empty sequence and N balls. The size of the i-th ball (1 \leq i \leq N) is 2^{A_i}.
You will perform N operations.
In the i-th operation, you add the i-th ball to the right end of the sequence, and repeat the following steps:
- If the sequence has one or fewer balls, end the operation.
- If the rightmost ... | LiveCodeBench | 1,234 | 1 | |
You have an empty sequence and N balls. The size of the i-th ball (1 \leq i \leq N) is 2^{A_i}.
You will perform N operations.
In the i-th operation, you add the i-th ball to the right end of the sequence, and repeat the following steps:
- If the sequence has one or fewer balls, end the operation.
- If the rightmost ... | LiveCodeBench | 1,234 | 2 | |
You have an empty sequence and N balls. The size of the i-th ball (1 \leq i \leq N) is 2^{A_i}.
You will perform N operations.
In the i-th operation, you add the i-th ball to the right end of the sequence, and repeat the following steps:
- If the sequence has one or fewer balls, end the operation.
- If the rightmost ... | LiveCodeBench | 1,234 | 3 | |
There is a grid of H rows and W columns. Some cells (possibly zero) contain magnets.
The state of the grid is represented by H strings S_1, S_2, \ldots, S_H of length W. If the j-th character of S_i is #, it indicates that there is a magnet in the cell at the i-th row from the top and j-th column from the left; if it i... | LiveCodeBench | 1,235 | 1 | |
There is a grid of H rows and W columns. Some cells (possibly zero) contain magnets.
The state of the grid is represented by H strings S_1, S_2, \ldots, S_H of length W. If the j-th character of S_i is #, it indicates that there is a magnet in the cell at the i-th row from the top and j-th column from the left; if it i... | LiveCodeBench | 1,235 | 2 | |
There is a grid of H rows and W columns. Some cells (possibly zero) contain magnets.
The state of the grid is represented by H strings S_1, S_2, \ldots, S_H of length W. If the j-th character of S_i is #, it indicates that there is a magnet in the cell at the i-th row from the top and j-th column from the left; if it i... | LiveCodeBench | 1,235 | 3 | |
You are given a weighted undirected graph G with N vertices, numbered 1 to N. Initially, G has no edges.
You will perform M operations to add edges to G. The i-th operation (1 \leq i \leq M) is as follows:
- You are given a subset of vertices S_i=\lbrace A_{i,1},A_{i,2},\dots,A_{i,K_i}\rbrace consisting of K_i vertice... | LiveCodeBench | 1,236 | 1 | |
You are given a weighted undirected graph G with N vertices, numbered 1 to N. Initially, G has no edges.
You will perform M operations to add edges to G. The i-th operation (1 \leq i \leq M) is as follows:
- You are given a subset of vertices S_i=\lbrace A_{i,1},A_{i,2},\dots,A_{i,K_i}\rbrace consisting of K_i vertice... | LiveCodeBench | 1,236 | 2 | |
You are given a weighted undirected graph G with N vertices, numbered 1 to N. Initially, G has no edges.
You will perform M operations to add edges to G. The i-th operation (1 \leq i \leq M) is as follows:
- You are given a subset of vertices S_i=\lbrace A_{i,1},A_{i,2},\dots,A_{i,K_i}\rbrace consisting of K_i vertice... | LiveCodeBench | 1,236 | 3 | |
The AtCoder railway line has N stations, numbered 1, 2, \ldots, N.
On this line, there are inbound trains that start at station 1 and stop at the stations 2, 3, \ldots, N in order, and outbound trains that start at station N and stop at the stations N - 1, N - 2, \ldots, 1 in order.
Takahashi is about to travel from st... | LiveCodeBench | 1,237 | 1 | |
The AtCoder railway line has N stations, numbered 1, 2, \ldots, N.
On this line, there are inbound trains that start at station 1 and stop at the stations 2, 3, \ldots, N in order, and outbound trains that start at station N and stop at the stations N - 1, N - 2, \ldots, 1 in order.
Takahashi is about to travel from st... | LiveCodeBench | 1,237 | 2 | |
The AtCoder railway line has N stations, numbered 1, 2, \ldots, N.
On this line, there are inbound trains that start at station 1 and stop at the stations 2, 3, \ldots, N in order, and outbound trains that start at station N and stop at the stations N - 1, N - 2, \ldots, 1 in order.
Takahashi is about to travel from st... | LiveCodeBench | 1,237 | 3 | |
There are N giants, named 1 to N. When giant i stands on the ground, their shoulder height is A_i, and their head height is B_i.
You can choose a permutation (P_1, P_2, \ldots, P_N) of (1, 2, \ldots, N) and stack the N giants according to the following rules:
-
First, place giant P_1 on the ground. The giant P_1's s... | LiveCodeBench | 1,238 | 1 | |
There are N giants, named 1 to N. When giant i stands on the ground, their shoulder height is A_i, and their head height is B_i.
You can choose a permutation (P_1, P_2, \ldots, P_N) of (1, 2, \ldots, N) and stack the N giants according to the following rules:
-
First, place giant P_1 on the ground. The giant P_1's s... | LiveCodeBench | 1,238 | 2 | |
There are N giants, named 1 to N. When giant i stands on the ground, their shoulder height is A_i, and their head height is B_i.
You can choose a permutation (P_1, P_2, \ldots, P_N) of (1, 2, \ldots, N) and stack the N giants according to the following rules:
-
First, place giant P_1 on the ground. The giant P_1's s... | LiveCodeBench | 1,238 | 3 | |
Takahashi tried to type a string S consisting of lowercase English letters using a keyboard.
He was typing while looking only at the keyboard, not the screen.
Whenever he mistakenly typed a different lowercase English letter, he immediately pressed the backspace key. However, the backspace key was broken, so the mistak... | LiveCodeBench | 1,239 | 1 | |
Takahashi tried to type a string S consisting of lowercase English letters using a keyboard.
He was typing while looking only at the keyboard, not the screen.
Whenever he mistakenly typed a different lowercase English letter, he immediately pressed the backspace key. However, the backspace key was broken, so the mistak... | LiveCodeBench | 1,239 | 2 | |
Takahashi tried to type a string S consisting of lowercase English letters using a keyboard.
He was typing while looking only at the keyboard, not the screen.
Whenever he mistakenly typed a different lowercase English letter, he immediately pressed the backspace key. However, the backspace key was broken, so the mistak... | LiveCodeBench | 1,239 | 3 | |
You are given a permutation P = (P_1, P_2, \dots, P_N) of (1, 2, \dots, N).
A length-K sequence of indices (i_1, i_2, \dots, i_K) is called a good index sequence if it satisfies both of the following conditions:
- 1 \leq i_1 < i_2 < \dots < i_K \leq N.
- The subsequence (P_{i_1}, P_{i_2}, \dots, P_{i_K}) can be obtain... | LiveCodeBench | 1,240 | 1 | |
You are given a permutation P = (P_1, P_2, \dots, P_N) of (1, 2, \dots, N).
A length-K sequence of indices (i_1, i_2, \dots, i_K) is called a good index sequence if it satisfies both of the following conditions:
- 1 \leq i_1 < i_2 < \dots < i_K \leq N.
- The subsequence (P_{i_1}, P_{i_2}, \dots, P_{i_K}) can be obtain... | LiveCodeBench | 1,240 | 2 | |
You are given a permutation P = (P_1, P_2, \dots, P_N) of (1, 2, \dots, N).
A length-K sequence of indices (i_1, i_2, \dots, i_K) is called a good index sequence if it satisfies both of the following conditions:
- 1 \leq i_1 < i_2 < \dots < i_K \leq N.
- The subsequence (P_{i_1}, P_{i_2}, \dots, P_{i_K}) can be obtain... | LiveCodeBench | 1,240 | 3 | |
For positive integers x and y, define f(x, y) as the remainder of (x + y) divided by 10^8.
You are given a sequence of positive integers A = (A_1, \ldots, A_N) of length N. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j).
Input
The input is given from Standard Input... | LiveCodeBench | 1,241 | 1 | |
For positive integers x and y, define f(x, y) as the remainder of (x + y) divided by 10^8.
You are given a sequence of positive integers A = (A_1, \ldots, A_N) of length N. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j).
Input
The input is given from Standard Input... | LiveCodeBench | 1,241 | 2 | |
For positive integers x and y, define f(x, y) as the remainder of (x + y) divided by 10^8.
You are given a sequence of positive integers A = (A_1, \ldots, A_N) of length N. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(A_i,A_j).
Input
The input is given from Standard Input... | LiveCodeBench | 1,241 | 3 | |
The AtCoder amusement park has an attraction that can accommodate K people. Now, there are N groups lined up in the queue for this attraction.
The i-th group from the front (1\leq i\leq N) consists of A_i people. For all i (1\leq i\leq N), it holds that A_i \leq K.
Takahashi, as a staff member of this attraction, will ... | LiveCodeBench | 1,242 | 1 | |
The AtCoder amusement park has an attraction that can accommodate K people. Now, there are N groups lined up in the queue for this attraction.
The i-th group from the front (1\leq i\leq N) consists of A_i people. For all i (1\leq i\leq N), it holds that A_i \leq K.
Takahashi, as a staff member of this attraction, will ... | LiveCodeBench | 1,242 | 2 | |
The AtCoder amusement park has an attraction that can accommodate K people. Now, there are N groups lined up in the queue for this attraction.
The i-th group from the front (1\leq i\leq N) consists of A_i people. For all i (1\leq i\leq N), it holds that A_i \leq K.
Takahashi, as a staff member of this attraction, will ... | LiveCodeBench | 1,242 | 3 | |
There are N buildings aligned in a row. The i-th building from the left has a height of H_i.
Determine if there is a building taller than the first one from the left. If such a building exists, find the position of the leftmost such building from the left.
Input
The input is given from Standard Input in the following... | LiveCodeBench | 1,243 | 1 | |
There are N buildings aligned in a row. The i-th building from the left has a height of H_i.
Determine if there is a building taller than the first one from the left. If such a building exists, find the position of the leftmost such building from the left.
Input
The input is given from Standard Input in the following... | LiveCodeBench | 1,243 | 2 | |
There are N buildings aligned in a row. The i-th building from the left has a height of H_i.
Determine if there is a building taller than the first one from the left. If such a building exists, find the position of the leftmost such building from the left.
Input
The input is given from Standard Input in the following... | LiveCodeBench | 1,243 | 3 | |
For strings x and y, define f(x, y) as follows:
- f(x, y) is the length of the longest common prefix of x and y.
You are given N strings (S_1, \ldots, S_N) consisting of lowercase English letters. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(S_i,S_j).
Input
The input is... | LiveCodeBench | 1,244 | 1 | |
For strings x and y, define f(x, y) as follows:
- f(x, y) is the length of the longest common prefix of x and y.
You are given N strings (S_1, \ldots, S_N) consisting of lowercase English letters. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(S_i,S_j).
Input
The input is... | LiveCodeBench | 1,244 | 2 | |
For strings x and y, define f(x, y) as follows:
- f(x, y) is the length of the longest common prefix of x and y.
You are given N strings (S_1, \ldots, S_N) consisting of lowercase English letters. Find the value of the following expression:
\displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N f(S_i,S_j).
Input
The input is... | LiveCodeBench | 1,244 | 3 | |
For positive integers x and y, define f(x, y) as follows:
- Interpret the decimal representations of x and y as strings and concatenate them in this order to obtain a string z. The value of f(x, y) is the value of z when interpreted as a decimal integer.
For example, f(3, 14) = 314 and f(100, 1) = 1001.
You are given... | LiveCodeBench | 1,245 | 1 | |
For positive integers x and y, define f(x, y) as follows:
- Interpret the decimal representations of x and y as strings and concatenate them in this order to obtain a string z. The value of f(x, y) is the value of z when interpreted as a decimal integer.
For example, f(3, 14) = 314 and f(100, 1) = 1001.
You are given... | LiveCodeBench | 1,245 | 2 | |
For positive integers x and y, define f(x, y) as follows:
- Interpret the decimal representations of x and y as strings and concatenate them in this order to obtain a string z. The value of f(x, y) is the value of z when interpreted as a decimal integer.
For example, f(3, 14) = 314 and f(100, 1) = 1001.
You are given... | LiveCodeBench | 1,245 | 3 | |
N AtCoder users have gathered to play AtCoder RPS 2. The i-th user's name is S_i and their rating is C_i.
AtCoder RPS 2 is played as follows:
- Assign the numbers 0, 1, \dots, N - 1 to the users in lexicographical order of their usernames.
- Let T be the sum of the ratings of the N users. The user assigned the number ... | LiveCodeBench | 1,246 | 1 | |
N AtCoder users have gathered to play AtCoder RPS 2. The i-th user's name is S_i and their rating is C_i.
AtCoder RPS 2 is played as follows:
- Assign the numbers 0, 1, \dots, N - 1 to the users in lexicographical order of their usernames.
- Let T be the sum of the ratings of the N users. The user assigned the number ... | LiveCodeBench | 1,246 | 2 | |
N AtCoder users have gathered to play AtCoder RPS 2. The i-th user's name is S_i and their rating is C_i.
AtCoder RPS 2 is played as follows:
- Assign the numbers 0, 1, \dots, N - 1 to the users in lexicographical order of their usernames.
- Let T be the sum of the ratings of the N users. The user assigned the number ... | LiveCodeBench | 1,246 | 3 | |
Takahashi is growing a plant. Its height at the time of germination is 0\,\mathrm{cm}. Considering the day of germination as day 0, its height increases by 2^i\,\mathrm{cm} day i's night (0 \le i).
Takahashi's height is H\,\mathrm{cm}.
Every morning, Takahashi measures his height against this plant. Find the first day... | LiveCodeBench | 1,247 | 1 | |
Takahashi is growing a plant. Its height at the time of germination is 0\,\mathrm{cm}. Considering the day of germination as day 0, its height increases by 2^i\,\mathrm{cm} day i's night (0 \le i).
Takahashi's height is H\,\mathrm{cm}.
Every morning, Takahashi measures his height against this plant. Find the first day... | LiveCodeBench | 1,247 | 2 | |
Takahashi is growing a plant. Its height at the time of germination is 0\,\mathrm{cm}. Considering the day of germination as day 0, its height increases by 2^i\,\mathrm{cm} day i's night (0 \le i).
Takahashi's height is H\,\mathrm{cm}.
Every morning, Takahashi measures his height against this plant. Find the first day... | LiveCodeBench | 1,247 | 3 | |
Takahashi and Aoki are playing a game using N cards. The front side of the i-th card has A_i written on it, and the back side has B_i written on it. Initially, the N cards are laid out on the table. With Takahashi going first, the two players take turns performing the following operation:
- Choose a pair of cards from... | LiveCodeBench | 1,248 | 1 | |
Takahashi and Aoki are playing a game using N cards. The front side of the i-th card has A_i written on it, and the back side has B_i written on it. Initially, the N cards are laid out on the table. With Takahashi going first, the two players take turns performing the following operation:
- Choose a pair of cards from... | LiveCodeBench | 1,248 | 2 | |
Takahashi and Aoki are playing a game using N cards. The front side of the i-th card has A_i written on it, and the back side has B_i written on it. Initially, the N cards are laid out on the table. With Takahashi going first, the two players take turns performing the following operation:
- Choose a pair of cards from... | LiveCodeBench | 1,248 | 3 | |
Takahashi has N cards from the card game "AtCoder Magics." The i-th card will be called card i. Each card has two parameters: strength and cost. Card i has a strength of A_i and a cost of C_i.
He does not like weak cards, so he will discard them. Specifically, he will repeat the following operation until it can no long... | LiveCodeBench | 1,249 | 1 | |
Takahashi has N cards from the card game "AtCoder Magics." The i-th card will be called card i. Each card has two parameters: strength and cost. Card i has a strength of A_i and a cost of C_i.
He does not like weak cards, so he will discard them. Specifically, he will repeat the following operation until it can no long... | LiveCodeBench | 1,249 | 2 | |
Takahashi has N cards from the card game "AtCoder Magics." The i-th card will be called card i. Each card has two parameters: strength and cost. Card i has a strength of A_i and a cost of C_i.
He does not like weak cards, so he will discard them. Specifically, he will repeat the following operation until it can no long... | LiveCodeBench | 1,249 | 3 | |
The pattern of AtCoder's wallpaper can be represented on the xy-plane as follows:
-
The plane is divided by the following three types of lines:
-
x = n (where n is an integer)
-
y = n (where n is an even number)
-
x + y = n (where n is an even number)
-
Each region is painted black or white. Any two regions... | LiveCodeBench | 1,250 | 1 | |
The pattern of AtCoder's wallpaper can be represented on the xy-plane as follows:
-
The plane is divided by the following three types of lines:
-
x = n (where n is an integer)
-
y = n (where n is an even number)
-
x + y = n (where n is an even number)
-
Each region is painted black or white. Any two regions... | LiveCodeBench | 1,250 | 2 | |
The pattern of AtCoder's wallpaper can be represented on the xy-plane as follows:
-
The plane is divided by the following three types of lines:
-
x = n (where n is an integer)
-
y = n (where n is an even number)
-
x + y = n (where n is an even number)
-
Each region is painted black or white. Any two regions... | LiveCodeBench | 1,250 | 3 | |
This is an interactive problem (where your program interacts with the judge via input and output).
You are given a positive integer N and integers L and R such that 0 \leq L \leq R < 2^N. The judge has a hidden sequence A = (A_0, A_1, \dots, A_{2^N-1}) consisting of integers between 0 and 99, inclusive.
Your goal is to... | LiveCodeBench | 1,251 | 1 | |
This is an interactive problem (where your program interacts with the judge via input and output).
You are given a positive integer N and integers L and R such that 0 \leq L \leq R < 2^N. The judge has a hidden sequence A = (A_0, A_1, \dots, A_{2^N-1}) consisting of integers between 0 and 99, inclusive.
Your goal is to... | LiveCodeBench | 1,251 | 2 | |
This is an interactive problem (where your program interacts with the judge via input and output).
You are given a positive integer N and integers L and R such that 0 \leq L \leq R < 2^N. The judge has a hidden sequence A = (A_0, A_1, \dots, A_{2^N-1}) consisting of integers between 0 and 99, inclusive.
Your goal is to... | LiveCodeBench | 1,251 | 3 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N and a sequence B=(B_1,B_2,\dots,B_M) of length M. Here, all elements of A and B are pairwise distinct. Determine whether the sequence C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of A and B in ascending order contains two consecutive elements appear... | LiveCodeBench | 1,252 | 1 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N and a sequence B=(B_1,B_2,\dots,B_M) of length M. Here, all elements of A and B are pairwise distinct. Determine whether the sequence C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of A and B in ascending order contains two consecutive elements appear... | LiveCodeBench | 1,252 | 2 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N and a sequence B=(B_1,B_2,\dots,B_M) of length M. Here, all elements of A and B are pairwise distinct. Determine whether the sequence C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of A and B in ascending order contains two consecutive elements appear... | LiveCodeBench | 1,252 | 3 | |
There is an N \times N grid, where the cell at the i-th row from the top and the j-th column from the left contains the integer N \times (i-1) + j.
Over T turns, integers will be announced. On Turn i, the integer A_i is announced, and the cell containing A_i is marked. Determine the turn on which Bingo is achieved for ... | LiveCodeBench | 1,253 | 1 | |
There is an N \times N grid, where the cell at the i-th row from the top and the j-th column from the left contains the integer N \times (i-1) + j.
Over T turns, integers will be announced. On Turn i, the integer A_i is announced, and the cell containing A_i is marked. Determine the turn on which Bingo is achieved for ... | LiveCodeBench | 1,253 | 2 | |
There is an N \times N grid, where the cell at the i-th row from the top and the j-th column from the left contains the integer N \times (i-1) + j.
Over T turns, integers will be announced. On Turn i, the integer A_i is announced, and the cell containing A_i is marked. Determine the turn on which Bingo is achieved for ... | LiveCodeBench | 1,253 | 3 | |
Takahashi's cake has been eaten by someone. There are three suspects: person 1, person 2, and person 3.
There are two witnesses, Ringo and Snuke. Ringo remembers that person A is not the culprit, and Snuke remembers that person B is not the culprit.
Determine if the culprit can be uniquely identified based on the memor... | LiveCodeBench | 1,254 | 1 | |
Takahashi's cake has been eaten by someone. There are three suspects: person 1, person 2, and person 3.
There are two witnesses, Ringo and Snuke. Ringo remembers that person A is not the culprit, and Snuke remembers that person B is not the culprit.
Determine if the culprit can be uniquely identified based on the memor... | LiveCodeBench | 1,254 | 2 | |
Takahashi's cake has been eaten by someone. There are three suspects: person 1, person 2, and person 3.
There are two witnesses, Ringo and Snuke. Ringo remembers that person A is not the culprit, and Snuke remembers that person B is not the culprit.
Determine if the culprit can be uniquely identified based on the memor... | LiveCodeBench | 1,254 | 3 | |
You are given N intervals of real numbers. The i-th (1 \leq i \leq N) interval is [l_i, r_i]. Find the number of pairs (i, j)\,(1 \leq i < j \leq N) such that the i-th and j-th intervals intersect.
Input
The input is given from Standard Input in the following format:
N
l_1 r_1
l_2 r_2
\vdots
l_N r_N
Output
Prin... | LiveCodeBench | 1,255 | 1 | |
You are given N intervals of real numbers. The i-th (1 \leq i \leq N) interval is [l_i, r_i]. Find the number of pairs (i, j)\,(1 \leq i < j \leq N) such that the i-th and j-th intervals intersect.
Input
The input is given from Standard Input in the following format:
N
l_1 r_1
l_2 r_2
\vdots
l_N r_N
Output
Prin... | LiveCodeBench | 1,255 | 2 | |
You are given N intervals of real numbers. The i-th (1 \leq i \leq N) interval is [l_i, r_i]. Find the number of pairs (i, j)\,(1 \leq i < j \leq N) such that the i-th and j-th intervals intersect.
Input
The input is given from Standard Input in the following format:
N
l_1 r_1
l_2 r_2
\vdots
l_N r_N
Output
Prin... | LiveCodeBench | 1,255 | 3 | |
You are given an array apple of size n and an array capacity of size m.
There are n packs where the i^th pack contains apple[i] apples. There are m boxes as well, and the i^th box has a capacity of capacity[i] apples.
Return the minimum number of boxes you need to select to redistribute these n packs of apples into box... | LiveCodeBench | 1,256 | 1 | |
You are given an array apple of size n and an array capacity of size m.
There are n packs where the i^th pack contains apple[i] apples. There are m boxes as well, and the i^th box has a capacity of capacity[i] apples.
Return the minimum number of boxes you need to select to redistribute these n packs of apples into box... | LiveCodeBench | 1,256 | 2 | |
You are given an array apple of size n and an array capacity of size m.
There are n packs where the i^th pack contains apple[i] apples. There are m boxes as well, and the i^th box has a capacity of capacity[i] apples.
Return the minimum number of boxes you need to select to redistribute these n packs of apples into box... | LiveCodeBench | 1,256 | 3 | |
You are given an array happiness of length n, and a positive integer k.
There are n children standing in a queue, where the i^th child has happiness value happiness[i]. You want to select k children from these n children in k turns.
In each turn, when you select a child, the happiness value of all the children that hav... | LiveCodeBench | 1,257 | 1 | |
You are given an array happiness of length n, and a positive integer k.
There are n children standing in a queue, where the i^th child has happiness value happiness[i]. You want to select k children from these n children in k turns.
In each turn, when you select a child, the happiness value of all the children that hav... | LiveCodeBench | 1,257 | 2 | |
You are given an array happiness of length n, and a positive integer k.
There are n children standing in a queue, where the i^th child has happiness value happiness[i]. You want to select k children from these n children in k turns.
In each turn, when you select a child, the happiness value of all the children that hav... | LiveCodeBench | 1,257 | 3 | |
You are given an array arr of size n consisting of non-empty strings.
Find a string array answer of size n such that:
answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And i... | LiveCodeBench | 1,258 | 1 | |
You are given an array arr of size n consisting of non-empty strings.
Find a string array answer of size n such that:
answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And i... | LiveCodeBench | 1,258 | 2 | |
You are given an array arr of size n consisting of non-empty strings.
Find a string array answer of size n such that:
answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And i... | LiveCodeBench | 1,258 | 3 | |
You are given a 0-indexed array of integers nums of length n, and a positive odd integer k.
The strength of x subarrays is defined as strength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1 where sum[i] is the sum of the elements in the i^th subarray. Formally, strength is sum ... | LiveCodeBench | 1,259 | 1 | |
You are given a 0-indexed array of integers nums of length n, and a positive odd integer k.
The strength of x subarrays is defined as strength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1 where sum[i] is the sum of the elements in the i^th subarray. Formally, strength is sum ... | LiveCodeBench | 1,259 | 2 | |
You are given a 0-indexed array of integers nums of length n, and a positive odd integer k.
The strength of x subarrays is defined as strength = sum[1] * x - sum[2] * (x - 1) + sum[3] * (x - 2) - sum[4] * (x - 3) + ... + sum[x] * 1 where sum[i] is the sum of the elements in the i^th subarray. Formally, strength is sum ... | LiveCodeBench | 1,259 | 3 | |
Given a string s, find any substring of length 2 which is also present in the reverse of s.
Return true if such a substring exists, and false otherwise.
Example 1:
Input: s = "leetcode"
Output: true
Explanation: Substring "ee" is of length 2 which is also present in reverse(s) == "edocteel".
Example 2:
Input: s = ... | LiveCodeBench | 1,260 | 1 | |
Given a string s, find any substring of length 2 which is also present in the reverse of s.
Return true if such a substring exists, and false otherwise.
Example 1:
Input: s = "leetcode"
Output: true
Explanation: Substring "ee" is of length 2 which is also present in reverse(s) == "edocteel".
Example 2:
Input: s = ... | LiveCodeBench | 1,260 | 2 | |
Given a string s, find any substring of length 2 which is also present in the reverse of s.
Return true if such a substring exists, and false otherwise.
Example 1:
Input: s = "leetcode"
Output: true
Explanation: Substring "ee" is of length 2 which is also present in reverse(s) == "edocteel".
Example 2:
Input: s = ... | LiveCodeBench | 1,260 | 3 | |
You are given a string s and a character c. Return the total number of substrings of s that start and end with c.
Example 1:
Input: s = "abada", c = "a"
Output: 6
Explanation: Substrings starting and ending with "a" are: "abada", "abada", "abada", "abada", "abada", "abada".
Example 2:
Input: s = "zzz", c = "z"
Out... | LiveCodeBench | 1,261 | 1 | |
You are given a string s and a character c. Return the total number of substrings of s that start and end with c.
Example 1:
Input: s = "abada", c = "a"
Output: 6
Explanation: Substrings starting and ending with "a" are: "abada", "abada", "abada", "abada", "abada", "abada".
Example 2:
Input: s = "zzz", c = "z"
Out... | LiveCodeBench | 1,261 | 2 | |
You are given a string s and a character c. Return the total number of substrings of s that start and end with c.
Example 1:
Input: s = "abada", c = "a"
Output: 6
Explanation: Substrings starting and ending with "a" are: "abada", "abada", "abada", "abada", "abada", "abada".
Example 2:
Input: s = "zzz", c = "z"
Out... | LiveCodeBench | 1,261 | 3 | |
You are given a string word and an integer k.
We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string.
Here, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y.
Return the minimum number of characters you need to delet... | LiveCodeBench | 1,262 | 1 | |
You are given a string word and an integer k.
We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string.
Here, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y.
Return the minimum number of characters you need to delet... | LiveCodeBench | 1,262 | 2 | |
You are given a string word and an integer k.
We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string.
Here, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y.
Return the minimum number of characters you need to delet... | LiveCodeBench | 1,262 | 3 | |
You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.
Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If... | LiveCodeBench | 1,263 | 1 | |
You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.
Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If... | LiveCodeBench | 1,263 | 2 | |
You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.
Alice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If... | LiveCodeBench | 1,263 | 3 | |
Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.
Example 1:
Input: s = "bcbbbcba"
Output: 4
Explanation:
The following substring has a length of 4 and contains at most two occurrences of each character: "bcbbbcba".
Example 2:
Input: s = "aaa... | LiveCodeBench | 1,264 | 1 | |
Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.
Example 1:
Input: s = "bcbbbcba"
Output: 4
Explanation:
The following substring has a length of 4 and contains at most two occurrences of each character: "bcbbbcba".
Example 2:
Input: s = "aaa... | LiveCodeBench | 1,264 | 2 | |
Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.
Example 1:
Input: s = "bcbbbcba"
Output: 4
Explanation:
The following substring has a length of 4 and contains at most two occurrences of each character: "bcbbbcba".
Example 2:
Input: s = "aaa... | LiveCodeBench | 1,264 | 3 | |
You are given a positive integer k. Initially, you have an array nums = [1].
You can perform any of the following operations on the array any number of times (possibly zero):
Choose any element in the array and increase its value by 1.
Duplicate any element in the array and add it to the end of the array.
Return the ... | LiveCodeBench | 1,265 | 1 | |
You are given a positive integer k. Initially, you have an array nums = [1].
You can perform any of the following operations on the array any number of times (possibly zero):
Choose any element in the array and increase its value by 1.
Duplicate any element in the array and add it to the end of the array.
Return the ... | LiveCodeBench | 1,265 | 2 | |
You are given a positive integer k. Initially, you have an array nums = [1].
You can perform any of the following operations on the array any number of times (possibly zero):
Choose any element in the array and increase its value by 1.
Duplicate any element in the array and add it to the end of the array.
Return the ... | LiveCodeBench | 1,265 | 3 | |
The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, nums and freq, of equal length n. Each element in nums represents an ID, and the corresponding element in freq indicates how many times that ID should be added to or removed from the collection at eac... | LiveCodeBench | 1,266 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.