Nice Binary Trees
below given code is for nicebtre spoj or nice binary trees spoj.
My code looks weird so get my code modified from net. :p
#include <stdio.h> char s[10001]; int i; int max(int p,int q) { return p > q ? p : q; } int length() { if (s[i++] =='l') return 1; else return max(length(),length())+1; } int main() { int t; scanf("%d",&t); while (t--) { scanf("%s", s); i=0; printf("%d\n",length() - 1); } return 0; }
No comments:
Post a Comment
Your comment is valuable to us