Skip to content

Instantly share code, notes, and snippets.

@theand
Created January 22, 2018 08:51
Show Gist options
  • Save theand/02208196f062412d28a68bc545e8b4b1 to your computer and use it in GitHub Desktop.
Save theand/02208196f062412d28a68bc545e8b4b1 to your computer and use it in GitHub Desktop.
정수 배열(int array)가 주어지면 가장 큰 이어지는 원소들의 합을 구하시오
var array1 = [-1, 3, -1, 5];
var array2 = [-5, -3, -1];
var array3 = [2, 4, -2, -3, 8];
const map1 = array3.map( (e,i,a) => {
return a.slice(i).reduce( (a, b) => a+b, 0);
});
console.log(Math.max(...map1));
@theand
Copy link
Author

theand commented Jan 22, 2018

시간 복잡도 1은 처리하기 귀찮아서 스킵.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment