Xin chào những người hạnh phúc 👋! Hôm nay chúng ta sẽ xem xét một vấn đề LeetCode khá dễ dàng
Nội dung chính ShowShow
- Báo cáo vấn đề
- Constraints:
- Phân tích
- Cách tiếp cận
- Độ phức tạp về thời gian
- Độ phức tạp không gian
- Sự kết luận
- Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
- Làm thế nào để bạn giải quyết một số palindrom?
- Làm thế nào để bạn kiểm tra xem một số là số palindrom?
- Số palindrom
Báo cáo vấn đề
Phân tích
Cách tiếp cận Could you solve it without converting the integer to a string?
Constraints:
-231
Độ phức tạp về thời gian
Độ phức tạp không gian
Input: x = 121 Output: trueSự kết luận
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.Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome.Làm thế nào để bạn giải quyết một số palindrom?
Input: x = -101 Output: falsePhân tích
Cách tiếp cận
Độ phức tạp về thời gian
Cách tiếp cận
Độ phức tạp về thời gian
- Độ phức tạp không gian
- Sự kết luận
- Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
- Làm thế nào để bạn giải quyết một số palindrom?
Độ phức tạp về thời gian
Độ phức tạp không gianO(log10n). The reason behind log10 is because we are dealing with integers which are base 10.
Độ phức tạp không gian
Sự kết luậnO(1).
Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
Làm thế nào để bạn giải quyết một số palindrom?
Làm thế nào để bạn kiểm tra xem một số là số palindrom?
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.1Số palindrom
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.2Xác định xem một số nguyên là một palindrom. Một số nguyên là một palindrom khi nó đọc cùng một phía sau như về phía trước.
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.3Theo dõi: Bạn có thể giải quyết nó mà không chuyển đổi số nguyên thành một chuỗi không? Could you solve it without converting the integer to a string?
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.4Sự kết luận
Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
Làm thế nào để bạn giải quyết một số palindrom?
Làm thế nào để bạn kiểm tra xem một số là số palindrom?
- Làm thế nào để bạn kiểm tra xem một số là số palindrom?
- Số palindrom
- Xác định xem một số nguyên là một palindrom. Một số nguyên là một palindrom khi nó đọc cùng một phía sau như về phía trước.
- Theo dõi: Bạn có thể giải quyết nó mà không chuyển đổi số nguyên thành một chuỗi không? Could you solve it without converting the integer to a string?
Sự kết luận
Làm thế nào để bạn tìm thấy palindrom của một số trong Python?
Làm thế nào để bạn giải quyết một số palindrom?
Làm thế nào để bạn giải quyết một số palindrom?
Làm thế nào để bạn kiểm tra xem một số là số palindrom?first reverse digits of num, then compare the reverse of num with num. If both are same, then return true, else false.
Làm thế nào để bạn kiểm tra xem một số là số palindrom?
Số palindromif the reverse of that number is equal to the original number.