Skip to content
Advertisement

Tag: algorithm

What does it mean by “second += arr[i][arr.length-i-1]”

I been practicing my algorithm solving skill by solving HackerRank problems. However, one of the problems is giving me a difficult time to understand. It is about calculating absolute difference between sum of diagonals in a square matrix “arr”. If the square matrix is like this: and the solution is like this: So, I came up with this solution: However,

Merge sort time complexity check

Hello guys I was learning about the merge sort so I wrote this function that takes 2 arrays and merges them sorted. Can someone tell me the time complexity of this function? I thought it would be O(n^2) as I am using shift inside a while loop. Is that correct or am I missing something here? Answer The worst case

Advertisement