Menu

So In A Interview I Was Asked That I Have To Divide The Input Array Into Three Parts Such That Taking Difference Of The Maximum And Minimum Value Of Each Part And Then The Final Answer Should Be Minimum Of The Three Differences Obtain From Three Parts And The Three Parts Should Contain At Leat One Element .How To Solve This Question In Minimum Possibel Tiem

So In A Interview I Was Asked That I Have To Divide The Input Array Into Three Parts Such That Taking Difference Of The Maximum And Minimum Value Of Each Part And Then The Final Answer Should Be Minimum Of The Three Differences Obtain From Three Parts And The Three Parts Should Contain At Leat One Element .How To Solve This Question In Minimum Possibel Tiem

So in a interview i was asked that i have to divide the input array into three parts such that taking difference of the maximum and minimum value of each part and then the final answer should be minimum of the three differences obtain from three parts and the three parts should contain at leat one element .
How to solve this question in minimum possibel tiem and space complexity and in c++ provide the solution.

Expert Answer

Step 1

To solve this problem with minimum time and space complexity in C++, you can follow a straightforwar.

OR