unique('bacdefgxpedl');
function unique(str){
const chars = str.split('').sort(); // O(n * log(n))
for(let i = 1; i < chars.length ; i++){ // O(n)
if( chars[i] === chars[i-1] ){ //
console.log('unique FALSE')
return false;
}
}
console.log('unique TRUE')
return true;
}
//Time: O(n *log(n)) + O(n) => O(n + n *log(n)) => O(n * log(n))
//Space: O(n) we take the same amount of space that the size of the input.