Skip to content

This is an Algorithm written in Javascript that checks if an array can be split into two array so that the sum of the different arrays are equal.

Notifications You must be signed in to change notification settings

samicey/canBalance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

canBalance

This is an Algorithm written in Javascript that checks if an array can be split into two array so that the sum of the different arrays are equal.

Given a non-empty array, if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side return the length of the two arrays as an array but if there is no place to split the array, return -1

canBalance([1, 1, 1, 2, 1]) → [3,2] canBalance([2, 1, 1, 2, 1]) → -1 canBalance([10, 10]) → [1,1]

About

This is an Algorithm written in Javascript that checks if an array can be split into two array so that the sum of the different arrays are equal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published