From 92671d0ad91c7473f150478ae7c5ca65494c78e7 Mon Sep 17 00:00:00 2001 From: "hyungmin.oh" Date: Tue, 13 May 2025 21:28:57 +0900 Subject: [PATCH 1/2] reverse linked list --- reverse-linked-list/haung921209.md | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 reverse-linked-list/haung921209.md diff --git a/reverse-linked-list/haung921209.md b/reverse-linked-list/haung921209.md new file mode 100644 index 000000000..11a1ecd15 --- /dev/null +++ b/reverse-linked-list/haung921209.md @@ -0,0 +1,63 @@ +# 연관 링크 +- [문제 풀이 스케줄](https://github.com/orgs/DaleStudy/projects/6/views/5) +- [답안 코드 제출법](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C) + +# Problem +- 문제 링크 : https://leetcode.com/problems/reverse-linked-list/description/ +- 문제 이름 : reverse-linked-list +- 문제 번호 : 206 +- 난이도 : easy +- 카테고리 : + +# 아이디어 +- 어떤 방법으로 접근했는지 서술 +- 포스 vs 최적화 아이디어 차이 등 +- 잡도에 대한 고려 + +# ✅ 코드 (Solution) + +```cpp +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * ListNode *next; + * ListNode() : val(0), next(nullptr) {} + * ListNode(int x) : val(x), next(nullptr) {} + * ListNode(int x, ListNode *next) : val(x), next(next) {} + * }; + */ +class Solution { +public: + ListNode* reverseListSubFunc(ListNode* before, ListNode* after){ + if(!after){ + return before; + } + + auto next = after->next; + after->next = before; + return reverseListSubFunc(after, next); + } + + ListNode* reverseList(ListNode* head) { + return reverseListSubFunc(nullptr, head); + } +}; +``` + + +# 🔍 코드 설명 + + +# 최적화 포인트 (Optimality Discussion) +• 최적화한 이유와 원리 +• 더 줄일 수 있는 여지는 있는가? +• 기존 방법 대비 얼마나 효율적이었는지 + +# 🧪 테스트 & 엣지 케이스 + +# 📚 관련 지식 복습 + +# 🔁 회고 + + From 8d93ae0dac1d0c91f6745c3e9ba4b4176c2a0db4 Mon Sep 17 00:00:00 2001 From: "hyungmin.oh" Date: Sat, 17 May 2025 21:10:45 +0900 Subject: [PATCH 2/2] reverse linked Longest Substring Without Repeating Characters --- .../haung921209.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 longest-substring-without-repeating-characters/haung921209.md diff --git a/longest-substring-without-repeating-characters/haung921209.md b/longest-substring-without-repeating-characters/haung921209.md new file mode 100644 index 000000000..da1fd2228 --- /dev/null +++ b/longest-substring-without-repeating-characters/haung921209.md @@ -0,0 +1,53 @@ +# 연관 링크 +- [문제 풀이 스케줄](https://github.com/orgs/DaleStudy/projects/6/views/5) +- [답안 코드 제출법](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C) + +# Problem +- 문제 링크 : https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ +- 문제 이름 : Longest Substring Without Repeating Characters +- 문제 번호 :3 +- 난이도 : medium +- 카테고리 : + +# 아이디어 +- 마지막 위치에 대한 저장을 통한 빠른 탐색 + +# ✅ 코드 (Solution) + +```cpp +class Solution { +public: + int lengthOfLongestSubstring(string s) { + unordered_map latestIdx; + int maxLength = 0; + int start = 0; + for(int idx = 0; idx= start){ + start = latestIdx[curC]+1; + } + latestIdx[curC] = idx; + maxLength = max(maxLength, idx-start+1); + } + return maxLength; + + } +}; + +``` + +# 🔍 코드 설명 + + +# 최적화 포인트 (Optimality Discussion) +• 최적화한 이유와 원리 +• 더 줄일 수 있는 여지는 있는가? +• 기존 방법 대비 얼마나 효율적이었는지 + +# 🧪 테스트 & 엣지 케이스 + +# 📚 관련 지식 복습 + +# 🔁 회고 + +