DIR Return Create A Forum - Home
---------------------------------------------------------
techsuns
HTML https://techsuns.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Puzzles && Algorithms
*****************************************************
#Post#: 396--------------------------------------------------
repeated elements again!!!
By: dinesh Date: December 10, 2012, 10:59 pm
---------------------------------------------------------
Given an array of n elements containing positive integers from 1
... n-1. Now we have to find the repeating elements but
condition here is any element could be repeated any number of
times. Time complexity O(n). Do not use an another array.
#Post#: 414--------------------------------------------------
Re: repeated elements again!!!
By: Kaliuday Balleda Date: December 13, 2012, 10:54 pm
---------------------------------------------------------
Sort the elements and check for consequtive elements repetitions
using a for loop which goes 4 N elts! If an elt repeats print
out!
#Post#: 415--------------------------------------------------
Re: repeated elements again!!!
By: dinesh Date: December 14, 2012, 12:13 am
---------------------------------------------------------
@ Kali: I did not understand how a for loop 4 N elts can solve
the problem? can you explain further...
Also, sorting taken O(nlogn) time.
#Post#: 448--------------------------------------------------
Re: repeated elements again!!!
By: kpr29 Date: February 14, 2013, 10:46 pm
---------------------------------------------------------
@Majeti : from ur question, I uderstood the array elements are
1,...n-1, but totally there are n elements so one is
repeating.... is it right......
kp.
#Post#: 449--------------------------------------------------
Re: repeated elements again!!!
By: dinesh Date: February 15, 2013, 12:30 am
---------------------------------------------------------
any element could be repeated any number of times
*****************************************************