Browse and solve 1,200+ machine learning coding challenges on Deep-ML. Filter by difficulty (beginner, intermediate, advanced) and category (linear algebra, machine learning, deep learning, NLP, computer vision). Write Python solutions in the browser and get instant feedback against test cases.
Implement flip(a) that reverses a 1-D array: out[i] = a[n - 1 - i].
Do not call np.flip, np.flipud, or use the slice a[::-1]. Use index arithmetic with np.arange.
Example:
flip(np.array([1., 2., 3., 4.])) -> [4., 3., 2., 1.]
flip(np.array([1., 2., 3., 4.]))
[4. 3. 2. 1.]
Index i reads position n-1-i.