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.
A relatively efficient way might be :
Iterate first array, store sum as key in a map.
Iterate another array and this time, only store those sum which exists in first map.
Same, iterate third one , and now, index those sum only which is contained in 2nd map. The last common value is your result :)
You will skip reversing arrays and a bit easy on memory as well
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
A relatively efficient way might be : Iterate first array, store sum as key in a map. Iterate another array and this time, only store those sum which exists in first map. Same, iterate third one , and now, index those sum only which is contained in 2nd map. The last common value is your result :) You will skip reversing arrays and a bit easy on memory as well