Count occurrence of repeated element in array || Count duplicate element || Java | Fox Tech Academy

preview_player
Показать описание
How to count occurrence of repeated element in array in java.
Program to count repeated element in arrays.
Top coding questions asked in recent exams :

If you feel any difficulties in coding,
feel free to ask, we are here to help you.

Thanks :
Fox Tech Academy
WhatsApp : +91 8252348796
Рекомендации по теме
Комментарии
Автор

after searching so many videos, landed up here and it was easy to understand. Thanks a lot, could you also please make a video with solution for this - print the count of non-repeated elements in the array.

rashmilakshmanaiah
Автор

perfect!! Thanks a lot...
sir at line 27 we can declare as i+= (count);

Sarath_Mannam
Автор

All good but due to loop inside loop time complexity is high .

abhaymishra
Автор

Second loop condition is not correct, j should start checking from 0th index, if array is{1, 2, 1, 3, 2, 1} will your code run for this?

gauhar.fatima
Автор

thanks brother. this video makes me lot of pecace.

toufikulislameyasin
Автор

If i want 1 count elements so how can i get with this?

neeturajput
Автор

brilliant bro, thanks
we will keep supporting you. good job
all the best

Abhishek-ybkb
Автор

Bro thoda aaram se marathon daud rha hai kya ?

rupesh
Автор

Speak slowly slowly in professional style then it will be understandable clearly
Don't mind your logic is better

nitishsharma
Автор

Hello can you upload a video on assigning Boolean values to an array of size, say 3, like
Value 1 = true
Value 2= false
Value 3= true
Now I want to calculate number of time true Occured and number of times false Occured. Please help on this m stuck badly...if not a video pls share stub code or even logic so I can understand

pranavsinghofficial
Автор

How to print highest repeated number 1st
[1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3]
3 should be printed first followed by 4

deevenarajumungara
Автор

Can we solve this problem without if function

Sy
Автор

Simple Code


package Mumbai;

import java.util.Arrays;

public class Dombivali
{
public static void main(String[] args)
{

int [] a = {5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1};

Arrays.sort(a);

for(int i = 0 ; i<a.length;i++)
{
int count = 1 ;
for(int j = i + 1 ; j<a.length; j++)
{
if(a[i]==a[j])
{
count ++ ;
}
}

if(count>0) // put count>1 if we want to find only duplicate with count
{

i+= count-1 ;
}

}
}
}

shubhamshinde
Автор

daaalna hua kre to optimized code bhi daaala kro, double loop laga ke to har program ka chutiya hum bhi kaaat lenge

_aashish_kumar
Автор

I want to enter values of array from keyboard please make a video on this

sweetthirty
Автор

bhai hindi mai bol le agar english nhi aate

Akarshvyas
join shbcf.ru