That is not O(1) space, final int[] result = new int[N]; here you need N extra space
L
lw0203jojo
@lw0203jojo
2
Reputation
8
Posts
62
Profile views
0
Followers
0
Following
Posts made by lw0203jojo

RE: Two solutons: O(N) space and O(1) space.

RE: My Java Solution (accepted), O(n) in time, O(1) in memory
That is not O(n) space, actually you need N extra space for output;

RE: O(n) solution. Technically not DP
That is DP and the time complexity is n^2

RE: O(1) space DP in Java
if you set pre = 0, then you needn't the case of if(i == 1){max = Math.max(max, nums[i]); }