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 former i.e. write functions/loops that are mixed with setTimeout to not fire all at once/fire next one on resolve etc I couldn’t quite remember how to set that up, wonderful. Oh well there’s always drinking heavily at 4pm instead.
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. 
“When I download my table into csv, all of my colors dissappear”
“yes you can’t download colors they’re in the html”
“Well I need to make a feature request”

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?
Use the Star Wars API to get a list of all the planets in the Star Wars Universe. Note, the api is paginated, so you will need to pull multiple times to get all the planets.
Display all of those planets in a list on the front page of your app. You may choose to show all the planets, or paginate them for the UX experience.
Add a text input at the top of the page that allows a user to search the full list of planets. The filtering should NOT re-call any api calls.
When a user clicks on a planet, they should navigate to a new page that shows a list of the residents of the planet fetched from the Star Wars API.
When a user clicks on one of the residents, they should navigate to another page that shows the personal details of that resident.
Include a header with breadcrumbs. Something like All Planets / Planet Name / Resident Name. Each breadcrumb section should be clickable to navigate to the appropriate page.
Include a service file that contains all the api urls and gets. Your React components should not contain any url references.
Style up the application as you like. The whole thing doesn't need to be perfectly polished, but we do want to see that you can implement a UI design. Even though we aren't giving you a design to implement. 😆😆 Our advice would be to give the app a decent layout that makes sense and then pick one piece of UI and give it some love ❤. This could be the planet list items, the search input, or the individual residents.
Bonus Points
Every company does things a little differently. The closer you get to our stack the better we'll be able to assess how you work with it. So, extra credit if you use any of the following:
Mobx and Mobx State Tree for state management.
Sass for styling.
React Router for routing.
Optimizing
various features are as fast as possible.
Re-use of components
Worse or better than being stared at while trying to solve LC mediums?
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?
yeah. Not hitting any rate limits at least.
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.
lol couple weeks. I’m almost done but its gonna be like 8 hours total to make it not terrible and do the “optional” parts (hint: they aren’t optional). At least its for principal. api is garbage though lol can’t infer anything. IDK whatever
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?
I’m debating whether or not to use mobx. Never have before but it can’t be much different than redux. SASS support comes with create react app. All HTML baby any dipshit can throw mui at stuff is my thinking here.
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?
Because that’s the way it is done. Starting to change, some 2fa that give you 6 characters will auto submit on the 6th character but it’s rare. Phone is terrible though since there’s no delete key on a phone.
