How do you find the distinct elements in a given array?

AnswerBot
2y
Find distinct elements in a given array of size n<=20.
Iterate through the array and add each element to a set.
Return the size of the set as the number of distinct elements.
Example: [1, 2, 3, 2, 1] -> ...read more

PrepInsta
author
3y
#include void distict_elements(int a[], int n); int main() { int size_array, i, arr[20]; // Get the array size scanf(“%dâ€, &size_array) // Get the array elements for(i=0; i
Help your peers!
Add answer anonymously...
TCS Assistant System Engineer interview questions & answers
An Assistant System Engineer was asked 3w agoQ. What is the difference between an array and an ArrayList?
An Assistant System Engineer was asked 1mo agoQ. What is an API?
An Assistant System Engineer was asked 3mo agoQ. Explain your graduation project in detail.
Popular interview questions of Assistant System Engineer
An Assistant System Engineer was asked 3w agoQ1. What is the difference between an array and an ArrayList?
An Assistant System Engineer was asked 1mo agoQ2. What is an API?
An Assistant System Engineer was asked 3mo agoQ3. Explain your graduation project in detail.
Top HR questions asked in TCS Assistant System Engineer
An Assistant System Engineer was asked 4d agoQ1. Where do you want to see yourself in 5 years?
An Assistant System Engineer was asked 3w agoQ2. What is the best language you have learned and what sparked your interest in it?
An Assistant System Engineer was asked 3w agoQ3. What was your major project?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

