Ad
  • Custom User Avatar

    can this code be considered as idiomatic C#?; considering todays standards.

  • Custom User Avatar

    Time complexity of integer square root is log(n).
    And then you are iterating that many times.
    So, the time complexity is θ(log(n)+n)

    Whereas using take while, the time complexity is θ(n)

  • Custom User Avatar

    What about this input string: "4.7 ohms"?

    From the description:

    For resistors less than 1000 ohms, the ohms value is just formatted as the plain number.

    The only possible variants with 4.7 then are:

    encode_resistor_colors("4.7k ohms") // yellow violet red gold = 47 * 10^2 ohms
    encode_resistor_colors("4.7M ohms") // yellow violet green gold = 47 * 10^5 ohms
    

    I hope that helped.

    Have a great evening.

  • Default User Avatar

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