Ad
  • Custom User Avatar

    Not possible, because 'x' takes the first element of (sorted) queue.

    But the list 'u' is not needed : never read except his size. Maintains a counter or decreasing 'n' will be enougth

    And why in the hell a check is done on queue in loop condition, it grows constantly (2 add for 1 remove)

    Summary : "while(true){...}" + "if(n--==0) return x;" instead of "u.Add(x);"

    Except the gready pitfall, it's nice and clever

  • Custom User Avatar

    Hi,

    Too late for that, unfortunately. Closing.

  • Custom User Avatar

    Please make requests on CW github instead of this page.