From 932b4f574cebe9330506bc21d72a03ccab740207 Mon Sep 17 00:00:00 2001 From: HongStudy Date: Thu, 20 Nov 2025 00:39:23 +0900 Subject: [PATCH 1/2] [week2] Valid Anagramp Sold --- valid-anagram/Hong-Study.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 valid-anagram/Hong-Study.cpp diff --git a/valid-anagram/Hong-Study.cpp b/valid-anagram/Hong-Study.cpp new file mode 100644 index 0000000000..47c987a513 --- /dev/null +++ b/valid-anagram/Hong-Study.cpp @@ -0,0 +1,34 @@ +''' +Time Complexity: O(n log n) +- 분류 정렬에서 O(n log n) 발생 + +Run time +- 7ms + +Memory +- 9.56 MB + +최적화쪽으로 수정 추가 필요 +''' +class Solution { +public: + bool isAnagram(string s, string t) { + // 선 길이 체크 + if (s.length() != t.length()) { + return false; + } + + // 두 배열 정렬(n log n) + std::sort(s.begin(), s.end()); + std::sort(t.begin(), t.end()); + + // 비교하여 다르면 false + for (int i = 0; i < s.length(); i++) { + if (s[i] != t[i]) { + return false; + } + } + + return true; + } +}; From bb028235fe5a001703d6de10c81b154e5dcc709d Mon Sep 17 00:00:00 2001 From: HongStudy Date: Fri, 21 Nov 2025 01:31:20 +0900 Subject: [PATCH 2/2] [week2] climbing stairs sold --- climbing-stairs/Hong-Study.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 climbing-stairs/Hong-Study.cpp diff --git a/climbing-stairs/Hong-Study.cpp b/climbing-stairs/Hong-Study.cpp new file mode 100644 index 0000000000..6ef9267cfe --- /dev/null +++ b/climbing-stairs/Hong-Study.cpp @@ -0,0 +1,18 @@ +class Solution { +public: + int climbStairs(int n) { + std::map stepMap; + stepMap[1] = 1; + stepMap[2] = 2; + + if (n == 1) { + return stepMap[n]; + } + + for (int i = 3; i <= n; i++) { + stepMap[i] = stepMap[i - 1] + stepMap[i - 2]; + } + + return stepMap[n]; + } +};