mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-29 16:53:12 +03:00
commit
d7ed5ea470
@ -11,6 +11,7 @@ LeetCode
|
||||
|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | [C](./src/3.c)|Medium|
|
||||
|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | [C](./src/4.c)|Hard|
|
||||
|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer/) | [C](./src/7.c)|Easy|
|
||||
|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number/) | [C](./src/9.c)|Easy|
|
||||
|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer/) | [C](./src/13.c)|Easy|
|
||||
|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses/) | [C](./src/20.c)|Easy|
|
||||
|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/) | [C](./src/21.c)|Easy|
|
||||
|
13
leetcode/src/9.c
Normal file
13
leetcode/src/9.c
Normal file
@ -0,0 +1,13 @@
|
||||
bool isPalindrome(int x){
|
||||
if(x < 0 || (x % 10 == 0 && x != 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int revertedNumber = 0;
|
||||
while(x > revertedNumber) {
|
||||
revertedNumber = revertedNumber * 10 + x % 10;
|
||||
x /= 10;
|
||||
}
|
||||
|
||||
return x == revertedNumber || x == revertedNumber/10;
|
||||
}
|
Loading…
Reference in New Issue
Block a user