Ad
  • Default User Avatar

    You could actully start the inner loop with j = 1 as you already have established that nums[i][0] is the smallest value before entering the loop.

  • Default User Avatar

    Clever solution and well optimized! I see others have arrived at this solution, but your comments stand out.

  • Default User Avatar

    Seems there is a memory allocation thing going on here.
    I'm coding in C.
    The number tests pass, the first string test pass but then:
    Test Results:
    number_tests
    should_pass (2 of 2 Assertions)
    Completed in 0.5602ms
    sample_cases
    should_pass_all_the_tests_provided
    Test Passed
    Incorrect answer for input: "The narwhal bacons at midnight."
    Actual: "3 11" fixture.c (ڔ��؊20 8 5 14 1 18 23 8 1 12 2 1 3 15 14 19 1 20 13 9 4 14 9 7 8 20"
    Expected: "20 8 5 14 1 18 23 8 1 12 2 1 3 15 14 19 1 20 13 9 4 14 9 7 8 20"

    It looks like my buffer is filled with garbage on the second run. It works on my local machine, gcc 9.3.0. on xubuntu 20.04.
    Any ideas anyone? Error in the test framework?

  • Default User Avatar

    result[size] = '\0'; is not needed as calloc nullifies the allocated memory.
    function isupper() could be used instead of string[index] >= 'A' && string[index] <= 'Z'.

    Nice solution though

  • Default User Avatar

    You should free 'temp'. Caller cannot do it-

  • Default User Avatar

    For 'marker' you could use char instead of int to save space. Also remember to free 'marker' as the caller cannot do that.

  • Default User Avatar

    Neat, but wastes memory. A 125 char array is created.

  • Default User Avatar

    Nice. Actually you could skip the last test ' if (i*i < n)'