[LeetCode] 2825. Make String a Subsequence Using Cyclic Increments (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given two 0-indexed strings str1 and str2.In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'.Return true if it is possible to make str2 a subsequence of str1 by performing the operation at most once, and false ot..
[Programmers] [PCCP 기출문제] 3번 / 충돌위험 찾기 - Python
·
알고리즘/프로그래머스
난이도: Lv. 2 문제 설명어떤 물류 센터는 로봇을 이용한 자동 운송 시스템을 운영합니다. 운송 시스템이 작동하는 규칙은 다음과 같습니다.물류 센터에는 (r, c)와 같이 2차원 좌표로 나타낼 수 있는 n개의 포인트가 존재합니다. 각 포인트는 1~n까지의 서로 다른 번호를 가집니다.로봇마다 정해진 운송 경로가 존재합니다. 운송 경로는 m개의 포인트로 구성되고 로봇은 첫 포인트에서 시작해 할당된 포인트를 순서대로 방문합니다.운송 시스템에 사용되는 로봇은 x대이고, 모든 로봇은 0초에 동시에 출발합니다. 로봇은 1초마다 r 좌표와 c 좌표 중 하나가 1만큼 감소하거나 증가한 좌표로 이동할 수 있습니다.다음 포인트로 이동할 때는 항상 최단 경로로 이동하며 최단 경로가 여러 가지일 경우, r 좌표가 변하는 이..
[LeetCode] 2109. Adding Spaces to a String - Python
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index. For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "En..
[LeetCode] 1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence - Python
·
알고리즘/LeetCode
난이도: Easy문제 설명Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.A pr..
[LeetCode] 1346. Check If N and Its Double Exist - Python
·
알고리즘/LeetCode
난이도: Easy문제 설명Given an array arr of integers, check if there exist two indices i and j such that :i != j0 arr[i] == 2 * arr[j] 문제 예제Example 1:Input: arr = [10,2,5,3]Output: trueExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j] Example 2:Input: arr = [3,1,7,11]Output: falseExplanation: There is no i and j that satisfy the conditions. 제한 사항2 -10^3  ✏️ Solution(솔루션)class Solutio..
[Programmers] 섬 연결하기 - Python
·
알고리즘/프로그래머스
난이도: Lv.3 문제 설명개의 섬 사이에 다리를 건설하는 비용(costs)이 주어질 때, 최소의 비용으로 모든 섬이 서로 통행 가능하도록 만들 때 필요한 최소 비용을 return 하도록 solution을 완성하세요. 다리를 여러 번 건너더라도, 도달할 수만 있으면 통행 가능하다고 봅니다. 예를 들어 A 섬과 B 섬 사이에 다리가 있고, B 섬과 C 섬 사이에 다리가 있으면 A 섬과 C 섬은 서로 통행 가능합니다. 제한 사항섬의 개수 n은 1 이상 100 이하입니다.costs의 길이는 ((n-1) * n) / 2이하입니다.임의의 i에 대해, costs[i][0] 와 costs[i] [1]에는 다리가 연결되는 두 섬의 번호가 들어있고, costs[i] [2]에는 이 두 섬을 연결하는 다리를 건설할 때 드는..