There’s also an O(1) space optimization (which I believe is explained in Cracking the Coding Interview). That optimization can then be generalized to finding up to k elements that appear at least n/k times in O(n) time and O(k) space.
Glad to see Code Wars still doing well. I used to work with this guy, who’s one of the founders: jhoffner | Codewars
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
You could always work through fixing your game to get more comfortable with async stuff. That poor one node instance you’re working to death will thank you. 
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
We may all be out of jobs soon. Could have done promiseArray = urls.map() though.
But in all seriousness. This thing could be a pretty powerful tool to get started on stuff like this where you remember how to do it… but promises are weird and how did that work again?
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
I swear to god i’m seeing versions of this same problem everywhere. query some api that returns paginated results and we’re gonna put some annoying rate limit on it and see what you do.
This is a take home assignment for a job interview?
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
FFS - hire me for a couple weeks and I’ll build this thing for you, then you can decide if you want to keep me on.
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
Are you using Mobx and Sass? I’ve never used Mobx so that would slow me down. CSS would slow me down but presumably that’s a requirement for this job. Are you using something off the shelf like react table for pagination and search?
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
I’m still my high school self - my boss boss wanted me to prepare a presentation to solve some problem we’re facing with ssl certs, i’ve been in bed with fever for 3 days and finally got up to do it (it’s in 3 hours) and buried in my drive i found a full blown presentation i’d made on this exact topic 2 years ago.
jackpot, reminds me of when i used to recycle old A+ papers in english class.
I have a Python question. I want to take a list and replace elements with an empty string if the element repeats the previous element. For example, I want to turn
['a', 'b', 'b', 'b', 'c', 'c']
into
['a', 'b', '', '', 'c', '']
One way to do this is
new = old[:1]
for i, o in enumerate(old[1:]):
new.append(o if o != old[i] else '')
This seems a little kludgy, but I can’t think of a more elegant solution. Any ideas?
maybe this is why im failing interviews - my instinct is to just do this
cpy = input_list[::]
for i in range(len(input_list)):
if i > 0 and input_list[i-1] == input_list[i]:
cpy[i] = ‘’
seems way more readable to me than any syntactic sugar crap
no way its time complexity is worse than O(N)
if you wanted to do it in place for fanciness points im sure you could but it’d read a bit uglier
For Python 3.10+:
new = old[:1]
new.extend(e2 if e1 != e2 else "" for e1, e2 in itertools.pairwise(old))
I don’t see any reason that’s actually better than your approach though. Just a chance to impress itertools nerds.
can anyone explain something that’s been bugging me for a long time now?
“please enter the last 4 digits of your ssn followed by the pound sign” on automated robo assist stuff. ok - the # is presumably acting as a delimiter for the software to understand my input is over. why can’t it just stop accepting input and realize i’m done after 4 digits have been entered, since that’s all it expects and all that will be valid?
The moderators of this message board, otatop, L.Washington, WichitaDM, Yuv, JonnyA, RiskyFlush, and SvenO, are cowards who let abusers dox and harrass other long time posters.
