Ad
  • Default User Avatar

    Be aware that the stack space here can become huge for bigints. It's a better practice to use tail recursion for constant stack space.

  • Custom User Avatar

    Offtopic, but: why do you copy other users' solutions? Or is this your second account?

  • Custom User Avatar

    really 🤣🤣🤣

  • Custom User Avatar
    • There is 1 word that starts with o -> {"o": ["only"]} -> 1 letter prefix, 1 word -> 1 = 1 -> OK
    • There are 2 words that start with a -> {"a": ["are","answers]} -> 1 letter prefix, 2 words -> 1 < 2 -> we will add more letters to make subdivisions
    • There is 1 word that starts with ar -> {"ar": ["are"]} -> 2 letters prefix, 1 word -> 2 > 1 -> Not OK
    • There is 1 word that starts with an -> {"an": ["answers"]} -> 2 letters prefix, 1 word -> 2 > 1 -> Not OK
    • There are 2 words that start with s -> {"s": ["some","solutions]} -> 1 letter prefix, 2 words -> 1 < 2 -> we will add more letters to make subdivisions
    • There are 2 words that start with so -> {"so": ["some","solutions]} -> 2 letter prefix, 2 words -> 2 = 2 -> OK
    • we take all the OK's in one final sorted array -> ["only", "solutions", "some"]
    • Mic drop!
  • Custom User Avatar
  • Default User Avatar

    only -> beginning = o (1 letter, 1 word) OK \\\ Why 'o'? Its only one word here wtf??

    are -> beginning = ar (2 letters, 1 word) not OK \\\ Why 'ar'? Its only one word here wtf??

    answers -> beginning = an (2 letters, 1 word) not OK \\\ Why 'an'? Its only one word here wtf??

    Whats the logic here? Why dont author explain this in the description..

  • Default User Avatar
  • Custom User Avatar

    Because of the the ascii values of 'l'(108) and 'm'(109). If you sort a list with these strings it will arrange words that start with the same characters by the next. In "solutions" and "some" - 's' and 'o' have the same value, it's the following characters that make the difference.

  • Default User Avatar

    Why the ouput ["only", "solutions", "some"] insted of ["only","some","solutions"].The test: "only some solutions are answers"

  • Custom User Avatar

    ONLY if their group size (or array length) is equal to the number of shared letters in each beginning

    • solutions, some -> beginning = so (2 letters, 2 words) OK
    • only -> beginning = o (1 letter, 1 word) OK
    • are -> beginning = ar (2 letters, 1 word) not OK
    • answers -> beginning = an (2 letters, 1 word) not OK
  • Custom User Avatar

    Why the output is
    ["only", "solutions", "some"] instead of ["solutions', "some"]
    The test:
    "only some solutions are answers"

    Descriptions says: Group them by their beginning!

  • Custom User Avatar

    Thank you for the remport, I change the ref solution (it was very slow endeed). Now it shouldn't timeout.

  • Custom User Avatar

    Python: The reference solution is really slow. If I run it against itself, I get a timeout. I don't think the ref solution should timeout.

  • Custom User Avatar

    I fixed the description. Thank you for the report

  • Custom User Avatar

    The description says to return an empty list if any cases match, I assume you meant if none of them match?

  • Loading more items...