Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1083 |
@bt8816103042 | 739 |
@SherlockHolmes3 | 444 |
@SHOAIBVIJAPURE | 430 |
@codeantik | 429 |
@shalinibhataniya1097 | 400 |
@ShamaKhan1 | 392 |
@neverevergiveup | 372 |
@amrutakashikar2 | 355 |
@murarry3625 | 350 |
@mahlawatep | 349 |
Complete Leaderboard |
Given a number N. Check whether N is a Twisted Prime number or not.
Note: A number is called Twisted Prime if it is a prime and its reverse is also a prime.
Example 1:
Input: N = 97
Output: 1
Explanation: 97 is a prime number. Its
reverse 79 isalso a prime number. Thus
97 is a twisted Prime and so, answer is 1.
Example 2:
Input: N = 43
Output: 0
Explanation: 43 is a prime number but its
reverse 34 is not a prime.So, 43 is not a
twisted prime and thus, answer is 0.
Your Task:You don't need to read input or print anything.Your task is to complete the function isTwistedPrime() which takes a number N as input parameter and returns 1 if it is a twisted prime number.Otherwise, it returns 0.
Expected Time Complexity:(O(sqrt(max(N,RevN))), here RevN is the reverse of N.
Expected Space Complexity:O(1)
Constraints:
1<=N<=109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes