Skip to content

Instantly share code, notes, and snippets.

@blessedjasonmwanza
Created February 3, 2022 07:32
Show Gist options
  • Save blessedjasonmwanza/3cab38aa94f8a94431c82c816a68f700 to your computer and use it in GitHub Desktop.
Save blessedjasonmwanza/3cab38aa94f8a94431c82c816a68f700 to your computer and use it in GitHub Desktop.
Count length of unique characters in a string
/**
* @param {string} s
* @return {number}
*/
var lengthOfLongestSubstring = function(s) {
const unique = new Set(s.split(''));
return Array.from(unique).length;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment