java - pseudo code to find the numbers which appear more than once in a list -



java - pseudo code to find the numbers which appear more than once in a list -

i have series 1,2,199,100,8,100,199,1001,5,9 , got write pseudo code find out numbers appear more 1 time in above list. can see 199 , 100 appear twice in list , should reply how should write pseudocode it? logic this:

array x = {1,2,199,100,8,100,199,1001,5,9} array y array j for(int = 0;i< 9; i++){ if x[i] exists in y j[i] = y else y[i] = x }

sort list quick sort or merge sort (n log n) single pass on list comparing current number previous o(n). if previous number equals current have duplicate.

edit:

array array = {1,2,199,100,8,100,199,1001,5,9} array sorted = sort(array) (int i=1; i<sorted.length; i++) int p = sorted[i-1] int c = sorted[i] if (p==c) print "duplicate"

java algorithm pseudocode series

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -