Back to course home
0% completed
Vote For New Content
Can't we just fill the array with 1 to n?
Jack Tan
Oct 22, 2025
Why can't we just do this?
public class Solution { public int[] sort(int[] nums) { for (int i = 0; i < nums.length; i++) { nums[i] = i + 1; } return nums; } }
0
0
Comments
Comments
J
Jack Tan2 days ago
I misunderstood the problem statement. In fact the elements in the input array are supposed to be objects rather than int numbers. Unlike filling the array with int numbers, you can't create those objects on the fly and put them into the array. You are supposed to r...
On this page