About 15,900,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. 26. Remove Duplicates from Sorted Array - Java - Stack Overflow

    Nov 19, 2020 · Question : Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for …

  4. Why does my code return 12 instead of 12.75 for Leetcode …

    Jul 11, 2023 · 0 Question: You are given an integer array nums consisting of n elements, and an integer k.Find a contiguous subarray whose length is equal to k that has the maximum …

  5. 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.

  6. 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 …

  7. 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, …

  8. 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 …

  9. 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 …

  10. How do I return all possible triplets in the 3Sum problem?

    Jun 3, 2022 · Question in brief: Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.