#9. Palindrome Number
Determine whether an integer is a palindrome. An integer is a
palindrome when it reads the same backward as forward.
Example 1:
Input: 121
Output: true
Example 2:Input: -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: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Follow up:Coud you solve it without converting the integer to a string?
1 | bool isPalindrome(int x) { |
#21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new
list should be made by splicing together the nodes of the first two
lists.Example:
Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4
1 | /** |
#796. Rotate String
We are given two strings, A and B.
A shift on A consists of taking string A and moving the leftmost
character to the rightmost position. For example, if A = ‘abcde’, then
it will be ‘bcdea’ after one shift on A. Return True if and only if A
can become B after some number of shifts on A.Example 1: Input: A = ‘abcde’, B = ‘cdeab’ Output: true
Example 2: Input: A = ‘abcde’, B = ‘abced’ Output: false Note:
A and B will have length at most 100.
1 | bool rotateString(char* A, char* B) { |