Indices of Non-Zero Elements
easynumpy_indexingImplement nonzero_indices(x).
Given a 1D array x, return a 1D array of the indices where x is non-zero,
in increasing order. No for/while loops.
Constraints
- no scipy, sklearn
- no for/while loops
Your solution
Edit nonzero_indices and run the real pytest suite in your browser — no install required. Your code is saved locally.
Loading the Python runtime (first run only)…
Hints
Hint 1
np.nonzero(x) returns the indices of the non-zero entries (take [0] for 1D).