Created
June 2, 2021 02:59
-
-
Save virtcoder/be222d442d1e342db728e1741d4a0dce to your computer and use it in GitHub Desktop.
Whiteboarding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * @param {string} s | |
| * @return {number} | |
| */ | |
| var numDecodings = function(s) { | |
| //create counter var | |
| //create traversal func- takes in start and end index | |
| //edge case | |
| // if we are at end of string | |
| // increase counter | |
| //recursion | |
| //check if first index is valid | |
| // | |
| -------------------------- | |
| //First Pass/ Idea | |
| //define helper function (isNumValid()) | |
| //if length is 1 and value is not 0 | |
| //return true | |
| //if length is 2 and value does not start with 0 and val < 26 | |
| //return true | |
| //take the first char/num in s and put it our helper func | |
| //if num is valid | |
| //call numDecodings again on the rest of string, not on what we just checked | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment