You are viewing a single comment's thread. Return to all comments →
My C++ solution -
int utopianTree(int n) { int height = 1; auto is_odd = [](int num){ return (num & 1);}; for (int i=1;i<=n;i++) { if (is_odd(i)) { height *= 2; } else { height += 1; } } return height; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Utopian Tree
You are viewing a single comment's thread. Return to all comments →
My C++ solution -