Created
August 24, 2019 05:28
-
-
Save sreeprasad/46decd02b1516409efce5b620cef5216 to your computer and use it in GitHub Desktop.
This file contains 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
private int findIndex(String S){ | |
int N = S.length(); | |
int ans = (1<<N)-2; | |
int pos=0,i=N-1; | |
while(i>=0) { | |
if(S.charAt(i)=='7') { | |
ans += (1<<pos); | |
} | |
i--; | |
pos++; | |
} | |
return (ans+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment