Skip to content

Commit

Permalink
Merge pull request #348 from benlowenthal/main
Browse files Browse the repository at this point in the history
Added leading zeros to titles
  • Loading branch information
QasimWani authored Oct 9, 2022
2 parents a36191a + 55eb480 commit 1c53d70
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,16 @@ function getProblemNameSlug() {
questionTitle = qtitle[0].innerText;
}
}
return convertToSlug(questionTitle);
return addLeadingZeros(convertToSlug(questionTitle));
}

function addLeadingZeros(title) {
const maxTitlePrefixLength = 4;
var len = title.split('-')[0].length;
if (len < maxTitlePrefixLength) {
return '0'.repeat(4 - len) + title;
}
return title;
}

/* Parser function for the question and tags */
Expand Down

0 comments on commit 1c53d70

Please sign in to comment.