| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- DWG
- Substring with Concatenation of All Words
- Python
- Regular Expression
- kaggle
- shiba
- 프로그래머스
- Python Implementation
- 30. Substring with Concatenation of All Words
- Protocol
- 파이썬
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- LeetCode
- attribute
- 컴퓨터의 구조
- 운영체제
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- data science
- Class
- Python Code
- iterator
- 315. Count of Smaller Numbers After Self
- concurrency
- 715. Range Module
- 시바견
- Decorator
- Generator
- t1
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 |