일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- Protocol
- 운영체제
- Regular Expression
- Python Code
- Class
- kaggle
- Substring with Concatenation of All Words
- LeetCode
- 43. Multiply Strings
- 밴픽
- 715. Range Module
- Python Implementation
- 시바견
- attribute
- data science
- 컴퓨터의 구조
- t1
- 315. Count of Smaller Numbers After Self
- 109. Convert Sorted List to Binary Search Tree
- 프로그래머스
- iterator
- shiba
- 30. Substring with Concatenation of All Words
- Generator
- Convert Sorted List to Binary Search Tree
- 파이썬
- DWG
- concurrency
- Decorator
Archives
- Today
- Total
Scribbling
[C++] isalnum, tolower 본문
LeetCode 125. Valid Palindrome
https://leetcode.com/problems/valid-palindrome/
Valid Palindrome - LeetCode
Can you solve this real interview question? Valid Palindrome - A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric cha
leetcode.com
class Solution {
public:
bool isPalindrome(string s) {
vector<char> vec;
for (char c : s) {
if (isalnum(c)) {
vec.push_back(tolower(c));
}
}
if (vec.empty()) {
return true;
}
auto left = vec.begin();
auto right = vec.end() - 1;
while (left < right) {
if (*left != *right) {
return false;
}
left++;
right--;
}
return true;
}
};
'Computer Science > C++' 카테고리의 다른 글
[C++] Load Balancing (0) | 2023.08.19 |
---|---|
[C++] lower_bound, upper_bound (0) | 2023.08.18 |
[C++] LeetCode 128. Longest Consecutive Sequence (0) | 2023.08.18 |
[C++] LeetCode 238. Product of Array Except Self (0) | 2023.08.18 |
[C++] priority queue (vector<int>) with comparator (0) | 2023.08.18 |