Source Link:
https://leetcode.com/problems/palindrome-number/description/
Question:
Determine whether an integer is a palindrome. Do this without extra space.
My Solution:
Note:
1. "palindrome" means "the integer" is equal to "the reverse_integer"
2. to reverse integer (loop) Step1: %10, Step2: *10, Step3: /10
while( temp_integer !=0){
int tail = temp_integer % 10;
reverse_integer = reverse_integer * 10 + tail;
temp_integer = temp_integer / 10;
}
3. if "the reverse_integer" is equal to "the integer"
if(reverse_integer == x)
return true;
Subscribe to:
Post Comments (Atom)
Codility - Lesson 16 Greedy algorithms - 2. MaxNonoverlappingSegments
Source Link: https://app.codility.com/programmers/lessons/16-greedy_algorithms/max_nonoverlapping_segments/ Question: Located on a line ...
-
Source Link: https://app.codility.com/programmers/lessons/15-caterpillar_method/count_distinct_slices/ Question: An integer M and a...
-
Source Link: https://app.codility.com/programmers/lessons/15-caterpillar_method/count_triangles/ Question: A zero-indexed array A consi...
-
Source Link: https://codility.com/programmers/lessons/9-maximum_slice_problem/max_slice_sum/ Question: A non-empty zero-indexed array A...
No comments:
Post a Comment