일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- timechat
- memory bank
- timestamp-aware frame encoder
- leetcode
- tensorflow
- 코딩테스트
- multimodal machine learning
- long video understanding
- Artificial Intelligence
- Python
- LeNet-5
- ma-lmm
- Kaggle
- q-former
- hackerrank
- Linux
- secure-file-priv
- autogluon
- Github
- transference
- jmeter
- 백준
- quantification
- 용어
- CNN
- sliding video q-former
- MySQL
- Server
- Anaconda
- error
Archives
- Today
- Total
반응형
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- timechat
- memory bank
- timestamp-aware frame encoder
- leetcode
- tensorflow
- 코딩테스트
- multimodal machine learning
- long video understanding
- Artificial Intelligence
- Python
- LeNet-5
- ma-lmm
- Kaggle
- q-former
- hackerrank
- Linux
- secure-file-priv
- autogluon
- Github
- transference
- jmeter
- 백준
- quantification
- 용어
- CNN
- sliding video q-former
- MySQL
- Server
- Anaconda
- error
Archives
- Today
- Total
Juni_DEV
[Python, LeetCode] 9. Palindrome Number 본문
반응형
주어진 문제
더보기
Given an integer x, return true if x is a palindrome, and false otherwise.
Example 1:
Input: x = 121
Output: true
Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:
Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3:
Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Constraints:
- -2^(31) <= x <= 2^(31) - 1
Follow up: Could you solve it without converting the integer to a string?
파이썬 리스트 뒤집기
- 슬라이싱 [::-1]
- .reverse() 메서드
- 내장함수 list(reversed())
풀이
def isPalindrome(self, x: int) -> bool:
# 배열 뒤에서부터 세기
# if str(x)[::-1] == str(x) :
# return ('true')
return str(x)[::-1] == str(x)
참고 :
https://codetorial.net/tips_and_examples/reverse_python_list_or_numpy_array.html
반응형
'Coding Interview' 카테고리의 다른 글
[Python, HackerRank] Divisible Sum Pairs (0) | 2023.04.19 |
---|---|
[Python, HackerRank] Camel Case 4 (0) | 2023.04.19 |
[Python, HackerRank] Breaking the Records (0) | 2023.04.14 |
[Python, LeetCode] 1. Two Sum (0) | 2023.04.14 |
[Python, HackerRank] Mini-Max Sum (0) | 2023.04.13 |
Comments