일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- DailyLeetCoding
- VCS
- Leedcode
- Union Find
- BFS
- dfs
- Easy
- python3
- ArrayList vs LinkedList
- Hashtable
- greedy
- leetcode
- hash
- graph
- sorting
- hash table
- 구현
- Bellman-Ford
- stack
- array
- Two Pointers
- A* Algorithm
- 광연자동차운전면허학원
- heap
- LinkedList
- String
- 자료구조
- Java
- Medium
- SinglyLinkedList
Archives
- Today
- Total
목록Implementation (1)
Min IT's Devlog

풀이 일자: 23.07.03 난이도: [Easy] 분류: [Hash] 문제 내용 2개의 string이 주어지고 s에서 2 문자의 자리를 바꿨을 때 goal이 될 수 있는지 리턴하는 문제이다. 문제 해결 흐름 1. 일단 불가능한 경우과 가능한 경우가 있을텐데 불가능한 경우의 경우의 수가 훨씬 많을 것이다. → 크게 나누면 len이 다른 경우, len이 같은데 들어가 있는 문자 수가 다른 경우, 자리를 바꾸더라도 불가능한 문자인 경우 이렇게 나눌 수 있을 것이다. class Solution: def buddyStrings(self, s: str, goal: str) -> bool: sc = Counter(s); gc = Counter(goal); if sc != gc: # 크기가 다르거나 문자의 갯수가 다른..
코테/LeetCode(Solve)
2023. 7. 3. 12:48