Ok, The question is based on Inplace operations and your logic is quite correct. I will explain with 3 things so it will be clear to you.
1. Good programming practice:-
The output yields [], because there is clear statement in 19th line
//19 nums.clear()
//20 nums=nonZeroArray;
Idea:- nums is…
    
Top comments (0)