0% found this document useful (0 votes)
2 views

DSA Question List

DSA QUESTIONS

Uploaded by

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

DSA Question List

DSA QUESTIONS

Uploaded by

Shravan Chaubey
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question on Map

**********************************
1) How can you count the frequency of each element in an array using a Map?
2) How can you use a Map to find the first non-repeating element in an array?
3) How can you use a Map to group an array of objects by a common property?
4) How can you remove duplicate elements from an array using a Map?
5) How can you use a Map to keep track of the index positions of elements in an
array?
6) How can you use a Map to find the intersection of two arrays?
7) How can you use a Map to find the common elements between multiple arrays?
8) How can you use a Map to check if two arrays are permutations of each other?
9) How can you use a Map to create a lookup table from an array of objects?
10) How can you use a Map to implement a caching mechanism for array computations?
11) How can you use a Map to store the results of an expensive function called on
each element of an array?
12) How can you use a Map to merge two arrays of objects based on a common key?
13) How can you use a Map to identify and count duplicate elements in an array?
14) How can you use a Map to track the positions of matching elements in two
arrays?
15) How can you use a Map to efficiently implement a two-sum problem in an array?

Question on Sets
***********************************
1) Basic Operations with Sets:

How do you add elements to a Set?


How do you check if an element exists in a Set?
How do you remove an element from a Set?
How do you iterate over all elements in a Set?

2) Unique Elements:

Given an array of integers, write a function to return an array of unique


elements using a Set.

3) Union of Two Sets:

Write a function to find the union of two sets.

4) Intersection of Two Sets:

Write a function to find the intersection of two sets.

5) Difference of Two Sets:

Write a function to find the difference between two sets (elements in setA but
not in setB).

6) Subset Check:

Write a function to check if one set is a subset of another.

7) Duplicate Detection:

Write a function to check if an array contains any duplicates using a Set.

8) Counting Distinct Elements:


Write a function to count the number of distinct elements in an array using a
Set.

9) Longest Consecutive Sequence:

Given an unsorted array of integers, write a function to find the length of the
longest consecutive elements sequence using a Set.

11) Common Elements in Multiple Arrays:

Write a function to find common elements in multiple arrays using Sets.

12) Removing Duplicates:

How can you use a Set to remove duplicates from a string?

13) Finding Symmetric Difference:

Write a function to find the symmetric difference between two sets (elements in
either setA or setB but not in both).

14) Set Performance:

Compare the time complexity of adding, checking for existence, and deleting
elements in a Set versus an Array.

15) Set and Object Comparison:

What are the key differences between using a Set and an Object for storing
unique values in JavaScript?

16) Set Size:

How do you determine the number of elements in a Set?

You might also like