5. Splitting an Array Use Python Suppose the elements of an array A containing positive integers, denote the weights in kilograms. And we have a beam balance. We want to put the weights on both pans...


5. Splitting an Array<br>Use Python<br>Suppose the elements of an array A<br>containing positive integers, denote the<br>weights in kilograms. And we have a beam<br>balance. We want to put the weights on<br>both pans of the balance in such a way that<br>for some index 0 < i < A.length - 1, all<br>values starting from A[0], A[1], upto A[ i -<br>1], should be on the left pan. And all values<br>starting from A[i] upto A[ A.length - 1]<br>should be on the right pan and the left and<br>right pan should be balanced. If such an i<br>exists, return true. Else, return false.<br>Input: [1, 1, 1, 2, 1] Output : true<br>Explanation: (summation of [1, 1, 1] =<br>summation of [2,1])<br>Input: [2, 1, 1, 2, 1] Output: false<br>Input: [10, 3, 10, 2, 1] Output: true<br>Explanation: (summation of [10, 3] =<br>summation of [10,2,1]))<br>%3D<br>

Extracted text: 5. Splitting an Array Use Python Suppose the elements of an array A containing positive integers, denote the weights in kilograms. And we have a beam balance. We want to put the weights on both pans of the balance in such a way that for some index 0 < i="">< a.length="" -="" 1,="" all="" values="" starting="" from="" a[0],="" a[1],="" upto="" a[="" i="" -="" 1],="" should="" be="" on="" the="" left="" pan.="" and="" all="" values="" starting="" from="" a[i]="" upto="" a[="" a.length="" -="" 1]="" should="" be="" on="" the="" right="" pan="" and="" the="" left="" and="" right="" pan="" should="" be="" balanced.="" if="" such="" an="" i="" exists,="" return="" true.="" else,="" return="" false.="" input:="" [1,="" 1,="" 1,="" 2,="" 1]="" output="" :="" true="" explanation:="" (summation="" of="" [1,="" 1,="" 1]="summation" of="" [2,1])="" input:="" [2,="" 1,="" 1,="" 2,="" 1]="" output:="" false="" input:="" [10,="" 3,="" 10,="" 2,="" 1]="" output:="" true="" explanation:="" (summation="" of="" [10,="" 3]="summation" of="" [10,2,1]))="">

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here