Given an equation x==y for ex 111=12, you need to add pluses inside x to make the equation correct. In our example “111=12” we can add a plus like this → “11+1=12” & the equation becomes correct. You need to find the minimum number of pluses to add to x to make the equation correct. If there is no answer then print -1.

Input : A string `s`

which is the equation

Constraints: `1<=len(s)<=1000`

The value of y does not exceed `5000`

?

Q2-

There is a unique ATM in wonderland. Imagine this ATM as array of numbers. You can withdraw cash only from either ends of the array. Sarah wants to withdraw X amount of cash from the ATM. What are the minimum number of withdrawals Sarah would need to accumulate X amount of cash . If not possible print -1.

Constraints : `1<=N<=1e5`

`1<=A[i]<=1e5`

`1<=X<=1e5`

I have an `O(n^2)`

approach for 2nd ques i guess, but is there any better way.

P.S These questions are from Infosys sample test for HackwithInfy and not from ongoing contest…

source:

`https://infytq.onwingspan.com/en/page/home`

Did you got qualifiers round results ??

No. Nobody from my college got the result. I think Result is not announced yet.

I am also having doubts in the 2nd one.

It’s somewhat similar to minimum coin problem but we cannot use the coin beyond it’s frequency.

1 Like

**Q-2 → ** You can check my code I have done it in **O(N) COMPLEXITY** .

here is my code code

1 Like

okay thanks , Can you also tell me how to approach the ques as I am not able to fully understand it, it is like two pointers I think

I have used sliding window technique

1 Like

How can we solve problem 1? Anyone can explain?

A harder version of problem Q1 is here link You can check the same

second ques can be solved with this logic : finding the maximum size subarray having Max(sum) <= totalsum - X

second ques can be solved with this logic : finding the maximum size subarray having Max(sum) <= totalsum(sum of all elements) - X

where are these questions asked , which exam , which year

Link is given, its from sample test.

infosys asks in infosys hackwithinfy questions as a sample problems