Hi,
From Biggest Number problem is not getting submitted but the same solution has been accepted in LeetCode.
Can anyone help on the same?
Thanks
Hi,
From Biggest Number problem is not getting submitted but the same solution has been accepted in LeetCode.
Can anyone help on the same?
Thanks
Hi, what do you mean by not getting submitted?
I saw your recent submission.
I am not experienced with Java but probably you should consider using something else than string.compareTo()
.
It should return something similar to str1 < str2
string.compareTo()
. In java this will do the lexicographical comparison. Hope this will help you.
Let me know in case need more info from my side. Thanks
in advance.
Here not submitted means all the test cases are being failed. But the same code has been submitted in leetcode.
Hi, I looked up compareTo() and it returns an integer value, therefore accordingly you should use something like str2.compareTo(str1) > 0
.
CompareTo itself return 1 if str2 is greater then str1 else -1. And it will return 0 in case both are equal.
As you suggested if i write the code like str2.compareTo(str1) > 0
. then it will give true or false or boolean type which is not the return type of compare function. Hence it will not work.
Overall this sorting function is working fine I have cross check this. I am sure this is not causing any issue.
Ohh basically, the comparator in C++ needs to return boolean. I will look up a bit about the comparator in Java and reach back.
You forgot the newline after each testcase
Yes It got submitted Thanks a lot
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.