• 1 s steps s 2 x 103 • 1 sbadindex s 4 10 Input Format for Custom Testing Input from stdin will be processed as follows

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

• 1 s steps s 2 x 103 • 1 sbadindex s 4 10 Input Format for Custom Testing Input from stdin will be processed as follows

Post by answerhappygod »

1 S Steps S 2 X 103 1 Sbadindex S 4 10 Input Format For Custom Testing Input From Stdin Will Be Processed As Follows 1
1 S Steps S 2 X 103 1 Sbadindex S 4 10 Input Format For Custom Testing Input From Stdin Will Be Processed As Follows 1 (515.09 KiB) Viewed 70 times
• 1 s steps s 2 x 103 • 1 sbadindex s 4 10 Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function The first line contains an Integer steps, the number of steps the pointer can take. The next line contains an integer badinde, the index to avoid 1. Maximum Index Function Description Complete the function maxindex in the editor There is an infinite array of integers numbered y below. consecutively from 0. At each step, a pointer can move from index to index ii or remain where it maxlndex has the following parameter(s) is. The value of /begins at 0. The value of begins at 1 and at each step./increments by 1. There is one int steps: the number steps to take known index that must be avoided. Determine the int badindex: the bad index highest index that can be reached in a given number of steps Returns: int: the maximum index that can be reached from Example index 0 steps 4 badElement -6 Constraints The pointer is limited to 4 steps and should avoid the bad item 6 • 1 sstaps s2101 . Scenario 1: • Is badindexsextos • In the first step / starts at 1. Move unit to index 0.1=1 and/-2 . At step 2. move 2 units to index 1.2.2 and/ Input Format for Custom Testing -3 . At step 3, do not move. Otherwise, the pointer will move 3 units to the bad item 6. Now Sample Case o At step 4, moved units to item 3.42 Sample input o . Scenario 2 At step 1, remain at index . Now / 2 STDIN Function . At step 2. mowe 2 units to index 0122 and/- 3 + steps ? • At step 2 move 3 units to index 23.5 and badIndex 2 . At step 4, moved units to index 5.4 Sample Case Sample Input o STOIN Function + steps - 2 bad Index = 2 Sample Output Explanation Move 2 steps and avoid index number 2. • At step 1, move unit to step 0.1 Afstap 2, move 2 units to step 1.23 Move 2 steps and avoid index number 2. • At step 1, move 1 unit to step 0+1=1. • At step2, move 2 units to step 1-2-3 The maximum index that can be reached is 3. Sample Case 2 Sample Input 2 STDIN Function + steps = 3 + bad Index - 3 Sample Case 1 Sample Input 1 STDIN Function Sample Output 2 5 2 1 + steps - 2 + bad Index - 1 Sample Output 1 2 Explanation 1 Move 2 steps and avoid index 1. Explanation 2 Move 3 steps and avoid index number 3. • Scenario 1: • At step 1, move unit to index 0+1 -1. • At step 2. remain at index 1. Otherwise, the pointer will move to the bad index number 3. . At step 3, move 3 units to index +3=4 • Scenario 2: At step 1, remain at index 0. . At step 2 move 2 units to index 0.2-2. • At step 3. move 3 units to index 2+35 • the maximum Index that can be reached is S. . At step 1, remain at index 0. Otherwise, the pointer will move 1 unit to the bad index number • At step 2, move 2 units to index T. The maximum index that can be reached is 2.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply