DSA Assignment - 1
DSA Assignment - 1
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 :
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.
Return an integer array answer of size 2 containing the two values in the above order.
Leetcode 2956 (20 marks)