Ad
  • Custom User Avatar

    Ok, with Java is then out of my hands: post under the Java translator comment, so that he can be notified.

    Cheers!

  • Default User Avatar

    This solution is really Java. Java streams are part of Java 8 and you can program in a functional way (albeit in an extremely verbose way) in Java 7. Java is a multi-paradigm language. Actually this solution could be better if it did away with array indexing altogether (e.g. strArr[i + j]), and use streams entirely.

    You are right that the solution is inefficient at O(n^2).

  • Custom User Avatar

    Which language? And feel free to share your code with a spoiler tag here :)

  • Custom User Avatar

    The definitions of these are:

    Best practise solutions tend to be a good balance of performance, readability and maintainability.

    Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production.

    Efficiency is valued in Codewars and this question has been asked many times as well as the topic has been debated many times (see here). Many of the coders on Codewars (like myself) have no experience coding at industrial standard or have no/little knowledge on efficient coding (such as space/time complexity). These skills are learnt at a more specialist level and therefore not everybody considers efficiency when they look at a good solution, they look at code length instead.

    However, in my opinion, efficiency is not the most important thing when it comes to coding smaller scale projects. Efficieny is a thing to look out for and try to manage. I try to structure my solutions with a "good balance of performance, readability and maintainability". I have learnt a lot during my time at Codewars and now try to keep thing compact yet efficient, but others may not have this knowledge and continue to mark these as "best practice" if the code is short. I do like one-line solutions (as long as they aren't too long) since they are snappy, to the point, simple and usually understandable.