I want to create a function in C. It will return a random integer in-range of N like:-
rand() % N;
but the thing is I want to keep track of uniqueness. I don't want the numbers to repeat. but i can also do this by making an array and copying the generated integers in it. like :-
array[count] = rand() % N;
and check every time if the number generated was already inside it or not. (simply by searching it inside the array[]); this is a simple approach but a correct one. it will take many if's and for's; for this to work.
this is the best i can come up with.
The thing is, I want to get the best possible/optimized solution for this problem. What will be the most efficient way to do this?
lets clear some things:- i want to set some text in a UILabel from a NSArray that is always unique. my NSArray is getting data from a Plist, and my Plist has over 1000 entries. if i want to do this many times it will effect the performance so i want some efficient way to do this.