[프로그래머스] LV4 징검다리
문제 설명 출발지점부터 distance만큼 떨어진 곳에 도착지점이 있습니다. 그리고 그사이에는 바위들이 놓여있습니다. 바위 중 몇 개를 제거하려고 합니다. 예를 들어, 도착지점이 25만큼 떨어져 있고, 바위가 [2, 14, 11, 21, 17] 지점에 놓여있을 때 바위 2개를 제거하면 출발지점, 도착지점, 바위 간의 거리가 아래와 같습니다. 제거한 바위의 위치 각 바위 사이의 거리 거리의 최솟값 [21, 17] [2, 9, 3, 11] 2 [2, 21] [11, 3, 3, 8] 3 [2, 11] [14, 3, 4, 4] 3 [11, 21] [2, 12, 3, 8] 2 [2, 14] [11, 6, 4, 4] 4 위에서 구한 거리의 최솟값 중에 가장 큰 값은 4입니다. 출발지점부터 도착지점까지의 거리 dis..
2021. 4. 27.
알고리즘
[leetcode] 336. Palindrome Pairs (팰린드롬 페어)
문제 설명 Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words words [i] + words [j] is a palindrome. Example 1: Input: words = ["abcd", "dcba", "lls", "s", "sssll"] Output: [[0,1], [1,0], [3,2], [2,4]] Explanation: The palindromes are ["dcbaabcd", "abcddcba", "slls", "llssssll"] Example 2: Input: words = ["ba..
2021. 4. 18.
알고리즘