Please answer only in python coding

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: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please answer only in python coding

Post by answerhappygod »

Please answer only in python coding
Please Answer Only In Python Coding 1
Please Answer Only In Python Coding 1 (147.46 KiB) Viewed 46 times
Given an array of positive integers arr, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by d. It is not allowed to remove the whole array. Return the smallest subarray that you need to remove, or −1) if it's impossible. A subarray is defined as a contiguous block of elements in the array. Make sure your program can take inputs from the terminal. Sample Input1: arr=[3,1,4,2],d=6 Sample Output1: [4] Sample Input2: arr=[6,3,5,2],d=9 Sample Output2: [5,2] I Sample Input3: arr=[1,2,3],d=3 Sample Output3: 0 comment: empty case Sample Input4: arr=[1,2,3],d=7 Sample Output4: −1 comment: impossible case Hint: Suppose you know the remainder for the sum of the entire array.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply