Skip to content

Instantly share code, notes, and snippets.

@aajjbb
Created July 19, 2013 17:44
Show Gist options
  • Save aajjbb/6040993 to your computer and use it in GitHub Desktop.
Save aajjbb/6040993 to your computer and use it in GitHub Desktop.
struct TrafficCongestionDivTwo {
long long theMinCars(int treeHeight) {
int i;
Int ans = 1LL;
for (i = treeHeight; i >= 1; i -= 2) {
ans += (Int) (pow(2, i) / 2);
}
if (treeHeight % 2 != 0) ans -= 1LL;
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment