Compress String

Question A simple compression algorithm would be to replace repeating characters with their count. Example aaa --> a3 aaabb --> a3b2 aaabbaa --> a3b2a2 Want to stand out? Ask if there’s a difference between a & A and if you need to add uppercase & lowercase together or need to separate them. In my implementation I assumed they’re different. Code // start counting, then upon seeing a diff, write the count....

June 15, 2022 Β· 1 min

Check if Two Strings Are One Edit Away

Question You can edit a string in three different ways: insert, remove or replace a character. Write a function to see if two strings are one or zero edits away. Example like, like --> true (zero edits) like, likes --> true (one edit: remove/insert) like, life --> true (one edit, replace) like, lik --> true (one edit: remove/insert) like, pine --> false (two edits) like, lion --> false (two edits) Strategy For most questions that require you to return true or false, you can reduce the scope of the question by removing noise....

June 15, 2022 Β· 3 min