Problem Solving/leetcode
-
Leecode - 2699. Modify Graph Edge WeightsProblem Solving/leetcode 2023. 5. 26. 22:56
내가 직접 풀진 못 했지만 다른 사람의 풀이를 보고 너무 처음보는 방식이라 정리라도 해본다.1. 문제https://leetcode.com/problems/modify-graph-edge-weights/ 그래프에서 src 출발지와 dest 목적지와 target 비용이 주어졌을 때cost가 -1인 길을 고쳐 target의 비용과 같게 만들어 return 해라. 단 -1인 길을 제외하고 이미 target보다 짧은 경로가 존재하면 실패 (빈값 리턴)-1을 고친 후에도 하나라도 target보다 짧은 경로가 존재하면 안 된다. 2. 풀이1. -1 을 경로를 처음부터 제외하고 dijkstra 돌린다.2. target 보다 짧은 경로가 있으면 빈값, target과 같은 경로가 있으면 -1을 전부 MAX로 만들고 ret..
-
Leetcode - Letter Combinations of a Phone NumberProblem Solving/leetcode 2023. 1. 15. 17:42
1. 문제 https://leetcode.com/problems/letter-combinations-of-a-phone-number/ Letter Combinations of a Phone Number - LeetCode Letter Combinations of a Phone Number - Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone leetcode.com 번호가 ..
-
Leetcode - Longest Palindromic SubstringProblem Solving/leetcode 2020. 10. 9. 03:01
Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Example 3: Input: s = "a" Output: "a" Example 4: Input: s = "ac" Output: "a" Constraints: 1 =0 && r
-
LeetCode - Longest Substring Without Repeating CharactersProblem Solving/leetcode 2020. 10. 2. 18:54
Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the ans..