Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions combination-sum/mkwkw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//set-up
1 change: 1 addition & 0 deletions number-of-1-bits/mkwkw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//set-up
35 changes: 35 additions & 0 deletions valid-palindrome/mkwkw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class Solution {
public:
bool isPalindrome(string s) {

string str = "";

for(int i=0; i<s.length(); i++)
{
if(isalpha(s[i]))
{
str += tolower(s[i]);
}
else if (s[i]>='0' && s[i]<='9') //alpha"numeric"
{
str += s[i];
}
}
Comment on lines +7 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 생각해보지 않은 접근 방법인데요.!👍
근데 이러면 string += 연산으로 인해 O(n²)가 됩니다.
O(n)으로 줄일 수 있는 방법을 생각해보셔도 좋을 것 같네요!


//Palindrome
if(s.length()==0 || s.length()==1)
{
return true;
}

for(int i=0; i<str.length()/2; i++)
{
if(str[i]!=str[str.length()-1-i])
{
return false;
}
}

return true;
}
};