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