@xueguang Nah, then they (more precisely, their
next) would all just be O(N) time. But solution 1 could easily be made O(1) time again by using a deque instead of a list.
No, seriously, my name really is Stefan. Not Stephan, Stephen, Steven or even Stefen.
Posts made by StefanPochmann
RE: 2 lines Python, 2 ways
@harshaneel Minimizing the total/average distance is just a prominent property of a median. For multi-dimensional cases you can even see it as the definition: https://en.wikipedia.org/wiki/Median#Spatial_median
RE: The point of " 0 <= x,y < 2 to the power of 31"
@nathan Python's and Ruby's integers can be larger. Also, it's letting people know that they must actually expect the full range up to 231.
RE: Java solution with memory efficient "limited" frequency map approach.
if a string contains a character more than Integer.MAX_VALUE times
As far as I've seen, that's impossible.
Also, if it were possible, then its own length() method would be wrong, as it returns an
RE: Something broken with problem or site?
Me, too, also since yesterday.
RE: 7-8 lines C++ / Python / Ruby
@rawmy12 When you do
pre.next, b.next, a.next = b, a, b.next, Python first evaluates the tuple on the right side and then assigns it to the left side targets. So
b.nextwas before that line. That's not the case in your separate-lines version, because when you assign to
a.next, you already changed
b.next. It's not anymore the value it was before.
RE: This problem is not well-defined. It should state that 4-space is considered as a TAB under certain situation.
@mragank2 Nah, you people really just need to get that idea out of your head that spaces are anything special. Just treat them like any other normal character (e.g., like 'x').