Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.
일련의 정수를 확인하여, 가장 큰 수와 인접한 요소를 찾아 곱한 값을 구하라
Example
For inputArray = [3, 6, -2, -5, 7, 3], the output should beadjacentElementsProduct(inputArray) = 21.
7 and 3 produce the largest product.
inputArray: [-1, -2]
Expected Output:2
inputArray: [5, 1, 2, 3, 1, 4]
Expected Output: 6
inputArray: [9, 5, 10, 2, 24, -1, -48]
Expected Output: 50
Code
int adjacentElementsProduct(int[] inputArray) {2
9
}'알고리즘(CF)' 카테고리의 다른 글
| 6. make Array Consecutive2 (1) | 2017.06.07 |
|---|---|
| 5. shapeArea (1) | 2017.06.07 |
| 3. checkPalindrome (1) | 2017.06.07 |
| 2. centuryFromYear (1) | 2017.06.07 |
| 1. add (1) | 2017.06.07 |