There is nothing much particular to java,,
Here is the code(simply copy pasted from the above one) in C::
     int main(){
            char ar[1000000];
            int dp[10000000];
            scanf("%s",ar);
            if(ar[l-1]!='0')
            dp[l-1]=1;
            for(int j=l-2;j>=0;j--)
            {
                int a=ar[j]-'0',b=ar[j+1]-'0';
                if(j==(l-2)  && (10*a+b)<=26)
                {
                if(a!=0)
                dp[j]=1+dp[j+1];
                }
                else if(j==(l-2) && (10*a+b)>26)
                dp[j]=dp[j+1];
                else if(j!=(l-2) && (10*a+b)<=26)
                {
                    if(a!=0)
                    dp[j]=dp[j+1]+dp[j+2];
                }
                else
                {
                    dp[j]=dp[j+1];
                }
            }
            printf("%d\n",dp[0]);
            return 0;
       }

-- 
*Regards,*
*Piyush Kapoor,*
*2nd year,CSE
IT-BHU*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to