Hi, I was solving this question to rotate the array by k elements and got confused at one point.
Line1:
nums[ : ] =nums[-k:]+nums[:-k]
Line 2:
nums = nums[-k:]+nums[:-k]
what is the difference between line 1 and 2? When I print nums in both the cases, same value is printed. However, line 1 is being accepted as answer but not line 2. Please help me understand this.