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
The value of y does not exceed
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.
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…
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.
Q-2 → You can check my code I have done it in O(N) COMPLEXITY .
here is my code code
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
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