JavaScript: Best Way to return true if found values repeated in an array -


possible duplicate:
easiest way find duplicate values in javascript array

let's have array thousands of elements ,

i want return true if there 2 or more elements same value.

i know can run for loop , check on every pair of elements find answer.

but there faster way? , what's best way?

this element distinctness problem. can read it, 1000 elements, optimizations not worth it.

if want optimize it, can push elements hash table , check if collisions duplicates. give o(n) on average (amortized), o(n^2) in worst case.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -