Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c8d545

Browse files
p202
1 parent c802d25 commit 0c8d545

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

‎AllQuestions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,7 @@ For example, 1 -> 3 -> 5. The weight of the path is the sum of the entries.
31933193

31943194
Write a program that returns the weight of the maximum weight path.
31953195

3196-
## Problem-202:waxing_crescent_moon:
3196+
## [Problem-202](src/main/java/in/ashwanik/dcp/problems/p181_210/p202):sunny:
31973197

31983198

31993199
> This problem was asked by Palantir.

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ Solutions to the coding problems from [Daily coding problem](https://dailycoding
8383
|[P21](src/main/java/in/ashwanik/dcp/problems/p1_30/p21)|[P77](src/main/java/in/ashwanik/dcp/problems/p61_90/p77)|[P131](src/main/java/in/ashwanik/dcp/problems/p121_150/p131)|
8484

8585

86-
## **Palantir (2)**
87-
| | |
88-
|--|--|
89-
|[P28](src/main/java/in/ashwanik/dcp/problems/p1_30/p28)|[P95](src/main/java/in/ashwanik/dcp/problems/p91_120/p95)|
86+
## **Palantir (3)**
87+
| | ||
88+
|--|--|--|
89+
|[P28](src/main/java/in/ashwanik/dcp/problems/p1_30/p28)|[P95](src/main/java/in/ashwanik/dcp/problems/p91_120/p95)|[P202](src/main/java/in/ashwanik/dcp/problems/p181_210/p202)|
9090

9191

9292
## **Two Sigma (2)**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Write a program that checks whether an integer is a palindrome. For example, 121
2+
is a palindrome, as well as 888. 678 is not a palindrome. Do not convert the
3+
integer into a string.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package in.ashwanik.dcp.problems.p181_210.p202;
2+
3+
class Solution {
4+
5+
6+
///1234
7+
boolean isPalindrom(int number) {
8+
if (number == 0) {
9+
return true;
10+
}
11+
12+
int reverse = 0;
13+
14+
int n = number;
15+
int mod = 0;
16+
while (n > 0) {
17+
mod = n % 10;
18+
reverse = reverse * 10 + mod;
19+
n = n / 10;
20+
}
21+
return number == reverse;
22+
}
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package in.ashwanik.dcp.problems.p181_210.p202;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
7+
8+
public class SolutionTest {
9+
10+
@Test
11+
void testIsPalindrome() {
12+
assertTrue(new Solution().isPalindrom(12321));
13+
assertFalse(new Solution().isPalindrom(1234));
14+
}
15+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /