Ad
  • Default User Avatar

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

  • Default User Avatar

    Nice! Concise and also performant on time complexity. I think it's O(n).

    • The "char.IsLetter(ch)" is O(1) because it alsmot just check character value ranges.
    • The "Distinct()" method use a hash set like approach instead of a list which avoids checking all previously added elements linearly to add a new element (character). If alphabet count is "m" it reduces the time complexity from O(n.m) to O(n) because the "set.Add(...)" method time complexity is on average the O(1) compared to search a list's element and then add which is O(m).

    Sorry for the long comment :)
    Correct me if i have said anything wrong.

  • Default User Avatar

    Great! I think it's the most performant solution in case of time complexity.
    Using the HashSet is best for checking if any element is in a collection and also remove that one at the same time, so that it won't be checked in the next loops.

  • Default User Avatar

    Clean and performant!
    Even which direction the indices go (increase or decrease) is decided smartly to have a readable code.
    I really love the little details (but really impactful) which others care.
    Nice man!

  • Default User Avatar

    I like solutions with linq, although I'm not used to them.
    Using linq is really good for tidy and fast development and useful where performance is not very critical.
    In scenarios where performance is important, I think we should avoid linq which in many cases may cause extra allocations and extra traversings through a collection. In many cases we can do it by some simple for loops.
    I found some nice articles about performance of linq statements:
    Linq Garbage Collection
    Linq Performance

  • Default User Avatar

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

  • Default User Avatar

    Nice, using hash set! Using a hash set for checking an element existence in a collection is the fastest way, but because the vowels characters are just a few, an array or list may suffices.