Question: I recently came across this question:

Find the number of ways to divide and array into m subarrays of equal sum?
Ex: given a[]= {1, 1, 2, 3, 4, 5}, m= 2

```
{{1, 1, 2, 4}, {3, 5}}

{{1, 3, 4}, {1, 2, 5}}

```

Is there any well known algorithm for it?

Answer: 
You may have some hope to modify the pseudo-polynomial time dynamic programming algorithm for the 2-partition problem, but you have no hope for $m \geq 3$. Check the following links 
<http://en.wikipedia.org/wiki/3-partition_problem>
<http://en.wikipedia.org/wiki/Partition_problem>
[Partition Problem](http://en.wikipedia.org/wiki/Partition_problem) is known to be NP-complete.
A naive approach would be to sort the list in descending order and start with two empty sets: $S\_1, S\_2$ . Results in $O(n log n)$

Let $sum(S)$ denote the sum of elements in array $S$.

For each iteration [1 to n] add a element to $S\_1$ iff $sum(S\_1) < sum(S\_2)$ else add it to $S2$.

Example:
$S = [5, 4, 3, 2, 1, 1]$

$
S1 = []\\
S2 = []$

$
S2 = [5]\\
S1 = [4]
$

$
S2 = [5]\\
S1 = [4,3]
$

$
S2 = [5,2]\\
S1 = [4,3]
$

$
S2 = [5,2,1]\\
S1 = [4,3]
$

$
S2 = [5,2,1]\\
S1 = [4,3,1]
$