메모장 입니다2
Reading] codility - MaxProfit 본문
An array A consisting of N integers is given.
N개의 정수로 구성된 배열 A가 주어진다.
It contains daily prices of a stock share for a period of N consecutive days.
그것엔 N의 연속된 기간동안의 주식 가격이 포함된다.
If a single share was bought on day P and sold on day Q, where 0 ≤ P ≤ Q < N, then the profit of such transaction is equal to A[Q] − A[P], provided that A[Q] ≥ A[P].
만약 단일 주식을 P날에 샀고 Q날에 팔았다면, 0<= P <= Q이고, 거래는 A[Q] - A[P]와 같다, ~~??
Otherwise, the transaction brings loss of A[P] − A[Q].
그외에, 거래는 A[P] -A[Q]의 손실을 가져온다.
For example, consider the following array A consisting of six elements such that:
A[0] = 23171 A[1] = 21011 A[2] = 21123 A[3] = 21366 A[4] = 21013 A[5] = 21367
예를들어, 다음과 같은 6개의 요소로 구성된 배열 A가 있다고 고려해봐라.
~~~
If a share was bought on day 0 and sold on day 2, a loss of 2048 would occur because A[2] − A[0] = 21123 − 23171 = −2048.
If a share was bought on day 4 and sold on day 5, a profit of 354 would occur because A[5] − A[4] = 21367 − 21013 = 354. Maximum possible profit was 356.
만약 주식을 day 0에 샀고 day 2에 팔았다면, 2048의 손실이 발생한다/ A[2] - A[0] = 21123
- 23171 = -2048이기 때문에.
만약 ~~~ , 354의 수익이 발생한다.
~~~. 최대의 가능한 수익은 356이었다.
Write a function,
def solution(A)
함수를 작성해라
that, given an array A consisting of N integers containing daily prices of a stock share for a period of N consecutive days, returns the maximum possible profit from one transaction during this period.
N의 연속된 기간의 주식의 가격이 포함된, N개의 정수로 구성된 배열 A가 주어지면,
이 기간동안의 거래로부터 최대 가능한 수익을 반환해라.
The function should return 0 if it was impossible to gain any profit.
함수는 0을 반환해야 한다. 만약 어떤 수익도 얻는것이 불가능하다면.
as explained above.
위 설명에 따르면.
'Study > 영어' 카테고리의 다른 글
Listening] 유튜브 동영상 목록 (0) | 2018.12.29 |
---|---|
Reading] Chances are (0) | 2018.04.08 |
Reading] codility - dominator (0) | 2018.03.28 |
Reading] codility - (0) | 2018.02.07 |
Reading] codility - Fish (0) | 2018.02.03 |