Skip to content

Instantly share code, notes, and snippets.

@sreeprasad
Created August 24, 2019 05:28
Show Gist options
  • Save sreeprasad/46decd02b1516409efce5b620cef5216 to your computer and use it in GitHub Desktop.
Save sreeprasad/46decd02b1516409efce5b620cef5216 to your computer and use it in GitHub Desktop.
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