0% found this document useful (0 votes)
17 views2 pages

DSA Assignment - 1

Uploaded by

anshuraghav1204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

DSA Assignment - 1

Uploaded by

anshuraghav1204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DSA Assignment - 1(Arrays)

Marks - 100
Note: Attempt this assignment after studying pre-recorded content and after attending
Live lectures of that particular topic.
Create your Leetcode Profiles and solve these questions there. Share your solved
questions link along with the Time complexity and Space Complexity of your solution in
a doc when you submit your assignment.
Submit the optimised solution for all the questions.

WARNING !! Don’t try to copy from somewhere else. We can call any student randomly
to explain their solutions and if we find the discrepancy, you will be provided 0.

For Example :

Question was https://leetcode.com/problems/concatenation-of-array/description/

Solution Link -
https://leetcode.com/problems/concatenation-of-array/submissions/1257621340/
Time Complexity: O(n)
Space Complexity: O(1)

Add screenshot:
Description:
Time Complexity: O(n)
Iterating to the entire n-sized array and for each array element performing O(1) operation
of push.
Space complexity: O(1)
No Extra space required for the Program Execution

1. There are n kids with candies. You are given an integer array candies, where each candies[i]
represents the number of candies the ith kid has, and an integer extraCandies, denoting the
number of extra candies that you have.
Return a boolean array result of length n, where result[i] is true if, after giving the ith kid all the
extraCandies, they will have the greatest number of candies among all the kids, or false
otherwise.
Leetcode 1431 (20 marks)

2. Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such
that |nums[i] - nums[j]| == k Leetcode 2006 (20 marks)

3. You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively.

Consider calculating the following values:


The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2.
The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1.

Return an integer array answer of size 2 containing the two values in the above order.
Leetcode 2956 (20 marks)

4. 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. Leetcode 1512 (20 marks)

5. Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].


Return the array in the form [x1,y1,x2,y2,...,xn,yn]. Leetcode 1470 (20 marks)

You might also like