HashedIn by Deloitte interview question

Sub array problems