Attention LeetCode -- Why are your method signatures concrete rather than abstract?

  • 0

    The method signature for word-ladder-ii is:

    public ArrayList<ArrayList<String>> findLadders(String start, String end, HashSet<String> dict)

    All LeetCode signatures involving collections are like this, in that they make use of concrete collections rather than collection interfaces.
    But if you actually find yourself at a Java tech interview, you'd want to write the method signature like this:

    public List<List<String>> findLadders(String start, String end, Set<String> dict)

    Otherwise your interviewer will think you don't understand that you reduce the usability of your methods by coding to concrete classes rather than to interfaces.

  • 0

    Thanks for your feedback and I agree with you completely. I will make your suggested change soon.

  • 0

    Now the default Java code definition uses List<T> instead of ArrayList<T>. To reload the default code definition, clear all text in the code editor, and reload the page. If the page comes up as empty, navigate away to another page and come back where you should see the default code definition being loaded.

Log in to reply

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