About 19,200,000 results
Open links in new tab
  1. Difference between nums[:] = nums[::-1] and nums = nums[::-1]

    Jul 22, 2019 · The assignment nums = nums[::-1] would be equivalent to create a new list in memory (with the elements reversed), and changing the pointer nums to point to that new list.

  2. what does this statement do? `nums[i] *= nums[i - 1] or 1`

    Jul 22, 2022 · A series of expressions connected by or s evaluates to the leftmost expression that has a "truthy" value - which for numeric types, means "nonzero". So this is equal to nums[I - 1] …

  3. nums[:] = unique anyone please explain this line of code

    Apr 12, 2025 · nums[:] is slice notation that gives a list [nums[0], nums[1], ... , nums[-1]], i.e. a copy of the list. The important distinction between nums[:] = unique and nums = unique is that …

  4. java - Given an array of integers nums and an integer target, …

    I was working on TwoSum problem of LeetCode Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

  5. How can I solve the 3-sum challenge using arrayLists?

    Jul 16, 2019 · I'm currently trying to solve the "three sum" challenge (I'm using java by the way). Here is the challenge description: Given an array nums of n integers, are there elements a, b, …

  6. Remove Duplicates from Sorted Array - Stack Overflow

    Nov 30, 2021 · Below is the problem or you can check the problem here Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique …

  7. python - Two Sum on LeetCode - Stack Overflow

    May 4, 2015 · I'm trying to do a LeetCode Two Sum question: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return …

  8. what is the mechanism for `def twoSum(self, nums: List[int], target ...

    Jun 17, 2019 · " nums : List[int] " states that nums is the name of the list function parameter/variable of type int " target: int " is another function parameter/variable of type int.

  9. 238.Product of Array Except Self-Leetcode - Stack Overflow

    Jul 29, 2021 · I have been trying out this problem on leetcode. 238.Product of array except self Given an integer array nums, return an array answer such that answer[i] is equal to the …

  10. nums[i++]=i; performs differently in java and C? - Stack Overflow

    Jul 25, 2020 · In nums[i ++] = nums[i + 1] If the i++ happens before the nums[i + 1], i + 1 will be out of bounds on the last iteration. In that case, Java rightly causes an error, and C, because it …