LeetCode Array Easy 1. Two Sum】的更多相关文章

Description Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, wh…
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [, , , ], targ…
Description Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [,,] Output: Example 2: Input: [,,,,,,,,] Output: Note:Your algorithm should run in linear runtime com…
Description Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is gr…
Description Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-,,-,,-,,,-,], Output: Explanation: [,-,,] has the largest sum = . Follow up: If you…
Description Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [,,,,,] Output: Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s . Note: T…
Description Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O…
Description Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1: Input: [, , ] Output: Explanation: The third maximum .  E…
Description Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [,,,,] Output: [,,,,] Note: You must do this in-place without making a copy of the array…
---恢复内容开始--- Description Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k. Example 1: Input: nums =…