Sort 13 Discussions, By:
Please Login in order to post a comment
for test case 1 , use unsigned long long int instead of long long int to store the number in base k...because 10^6 in binary will have around 20 digits and long long int causes overflow.
whats the problem with test case no 1.. i m not able to pass it.. what should i do.??
Converting the number to base k takes probably too much time... Try to convert it only if it is necessary
Recursion greatly helps to find the base. And also does not take much time. The last case came in 2 secs, in python 3.
Hope it Helps!Simple JAVA Solution passes all test cases!!!
public class Solution
public static void main(String args)
Scanner s=new Scanner(System.in);
if(new StringBuilder(i+"").reverse().toString().equals(i+"") && Integer.toString(i,k).equals(new StringBuilder(Integer.toString(i,k)).reverse().toString()))
all test cases passed in less than 0.03 s in python 3
How can i saw the input of the other test cases ? is it possible ?
I am getting runtime error in testcase 14 and all the remaining got passed could any one tell me what could be the error .My code is in Python3
For those who are curious, my solution takes the following points into account:
That way I could pass any test case up to N=10^10.
Test Case 5 in C++ is takin 0.12s . In python it is taking 0.02s.
Python here. Got 0.01s for #5. The only test cases where it took 0.02s are #1 and #13.
All test cases passed but I am getting 1.54s time taken on 5th testcase, which is highest amongs all testcases. Can i consider my algorithm efficient or do I need to optimize it further ??
0.25s for 5th testcase here...
All test cases pass under 0.05s in Python
Test case 5 - 0.02s
You can view the code here.
You can also make suggestions or help make improvement in the existing code.
0.2s in python 3 here lol
brute forced it too