We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here is My solutin using Java Language. Its time complexity is O(n).
Explanation(using math logic) - let's denote a middle integer with y and both right and left side as x because there sum is same.
Now the equation will look like ->
1) x + y + x = sum of array
2) 2x + y = sum
3) 2x = sum - y
Sherlock and Array
You are viewing a single comment's thread. Return to all comments →
Here is My solutin using Java Language. Its time complexity is O(n).
Explanation(using math logic) - let's denote a middle integer with y and both
right and left side as x because there sum is same. Now the equation will look like ->
1) x + y + x = sum of array
2) 2x + y = sum
3) 2x = sum - y