Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int skyline_solution(const unsigned int skylineHeights[], unsigned int arrLen) {
- if (arrLen <= 0) { return 0; }
- unsigned int stripes = skylineHeights[0];
- for (int i = 1; i < arrLen; i++)
- {
- if (skylineHeights[i] > skylineHeights[i - 1]) {
- stripes += (skylineHeights[i] - skylineHeights[i - 1]);
- }
- }
- if (stripes > 1000000000) { return -1; }
- return stripes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement