Implement a method to flatten a nested array without using the flatten method.
MediumProblem Statement
Implement a method to flatten a nested array without using the flatten method.
Sample Input
[[1, 2, [3]], 4]
Sample Output
[1, 2, 3, 4]
Limits
Time: 2s · Memory: 256 MB