Skip to content

Instantly share code, notes, and snippets.

Avatar

Huei Tan hueitan

View GitHub Profile
View anagrams.md
function numberOfAnagrams(S) {

  // S.length!/repeat!
  
  var total = factorial(S.length),
	repeat = 1,
      array = S.split('').sort();
  
  for (var i=1;i<array.length;i++) {
View chessboard-knight-move.md
function blackOrWhite(s) { // true: black, false: white
  var vertical = s[0].charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  var horizon = s[1];
  if (vertical % 2 == 1) { // vertical odd
    if (horizon % 2 == 0) { // horizon even
      return false;
    }
    return true;
  } else { // vertical even
View frontendDevlopmentBookmarks.md
You can’t perform that action at this time.