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