Ad
  • Custom User Avatar

    Approved.

  • Custom User Avatar

    i usually use the php manual for the PHP katas

  • Default User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Users can modify the matrix in their solution. This could lead to wrong assertion messages => generate the assertion message before calling the user solution.

  • Custom User Avatar
    • Although it is correct that an empty product should have value 1 it is not specified in the description and thus I would omit this thest case. Otherwise I see discussions coming why this is the expected value.
    • Please use JUnit 5 and make all test methods and classes package private.
    • Reference solution needs to be private or can be calculated directly with the test case creation.
    • Please remove System.outs and give these messages in assertion messages instead.
    • Add a return 0; to initial solution template to make it compile.
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    The time complexity of the longest method is determined by the operations performed within the method. Let's analyze the operations step by step:

    1. Concatenation: The line String s = s1 + s2; performs concatenation of the two input strings s1 and s2. The time complexity of string concatenation in Java is O(n1 + n2), where n1 is the length of s1 and n2 is the length of s2.

    2. Distinct: The distinct() method is used on the IntStream created from the concatenated string s. The distinct() method creates a new stream with distinct elements, which involves iterating through the elements of the stream and keeping track of unique elements. The time complexity of the distinct() operation is O(n), where n is the number of characters in the concatenated string s.

    3. Sorting: The sorted() method is used to sort the characters in the stream in ascending order. The time complexity of the sorted() operation is O(n log n), where n is the number of characters in the concatenated string s.

    4. Collecting: The collect() method is used to collect the sorted characters back into a StringBuilder to form the resulting string. The collect() operation iterates through the elements in the stream and appends them to the StringBuilder. The time complexity of the collect() operation is O(n), where n is the number of characters in the concatenated string s.

    Overall, the dominant operation is the sorting step with a time complexity of O(n log n). Therefore, the time complexity of the longest method is O(n log n), where n is the total number of characters in the concatenated string s.

    It's important to note that the time complexity may vary depending on the length of the input strings and the specific implementation of the distinct() and sorted() operations. However, in this case, we can safely say that the time complexity is O(n log n) due to the sorting operation.

  • Default User Avatar
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Default User Avatar

    Also in a coding interview where you are applying for a specific language, knowledge of the built in functions is key to success.

  • Default User Avatar

    I really need to start using Google lol

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Loading more items...