- Define a hash function
- Explain how a hash table can be used to increase the performance of an algorithm
Turn to your neighbot and define what a hash function is
Turn to your neighbor and discuss how a hash table can increase the performance of to following problem.
function hasDuplicates(str){
for(let i = 0; i < str.length; i++){
for(let j = 0; j < str.length; j++){
if(i !== j && str[i] === str[j]) return true;
}
}
return false;
}
hasDuplicates('123456') // false
hasDuplicates('123416') // true