solution to two arrays problem on hackerrank