Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Assignment-Introduction To Array

Uploaded by

717821f159
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Assignment-Introduction To Array

Uploaded by

717821f159
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Q1.

Running Sum of 1d Array Easy


Given an array nums. We define a running sum of an array
as runningSum[i] = sum(nums[0]…nums[i]).

Return the running sum of nums.

Practice

Q2. Number of Good Pairs Easy


Given an array of integers nums, return the number of
good pairs.

A pair (i, j) is called good if nums[i] == nums[j] and i < j.

Practice

Q3. Find Greatest Common Divisor of Array Easy


Given an integer array nums, return the greatest common
divisor of the smallest number and largest number in
nums.

The greatest common divisor of two numbers is the


largest positive integer that evenly divides both numbers.

Practice

01
Q4. Unique Number of Occurrences Easy
Given an array of integers arr, return true if the number of
occurrences of each value in the array is unique or false
otherwise.

Practice

Q5. Divide Array Into Equal Pairs Easy


You are given an integer array nums consisting of 2 * n
integers.
You need to divide nums into n pairs such that:
Each element belongs to exactly one pair.
The elements present in a pair are equal.
Return true if nums can be divided into n pairs, otherwise
return false.

Practice

Q6. Find the Duplicate Number Medium


Given an array of integers nums containing n + 1 integers
where each integer is in the range [1, n] inclusive.

There is only one repeated number in nums, return this


repeated number.

You must solve the problem without modifying the array


nums and uses only constant extra space.
Practice
02
Q7. Find All Duplicates in an Array Medium
Given an integer array nums of length n where all the
integers of nums are in the range [1, n] and each integer
appears once or twice, return an array of all the integers
that appears twice.

You must write an algorithm that runs in O(n) time and


uses only constant extra space.
Practice

Q8. Find Peak Element Medium


A peak elemenA peak element is an element that is
strictly greater than its neighbors.

Given a 0-indexed integer array nums, find a peak


element, and return its index. If the array contains
multiple peaks, return the index to any of the peaks.

You may imagine that nums[-1] = nums[n] = -∞. In other


words, an element is always considered to be strictly
greater than a neighbor that is outside the array.

You must write an algorithm that runs in O(log n) time.


t is an element that is strictly greater than

Practice

03

You might also like