Video courses for company/skill based Preparation
Purchase mock tests for company/skill building
Find non-repeating elements in an array
We will see how to find non-repeating elements from an array now. An element is said to be non-repeated element if its frequency is one. we will find this using set concepts. Read the algorithm to understand code.
Given an array print elements whose frequency is one.
- Input: arr [ ] =[1,2,5,2,6,7,5]
- Output: 1 6 7
Here 1 6 7 are the only elements with frequency one.
- Step 1: Read the array size
- Step 2: Initialize empty array
- Step 3: Read array elements and store in an array
- Step 4: Iterate through set of array (which eliminates duplicates )
- Step 5: if the element in the set of array has count 1 in array then print that element
ENTER ARRAY SIZE 7
1 6 7