[HackerRank][Python3] Candies
2018. 6. 14. 03:00 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/candies/problem
My Solution :
#!/usr/bin/env python3 def candies(n, arr): c = [1]*n for i in range(n-1): if arr[i] < arr[i+1]: c[i+1] = c[i] + 1 for j in range(n-1, 0, -1): if arr[j] < arr[j-1] and c[j] >= c[j-1]: c[j-1] = c[j] + 1 return sum(c) n = int(input()) arr = [] for _ in range(n): arr_item = int(input()) arr.append(arr_item) result = candies(n, arr) print(result)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Array Manipulation (0) | 2018.07.09 |
---|---|
[HackerRank][Python3] New Year Chaos (0) | 2018.07.07 |
[HackerRank][Python3] Minimum Swaps 2 (0) | 2018.07.06 |
[HackerRank][Python3] Is This a Binary Search Tree? (2) | 2018.06.25 |
[HackerRank][Python3] Two Characters (0) | 2018.06.11 |
[HackerRank][Python3] Append and Delete (0) | 2018.06.10 |
[HackerRank][Python3] Recursive Digit Sum (0) | 2018.06.07 |
[HackerRank][Python3] Sam and substrings (0) | 2018.06.06 |
최근에 달린 댓글 최근에 달린 댓글