Leetcode Implement Dynamic Array Solution Hackerrank Problem