How will you do it if the interviewer asked you to not use the sort function?


  • 0
    P

    Every solution here makes use of the custom sort function. Is there a solution here which doesn't use it?


  • 0

    @piy9 If you do not or can not utilise the sort then you can directly take advantage of the comparer to select. Actually selecting the most significant number is the core of hacking the problem.


  • 0
    P

    @LHearen @LHearen Sorry didn't get what you meant by take advantage of comparer.

    Do you mean to say that we could implement our own sort like quicksort - and instead of comparing two numbers, compare the two strings just like in all the custom sort operations (return s1+s2 > s2+s1)


  • 0

    @piy9 That could also do, I think, since we are just trying to find out the largest here.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.