![]() |
Geek has N packs of chocolates and the amount of chocolates in each pack is given in an array arr[]. His sister wants to have a pack of chocolate. Geeks being greedy will pick the packs with more number of chocolates but he can pick from either first or last. Find the number of chocolates his sister will get. Examples:
Approach: The problem can be solved using the following observation:
Follow the below steps to implement the idea:
Below is the implementation of the above approach. C++
Output
1 Time Complexity: O(N) As we are traversing the array once |
Reffered: https://www.geeksforgeeks.org
Arrays |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |