Dynamic programming problems

Here is a list of all dynamic programming tasks from this blog.

Leetcode 303. Immutable range sum query

Leetcode 198. House robber

Leetcode 53. Maximum subarray

From a given array find the maximum contiguous subarray with the largest sum, Leetcode 53.

Leetcode 121. Best time to buy and sell stock

Leetcode 746. Min cost climbing stairs

Leetcode 70. Climbing stairs

Timus 1005. Stone pile

This is a first post which describes how to solve some particular programming task. Today we will consider Stone pile task from Timus. It is clear and easy. The task sounds like: Task Stone pile Task You have a number of stones with known weights w1, …, wn. Write a program that will rearrange the stones into two piles such that weight difference between the piles is minimal. Input Input contains the number of stones n (1 ≤ n ≤ 20) and weights of the stones w1, …, wn (integers, 1 ≤ wi ≤ 100000) delimited by white spaces.