Check out example codes for "lazer codechef". It will help you in understanding the concepts better.

Code Example 1

1
4 3
1 3 5 1
2 4 4
1 2 3
1 4 1

Learn ReactJs, React Native from akashmittal.com