Пікірлер
@manaspandey0
@manaspandey0 4 ай бұрын
Time limit exceeded
@maryllianvieira0667
@maryllianvieira0667 6 ай бұрын
The best explanation ever! Thank you
@sapatil8999
@sapatil8999 Жыл бұрын
result = [] for i, v in enumerate(nums): result.append(nums[v]) return result
@JJ-nv5hs
@JJ-nv5hs 7 ай бұрын
I was so close to this solution, i literally only forgot the [v] part. thank you for helping me with this.
@jagggyjazz8010
@jagggyjazz8010 Жыл бұрын
Bruh where is O(1) solution
@amroulouay6819
@amroulouay6819 Жыл бұрын
class Solution: def build_array(nums): n = len(nums) for i, num in enumerate(nums): original_val = num % n new_val = nums[num] % n nums[i] = new_val * n + original_val for i in range(n): nums[i] //= n return nums
@147-dhanush8
@147-dhanush8 Жыл бұрын
explain what is [ ans.append(value) ] means
@MrSaurus
@MrSaurus Жыл бұрын
That just adds each value to the ans array
@abhisheksurela2881
@abhisheksurela2881 2 жыл бұрын
I don't understand the question, or I would say the question is not clear
@MKYEuphoria
@MKYEuphoria 2 жыл бұрын
I agree. I felt like crying doing this challenge
@anonymoustv8604
@anonymoustv8604 2 жыл бұрын
Thanks for the explanation!
@rtr8463
@rtr8463 3 жыл бұрын
Thank you so much
@nijatabiyev1316
@nijatabiyev1316 3 жыл бұрын
thanks for the all leetcode python solutions
@mohammad_butt
@mohammad_butt 3 жыл бұрын
At 2:22 I meant "for" loop, not "while" loop.
@mohammad_butt
@mohammad_butt 3 жыл бұрын
Why we recalculate the length inside the while loop? Suppose the num array has 9 elements and we just removed an element, index will try to increment all the way to 9, but there are only 8 elements. So not decrementing length will go out of bound leading to "list index out of range" error. Alternatively, we can replace "while i < length" with "while i < len(nums) - 1". This way we wont have to manually recalculate the length.