Want to give it a shot?? Sign up with us to make sure your upcoming interviews are the best they can be by practicing with our experienced engineers. interviewing.io/signup?.com&
Inerviewer: Choose any language you want. Me: Ok, python. Inerviewer: Ok great. Lets Go. Middle of first problem.... Interviewer: Forgot to mention, you cant use any of pythons features. Me: Can I change to C?
@@coolkatmehrfth Im pretty sure people who worked with that... pretty much had no life to begin with... you cant die when you don't even have a life in the first place :)))
This was probably my favorite interviewer from the ones I've seen. Clearly experienced, not bothering to write long problems on screen, or setting the parameters of the interview and just letting it flow, be more human. You don't need to go all Voight Kampff on someone to get a good sense of their skills.
Yeah exactly dude, it's more of a test to understand if the guy who's writing the reverse a string answer didn't just memorize the thing in X language and wrote it up and not knows what he is doing, much better to ask explanations of simple problems and why the answer you think is the right one is the right one. Good engineers are not ones that mug up but ones who actually can create shit from pre existing shit and somehow better it up !
I really dont think these types of technical challenges find good developers, I think they just find developers who either know the syntax of a language in depth or happen to have done the exact problem before. Taking the problem at 9:05 as an example, I dont know how to do this in Javascript syntax (I work in Javascript every day). However I know what I need to do, and googling it gave me a 2 line answer in less than 10 seconds. So I would have failed this test, but would have completed it in under 10 seconds in a real work environment. I dont think this makes me a bad developer. I think much better technical interviews are to present the user with an already working bit of code (or not) and get them to expand on it, or fix it, using what is already there.
Was looking for this comment. + The fact that they are talking about complexity and time but IRL it depends on how the language is interpreted by the machine. If you're not working on complex algorithms, you never do this.
Agreed. The skill that the interviewer testing here is not just dev skills, but also computer science principles, which based on which company hires you, treats as important to churning out code. For IT services based company, which are focused on realizing business use cases, time and space complexity might not matter as much as code maintainability, code refactoring etc. But it would matter for product companies like Google, Amazon, where every microsecond and byte saved makes a world of difference.
exactly. That is my exact perspective. You are just catching a developer who failed that question before, so they remember how to solve that particular problem the next time it gets asked.
@@redwoodenjoyer Biggest application is in cryptography IMO. It's very fast to compute, easy to understand, commutative and associative ! Basic example of a XOR cypher : en.wikipedia.org/wiki/XOR_cipher
blake XORs largest application is actually probably for a full-adder implemented in hardware honestly. Total # of XORs used for that purpose has to be in billions/trillions at this point
If you've ever hired a developer that didn't know how to problem solve and use very simple language constructs you know the value of these tests. Maybe they are a little academic but most times they are trying to understand your problem solving ability not your knowledge of obscure language concepts. We hired a guy that had an amazing CV that looked like he could've invented Java himself when we got him into our department he was a nightmare and had almost no concept of how to problem solve in code. It was a disaster and the company that hired him was a charity that felt too bad to fire him otherwise he would've lost his visa.
all the while he was thinking "please don't make me implement heap sort please don't make me implement heap sort." just one of those things where you know you can probably do it if you had to, but you just never want to.
I have an issue with this type of interview. High performance "reverse" algorithms are pretty much only useful for working with really massive datasets, like DNA/RNA. The real issues that businesses face have to do with solving business problems. Reversing a string is not a business problem. Anyone can look up the "current, most optimal way" to solve your sorting problem, reverse problem, etc. It takes an engineering mindset to architect a solution to a business problem, though... which is a totally different skillset and what pretty much every company actually desires (outside of research and game engine development). I have had many interviews and given many interviews where wrapping your head around a real life problem gives far more information about the ability to engineer software. "Say you have 50 requests coming in every second to your online shopping product catalog. How do you best serve that data to your customers if that data is sitting in your database?" Answer: 1. "Pull the active product data into a cache, where the data is easy to sort and categorize for the filters the customer selects. This way, the customers are searching in-memory data." 2. "Load balance customer requests over several web servers so wait times are shorter. Ensure your web servers have available resources (bandwidth, RAM, etc) and your database server(s) has a reasonable number of connections available and that each query returns the smallest dataset." 3. "Optimize filtering to reduce the product set as quickly as possible. Smaller datasets are far more performant. This might limit the number of products a customer sees at once (say, the first 20 results)." "Assume your customers have to upload numerous high quality (i.e. large) images to your site. How would you handle this?" Answer: 1. "Bandwidth will be an issue. Many areas do not have gigabit fiber. Colocation can have anywhere from 20-100 mbps on a standard connection. If you have 12 Megapixel images, each one is roughly 12 Megabytes (or more, if they have higher color bit rates). 12 MB * 8 bits/byte = 98 Mbits. So a single image can max out the available download pipeline of a small operation, if only for 1 second. In reality, customer upload speeds will vary wildly. The images will need RAID storage, for performance and safety (backup)." 2. "If cost is not too big of an issue, consider cloud storage. This will alleviate issues with load balancing, bandwidth, storage space, and image backups. It will also provide high availability and allow your business to expand to other global regions, quickly. This may take the form of a Kubernetes cluster." I don't expect a candidate to know "everything". I expect them to give it their best shot. Then I might have them draw a diagram. Or write out a SQL query. Or pseudo-code a small piece of their response. Do they focus on hardware solutions? Do they focus on database solutions? Do they focus on software solutions? Do they understand current tech trends? Are they a capable problem solver? Do they think through the solution? Do they get frustrated? Do they ask for help? Do they throw out ideas? Do they eliminate bad ideas? Do they ultimately solve the problem? Do they make excuses? Do they enjoy the process? Do they get completely stuck? Did they lie about their skillset on their resume? Would you enjoy having this person on your team? Would they bring new approaches/skills to the table? To me, memorizing algorithms just tells me that they studied like it was a college test. I have worked with DNA, so I know that performance is important, but it isn't great for a job interview question. It's also one Google search away. Looking at a real problem requires multiple approaches and an accumulation of knowledge (the thing you need humans for). I've had the pleasure of working with, and learning from, very talented people. It's difficult, in my mind, to find those people with this type of approach.
its difficult to find those people because they are leading a business. If you are capable of thinking like this you won't bother working for someone else.
@@QuiiKSyyntax I don't agree. Having business skills is completely different. Knowing when to get a lawyer involved, contract negotiations, taxes & expense management, hiring, sales, finding new clients... these are all way outside most technical people's wheelhouse. I think most technical people don't want to deal with the business, so they work with companies that allow them to do what they do best. I've met a lot of really talented developers, none of whom run a company. Are they smart enough to run a company? Probably.
Matthew those business skills won’t get you anywhere when trying to build your own business without beeing an expert at something. There are two options tho, either you make your business knowledge a business itself or you have the money to hire the people you need to do stuff you can’t. While people with problem solver attitude and beeing an expert at something can all be great business leaders, because not figuring something out is not an option.
Yeah pretty dumb stuff these interviews... always the same textbook question with no real application. These engineers are stuck is the 80s and don't want to grow out of it.
For the one-liner programmers this would be solution for the technical questions # Reverse string function def reverse_string(input_str): return "".join(str[::-1]) # Find missing element in the list def find_missing_element(list_a, list_b): return [x for x in list_a if x not in list_b] regarding to the variables names in the find_missing_element function, I think it need to be clear which one is the full list and which is the partial list. A side note, the interviewer said that he would use "str" as a variable name for the reverse function but actually I am not fan of using just "str" because it's a python built-in function and it might cause a syntax error.
@@sliderBro No new allocation, it's (O)n, because it's only using the step argument of string slicing. It's the equivalent of starting at &string + sizeof(string) and decrementing the pointer by 1 until 0 in C. Pro Tip: A strong understanding of C really helps out in python, as the types in python are usually more complex object types from C (list, dict, etc).
@@mattymattffs dude. That immediately went through my head What the hell was the point of that? And im not quite sure but appending it to the end of the list would make that O(n) so better than his concatenation
Yes, so it's basically can be done in O(n) time and O(1) space! I was also thinking about why didn't find the solution. Because when the interviewer said "only one element missing" then my first thought was missing element = sum(full)-sum(partial)
It's kind of fundamental stuff as far as programming goes. You can program without knowing this, but unless you have a basic understanding of time & space complexity, you can accidentally write code that is suuuper slow.
@@kristupasantanavicius9093 in a language like python, strings are immutable, so you create a new string through copying. Copying a string with m characters will take m operations. If you perform the copy operation in a loop, from 1 to n, you get 1 + 2 + 3 + ... + n-1 + n. You might know that this can also be expressed as n*(n+1) / 2. Expanded, this becomes n^2 / 2 + n / 2. We aren't interested in coefficients, and only the most significant term, so this all becomes O(n^2). In practice, copying a string with m characters might only take m/8 instructions (copying a word at a time, instead of a byte at a time). However, if you plug this into the above, you will still get O(n^2), because the coefficients are discarded. Note that either way, this copy operation is O(n). Time complexity is compositable; if you are combining 2 algorithms, or using an algorithm in a loop, you can use the time complexities of the individual algorithms to find the overall time complexity. Hope this all makes sense
@@mardvorak2 well, I learned the concept in my data structures and algorithms class in college. I bet you could find a free course online that covers this. Otherwise, I dunno, the internet has everything nowadays
Couldn't hear very well, but I tried following along with the results: def reverse(x): return x[-1::-1] i = reverse('Hello!') print(i) """ """ # 08:14 def findMissing(x, y): for i in x: if i not in y: return i x = [4, 12, 9, 5, 6] y = [4, 12, 9, 6] z = findMissing(x, y) print(z) """
I don't know. Never worked in a company that cares about time complexity. Unless you are doing low level, high-speed services, it really doesn't matter. What matters more is readability and maintainability.
Really? I think these interviews are exaggerated but time and space complexity knowledge was important even for me who only did internships and haven't graduated yet.
@@windskm In the general industry, it doesn't matter. Everything is based on how quickly you can get a product to market. Firms are more than happy for you to use a couple more E2 instances to handle the load and get the feature 50% faster to the users because you used a pre-defined logic. Another good example is immutable functional programming, every "map, flatmap, filter etc" will create a new collection or monad. It's wasteful cpu-timewise (and memory wise). But it's more deterministic, easier to read and faster to get to the market. Even in data science, rarely who would want you to manually rewrite neural nets from scratch if you can simply wire them with pre-written modules by Google. Now, there are exceptions (as I mentioned). The core teams. They must care about deep level dynamics. If your team develops the core frameworks that will be used by other teams, every small delay in your core will impact their end products.
@@artursvancans9702 ahhh gotcha. Yes, I think that makes senses when developers don't need to care about server bills. Still, if there's a clear O(n) solution to a problem than why do an O(n**2)? I think that's why companies who run a lot of their infrastructure (google, mcsft, facebook) want every single one of their SWE engineers to know this, even if they are front-end, back-end, dev-ops, low-level or whatever.
@@ItsMeChillTyme It always depends on the job culture. I have seen some contractors trying to keep everything as secretive as possible. Mostly happens in corporate environments. However, usually you work in a team, your features are PR'ed or worked in pairs. The convoluted code will just simply not get to the prod. Even if you work solo, in most cases your tech lead or head of tech will follow Bus Factor, that will make sure at least 2 other people can replace you at any point. TLDR - It happens. But in shitty companies.
9:20 if the arrays are numeric I would just add up the values to get the missing one by subtraction. But that is very limited. edit: Ah ok, it is mentioned at 19:30
bruh that's like 2nd grade problem. just to Return list(x for x in full_set if x not in partial_set).That would also work if there are more than 1 element missing.
Great interview, some commentators are obviously extremely infatuated with themselves and do not understand what stress is until they are at an interview themselves, but this guy did awesome. Really cool I greatly enjoyed this and shows I have some common thinking.
Technical interview: loosely translated, an hour of ignoring the fact modern languages handle these operations for us so we can make ourselves feel clever.
Interviewer: You need to implement a function to reverse a string, how would you do it? Bad answer: Explain how to write a program to reverse a string. Good answer: Use the built-in string libraries reverse function every language has. Interviewer: You need to divide numbers but your dog ate your / key, what do you do? Bad answer: Explain how to divide using bitwise operations and subtraction. Good answer: Get a new keyboard. Interviewer: They can't afford a new keyboard. Good answer: Quit and get a new job, this place is going bankrupt.
the interviewer said that he would name the string str at 26:06 but that no one would actually do that since str() is a built in function in python lol
@@justarandomcitizen210 i was wrong, it actually does compile but it's just not good practice. sometimes it works but nobody who codes in python would do that since it's a native function and this can lead to many errors/unintended consequences. this is okay in java, C, and many other languages but not python. just a nit picky detail
Samuel Moss lmao 😂 it will work with any valid 2 sets as mentioned in the interview. Runtime would be linear dependent on the size of the arrays cause we would have to iterate through them to sum up. space complexity should also be linear. And implementation would be super easy. Arithmetic operation on arrays is reliable and easy.
Can't you reverse a string in python by creating a slice that starts at the ending position and moves backwards? def reverse(x): return x[::-1] I think there is no faster way to reverse a string in python but this is still O(n) time complexity.
It was kinda hard to hear what they were saying so sorry if my question is dumb, but in 10:10, why not just do: def find_missing(full_set, partial_set): missing_items = (set(full_set) - set(partial_set)) return missing_items Why did he type all the extra stuff if you're just trying to find the missing item/items of the list? Again, this could be a dumb question. Were they just looking for different ways to get the job done?
Nobody Cares Serialisation and deserialization is essentially taking a tree data structure and removing the values in a certain order (tree shifting each time) and putting it into a new tree. The only difference compared to a linear data structure is the order of removal and order of placement instead of FIFO
@@pointinpolyhedron yes that's kind of correct it's just you have to keep track of where all the null values are and how many branches there are for each node before you insert into JSON. That's the tricky part
For the second problem: Simple swift solution which just sums up each array and returns the difference which is the missing element. O(N) time O(1) space func findMissing(_ fullArray: [Int], _ partialArray: [Int]) -> Int { let sumOfFull = fullArray.reduce(0, +) let sumOfPartial = partialArray.reduce(0, +) return sumOfFull - sumOfPartial } If there are multiple items missing.. we just make a set from the partial array and iterate through the full array and keep track of what items aren't contained in the set: O(N) Time & Space var set: Set = [] var missingNums: [Int] = [] for num in partialArray { set.insert(num) } for num in fullArray { if set.contains(num) == false { missingNums.append(num) } } return missingNums
Those are the worst interviews. I would rather want to see reverse python built-in function rather than that overly convoluted for-loop solution. A better tech interview would be them talking about higher-level and architectural problems.
You are both missing the point. He is testing his problem solving skills and his thought process, that's why on many interviews I hear "please think out loud". Whether the problem he solves is useful doesn't matter at all.
NDD He’s asking for specific computer science problems to solve. This problems have hardly any application in real life. You could be dismissing real problem solvers for folks that read a Wikipedia article before the interview.
Can somebody explain to me the time complexity of string reverse? What do they mean Big O on N? O(n)? Then the interviewee says "its another N"?? You can't have 2N, because time complexity is not measuring the time taken, but rather the time taken relative to the number of elements. Also, prepending a string like that is not O(n). Inserting to the front of a string (assuming the string is contiguous in memory) is exponential curve. The code would become unusable with just a few elements because you need to allocate/move the entire array to make space for the element being inserted to the front.
Its actually a very interesting question. What is the time complexity or string reverse using string prepend? Maybe somebody could elaborate? Its definitely exponential in some form, not sure which exact one though.
By "another n" he meant that the concatenation inside of the loop makes the algorithm O(n^2). It is not exponential, but quadratic. His solution was using a list to allow for constant writing.
By the way, mind you this is just 1st round. It's not like he is going to get an offer by reversing a string. Then you have to do multiple technical rounds consisting of design and architecture related questions. Nowadays they test EVERYTHING. From developer common sense to architecture of the system. After 5-6 rounds of this you get a result which is again very low for such companies.
@@user-ob5hj5vn8c Sincere comment? I can't tell sarcasm on RUclips. What makes it great Space Complexity? I'm self teaching myself to code, but without a CS background, these topics confuse me a bit and trying to work on it
Really not hard unless you wanna be specific like setx - sety is actually O(len(setx)) avg case in Py but this guy wasnt expected to know that either. Anything that does one thing is O(1), a loop is O(n), except for loops where you can break or otherwise not process all elements those are log n. And nested loops are multiplied [2 nested for loops would be O(n.n) aka O(n²), non nested loops would be O(n+n)]. Also good to do in interview if you're confident is ask if they want to know avg or worst case
That's still O(n) since you need to run through each element once. Also, like he said, there's the risk of overflow and underflow in the sum, as the sum also scales with the input.
Why did they never actually run any of the code? Like they never called any of the functions... I didn't watch the whole thing to see if there were any clear mistakes, but they kept saying 'it works' when they really only checked if the interpreter would syntactically accept that code...
Matt Billenstein What did you think was happening everytime he said “let’s give it a quick run” followed by long silence, followed by him saying “it works”? Here’s the last one of about five or so times it happened: 23:10 He was running the code on his end, probably even copied it directly out of the interview interface and onto a separate environment just so he could see the results and say whatever he wanted to the interviewee (maybe even lie or mislead them in the results to see if they stick by and defend their code or roll over and assume it’s wrong even when it isn’t) I really do hope that most prospective technical employees know that just because you don’t see something on screen doesn’t mean that it isn’t happening on the other end. Otherwise all our future backend developers will start to leave for GUI and front end development not realizing there’s more that makes their programs work than what they actually see. 23:10
Matt Billenstein what do I think is happening? Exactly what I stated is happening, the code IS indeed being run and it confirms it on screen every time it runs on the timestamp of “extenuated at”. Look at the time value changing above the part that says “Mammoth Avenger ran 29 lines of Python.” And notice how every time he runs it the time stamp changes it to confirm he ran it again at the most recent time? So “what do I think happened”? I think Mammoth Avenger’s code was RUN several times by him and/or the interviewer, because it literally says it was and even confirms it every time above “ran code” changes (and I recall it changing at least five times)
For most jobs worth wanting, more important than big O is *being cool*. Being friendly, easy to chat with, and interested in the person you’re talking to.
Python scripters are very poor. The rates are extremely low. Due to low learning curve and low intelligence required to learn it. But this guy still don’t know basic stuff.
@@gilfhunter42069 hehe yes. actually, data scientists use py -- high mathematics and stats or genetics - very high skillset, very high pay. but that is probably 5% of all the jobs. the rest is like every other language - an average (of programmers) person can do it. So especially for this vid, my statement is most likely right on the money.
@@johnmadsen37 Well, I don't know. As long as you need a degree for the job, the pay of a python software engineer (which is usually connected to machine learning, data science or simillar fields, because why else would you want to use python in enterprise situations) is high
To all the people who are commenting that these are real world problems or they wont be used in development, i am sorry to inform you that this interview isn't intended to check your programming skill to glue API or other stuff. The main aim of these type of interviews is to check the approach a person uses to get to the solution, if he/she gets stuck at some point, then what is their attitude towards that difficulty. Real world problems dont get solved during the one hour or half hour interview. They require people who built solutions to a problem, there is nothing special about people who glue API together. API is based on work did by engineers who are capable to solve such problems.
I had one of these "blackboard" interviews with Indeed. Honestly, it did not prove that I was a good Python developer or not. I was more nervous than anything while doing it.
Solution at 11:29 is logically incorrect if we have duplicates in first array and that duplicate is missing from second array and since he set() those array, the output would be empty set
1. return x[::-1] 2. Just do binary xor for all numbers in both arrays, the result will be equal to the missing number. O(n) time, O(1) space. Like: return functools.reduce(itertools.chain(arr1, arr2), operator.xor)
The questions are really simple: #Question 1 def reverse(s): return s[::-1] s = "abc" print(reverse(s)) #"cba" #Question 2 def findLast(l1,l2): for i in l1: if i not in l2: return i
So interesting that people often assume atting charscto a string is O(1) operation. This must have been his thought Wenn claiming it is linear in time. I really loved the xor approach (:
I never used xor on integers and find it quite interesting. Is it correct to assume that this only works if there is only 1 missing element in the second set? While playing around a bit I realized that when 2 numbers are missing in the second set the 'xor_sum' will sometimes be the sum of the missing values and sometimes the difference between the missing values. So if the question was to find the sum of the missing integers in the second set there would be no reliable way to do it using xor, correct? Edit: Also I don't get what is the drawback of just adding up all integers in the first list and then subtracting all integers in the second list, wouldn't that be the same thing? And then it would even work to get the sum in case multiple values are missing. There would also be no extra space required for that approach. The more I think about it the more I get confused about it so would be great if somebody could clarify
@@Kriishna47 Does that really make a difference for python? There is no maximum integer value in python and it's simply limited by the available memory. edit: I would guess the advantage of using xor would then still be that the sum is not getting that huge and we don't use that much memory, so in some cases it can probably make a difference
You're right about xoring with multiple missing values won't give you the correct value, but it kind of makes sense. You only have 1 integer as an output, and you're trying to find 2 values, so your output is going to be garbage in some way. Why does xoring work in the first place? Because of the following properties: n ^ n = 0 0 ^ m = m And xoring is fully commutative, so: a ^ b ^ c ^ x ^ b ^ c ^ a = x Because of these properties, you can do a lot of cool tricks with it. For example, if you have numbers a, b, c, you can make a parity value: p = a ^ b ^ c. Then, let's say you lose the value of b, but you still have a, c, and p. You can find b by: b = a ^ c ^ p. Note that a ^ b ^ c ^ p = 0 . This is a basic data redundancy algorithm (e.g. raid 5 uses this)
If you wanted to really piss him off during the string reverse, you could have just used a RTL character and said it's O(1). :^) u"\u202E" You're welcome.
@@Gbyrd99 Basically that string becomes a character, and the character tells the text render to do what it does normally in reverse. So basically you can type backwards. I'm not sure if RUclips sanitizes unicode, but if it does you'll see this backwards: This is a test. Thsi text should be backwards.
I think convert list to set in the find_missing problem is not a good choice since if the missing one is just one of the duplicate pairs, and you just drop it away
Neither of you were right about which sorting algorithm Python uses. It's not a modified quicksort, but a modified mergesort that uses insertion sort once the sublists get small enough for improved cache behavior called "Timsort" en.wikipedia.org/wiki/Timsort
Isn't the find_missing O(n logn)? When you subtract the sets it has to compare every element of set A with up to every element of set B. Then it subtracts the element from set B if it finds it. Worst case scenario, O(n logn).
def StringReverse(astring): astring = str(astring) reversed_string = astring[::-1] return reversed_string This is a much easier way of writing a function which reverses strings
Easy questions but I’d probably fail because of my lack of understanding big O. As in I couldn’t tell if linear or anything. Any recommendation of great video on big o?
Not sure about videos but Cracking The Coding Interview has a chapter on big O and would probably be an interesting and relevant read if you're interested in stuff like this.
I think he's doing a good job, but in these types of interviews, you need to kind of show a little stress and perhaps a show of speed, while also being personable. It's kind of like... uhm... uh... ect. You don't want to sound arrogant or cocky, but you do want to sound sure.
I don't know if I would agree. Not being sure and admitting to it, but showing your thought process and how you come up with a solution to something you haven't done before shows how you would deal with new challenges as well. And that could also be a good thing. Wouldn't it?
lol this is so funny. um hmmmm ummmmm hmmmm so this goes like this, now we increment i,hmmmm ummm, there we go, the optimal solution for dijkstra's algorithm.(thinking in mind: god damn it, that was so hard, it was hard because I had to fake that I never saw this problem before, but I remember it word to word, variable to variable **cough**cough) and then that person ended up getting $400k offer from Google.
I'm at 3:46. I'm guessing it isn't Big O(n) because every time he loops he has to rebuild all of those chars over again because the string is a brand new object every time. My guess is Big O(N^2) as he currently has it.
1st: def rev(x): return x[::-1] print(rev("Apple") 2: def find_missing(arr1, arr2): result =0 for i in arr1+arr2: result ^= i return result print (find_missing([4,2,5,5,6],[2,6,5,4]))
The functions are very easy but then the interviewer throws in questions like what are the time and space complexities of sorting algorithms. That's going to catch anyone off-guard, especially junior developers.
Idk if the interviewer was aware that his constructive criticism on naming was a mute point in python. Str is a reserved word. I would just comment what the variable is above the function or in a docstring like you would in any production code.
TheRealFarm *moot(not being demeaning, just thought it’d be nice to know) Regarding the interview - he might’ve advised it so that the interviewee can utilise what the interviewer said for other languages should they get the job
While I agree that calling a variable str is a horrible idea, it's perfectly valid. str is *not* a reserved word. It's a function just like all others and can be overwritten if you wanted to do so. There are a handful of keywords in python that are reserved (like del, assert, return, yield, print (in py2)) but everything that is a function can be overwritten.
They probably are talking about space complexity, which it is. You could have sounded more humble. It makes me feel stupid when I sound uppity and later realize that I was the one who was actually wrong.
@@kieranhorganmallow Can you show me any link or documentation that says it is quicksort not mergesort? Any article could be wrong so lets go straight to the source. github.com/python/cpython/blob/master/Objects/listobject.c#L1881 This is the code that performs the merge operation on a list sort. github.com/python/cpython/blob/master/Objects/listsort.txt You can also take a look at this link which describes and compares the performance of the sort
@@kieranhorganmallow Also, I just noticed you said quicksort is faster on average than merge sort, quicksort has the same speed as mergesort both on average and in the best case. The advantage of QS over MS is that QS uses O(log(n)) space complexity where MS needs O(n)
Want to give it a shot?? Sign up with us to make sure your upcoming interviews are the best they can be by practicing with our experienced engineers. interviewing.io/signup?.com&
"Go ahead an pick whatever language you like to work in"
"Ok i pick English, this should be easy"
You mean SQL.
i laughed way to hard for this
Uh he means Python...
you made my day
Oh lol i like this
Got the awkward goodbyes down perfectly!
lol
Interviewer: Do you have any questions, I'll be happy to answer
Me: Wtf is your x problem?
Lmaoooo. My ribs
Inerviewer: Choose any language you want.
Me: Ok, python.
Inerviewer: Ok great. Lets Go.
Middle of first problem....
Interviewer: Forgot to mention, you cant use any of pythons features.
Me: Can I change to C?
:D
Do u mean built in function ?
😂😂😂
Protip: if you know you're not going to get the job, just say I love you before you guys hang up.
yeah, i dare you
Yeah way to get yourself blacklisted from other acquaintances of that guy in other companies.
What if it was between different gender lol
It was a mock interview btw
@@tommyphilip2000 Only a butt hurt moron would blacklist you. Anyone else would just shrug it off.
he should've chosen 6502 assembly as his programming language of choice.
spearPYN learning 8051 assembly rn, wanna die
@@coolkatmehrfth Im pretty sure people who worked with that... pretty much had no life to begin with... you cant die when you don't even have a life in the first place :)))
Or brainf*ck
just hearing this intro gave me anxiety
glad he got accepted on the job
I mean reversing a string isn't difficult at all
@@chappie3642 sounds like youve never had a technical interview
Chappie yeah
I dont want to learn to code anymore
This was probably my favorite interviewer from the ones I've seen. Clearly experienced, not bothering to write long problems on screen, or setting the parameters of the interview and just letting it flow, be more human. You don't need to go all Voight Kampff on someone to get a good sense of their skills.
Point well made
Yeah exactly dude, it's more of a test to understand if the guy who's writing the reverse a string answer didn't just memorize the thing in X language and wrote it up and not knows what he is doing, much better to ask explanations of simple problems and why the answer you think is the right one is the right one. Good engineers are not ones that mug up but ones who actually can create shit from pre existing shit and somehow better it up !
Santiago Méndez do you code iOS apps?
Lucifer Morningstar do you code iOS apps?
Oh yea?!? Then how are you supposed to know if they are a Replicant?! Due diligence dude. Due diligence.
I really dont think these types of technical challenges find good developers, I think they just find developers who either know the syntax of a language in depth or happen to have done the exact problem before.
Taking the problem at 9:05 as an example, I dont know how to do this in Javascript syntax (I work in Javascript every day). However I know what I need to do, and googling it gave me a 2 line answer in less than 10 seconds.
So I would have failed this test, but would have completed it in under 10 seconds in a real work environment. I dont think this makes me a bad developer.
I think much better technical interviews are to present the user with an already working bit of code (or not) and get them to expand on it, or fix it, using what is already there.
Yep, there is no need to reinvent the wheel. It's inefficient and a waste of time.
Practical tests, doing what the job requires on a daily basis, are the only reasonable way to test candidates. I agree completely.
Was looking for this comment.
+ The fact that they are talking about complexity and time but IRL it depends on how the language is interpreted by the machine. If you're not working on complex algorithms, you never do this.
Agreed. The skill that the interviewer testing here is not just dev skills, but also computer science principles, which based on which company hires you, treats as important to churning out code. For IT services based company, which are focused on realizing business use cases, time and space complexity might not matter as much as code maintainability, code refactoring etc. But it would matter for product companies like Google, Amazon, where every microsecond and byte saved makes a world of difference.
exactly. That is my exact perspective. You are just catching a developer who failed that question before, so they remember how to solve that particular problem the next time it gets asked.
My favorite about the entire interview is the fact that the interviewer is called “The Legendary Artichoke.”
dude just casually pulling out the xor. didn't know it could be used like that, pretty neat
ageofwar2000 negative indexing is bad form
Yea I put that in my notes now!
Question: first time i've seen xor here other than in minecraft gates from 5 years ago. Is this the biggest application? Finding the missing number?
@@redwoodenjoyer Biggest application is in cryptography IMO. It's very fast to compute, easy to understand, commutative and associative !
Basic example of a XOR cypher : en.wikipedia.org/wiki/XOR_cipher
blake XORs largest application is actually probably for a full-adder implemented in hardware honestly. Total # of XORs used for that purpose has to be in billions/trillions at this point
This guy clearly has more of an object oriented background. Interviewer was a data systems guy
literally 27 min of my deepest anxiety
If you've ever hired a developer that didn't know how to problem solve and use very simple language constructs you know the value of these tests. Maybe they are a little academic but most times they are trying to understand your problem solving ability not your knowledge of obscure language concepts.
We hired a guy that had an amazing CV that looked like he could've invented Java himself when we got him into our department he was a nightmare and had almost no concept of how to problem solve in code. It was a disaster and the company that hired him was a charity that felt too bad to fire him otherwise he would've lost his visa.
This is the Legendary Artichoke interviewing Mammoth Avenger, live on CTV news, back to you kelly !
"Such as heap sort which you may vaguely remember?" *long pause* "yep." as he exhales xD
all the while he was thinking "please don't make me implement heap sort please don't make me implement heap sort." just one of those things where you know you can probably do it if you had to, but you just never want to.
When in doubt, always use a HashMap or Set (or a Dictionary to my C# people)
This dude has some talent! He works through the problem with the interviewer and tells him what's going on in his head. I bet this dude got hired.
I'm wondering if he got a call back. Young kids are so so cute when they're nervous. I'd feel bad if he didn't get it.
Probably not since it's a mock interview
I have an issue with this type of interview. High performance "reverse" algorithms are pretty much only useful for working with really massive datasets, like DNA/RNA. The real issues that businesses face have to do with solving business problems. Reversing a string is not a business problem. Anyone can look up the "current, most optimal way" to solve your sorting problem, reverse problem, etc. It takes an engineering mindset to architect a solution to a business problem, though... which is a totally different skillset and what pretty much every company actually desires (outside of research and game engine development). I have had many interviews and given many interviews where wrapping your head around a real life problem gives far more information about the ability to engineer software.
"Say you have 50 requests coming in every second to your online shopping product catalog. How do you best serve that data to your customers if that data is sitting in your database?"
Answer:
1. "Pull the active product data into a cache, where the data is easy to sort and categorize for the filters the customer selects. This way, the customers are searching in-memory data."
2. "Load balance customer requests over several web servers so wait times are shorter. Ensure your web servers have available resources (bandwidth, RAM, etc) and your database server(s) has a reasonable number of connections available and that each query returns the smallest dataset."
3. "Optimize filtering to reduce the product set as quickly as possible. Smaller datasets are far more performant. This might limit the number of products a customer sees at once (say, the first 20 results)."
"Assume your customers have to upload numerous high quality (i.e. large) images to your site. How would you handle this?"
Answer:
1. "Bandwidth will be an issue. Many areas do not have gigabit fiber. Colocation can have anywhere from 20-100 mbps on a standard connection. If you have 12 Megapixel images, each one is roughly 12 Megabytes (or more, if they have higher color bit rates). 12 MB * 8 bits/byte = 98 Mbits. So a single image can max out the available download pipeline of a small operation, if only for 1 second. In reality, customer upload speeds will vary wildly. The images will need RAID storage, for performance and safety (backup)."
2. "If cost is not too big of an issue, consider cloud storage. This will alleviate issues with load balancing, bandwidth, storage space, and image backups. It will also provide high availability and allow your business to expand to other global regions, quickly. This may take the form of a Kubernetes cluster."
I don't expect a candidate to know "everything". I expect them to give it their best shot. Then I might have them draw a diagram. Or write out a SQL query. Or pseudo-code a small piece of their response.
Do they focus on hardware solutions? Do they focus on database solutions? Do they focus on software solutions? Do they understand current tech trends?
Are they a capable problem solver? Do they think through the solution? Do they get frustrated? Do they ask for help? Do they throw out ideas? Do they eliminate bad ideas? Do they ultimately solve the problem? Do they make excuses? Do they enjoy the process? Do they get completely stuck? Did they lie about their skillset on their resume? Would you enjoy having this person on your team? Would they bring new approaches/skills to the table?
To me, memorizing algorithms just tells me that they studied like it was a college test. I have worked with DNA, so I know that performance is important, but it isn't great for a job interview question. It's also one Google search away. Looking at a real problem requires multiple approaches and an accumulation of knowledge (the thing you need humans for). I've had the pleasure of working with, and learning from, very talented people. It's difficult, in my mind, to find those people with this type of approach.
Finally someone said it
its difficult to find those people because they are leading a business. If you are capable of thinking like this you won't bother working for someone else.
@@QuiiKSyyntax I don't agree. Having business skills is completely different. Knowing when to get a lawyer involved, contract negotiations, taxes & expense management, hiring, sales, finding new clients... these are all way outside most technical people's wheelhouse. I think most technical people don't want to deal with the business, so they work with companies that allow them to do what they do best. I've met a lot of really talented developers, none of whom run a company. Are they smart enough to run a company? Probably.
Matthew those business skills won’t get you anywhere when trying to build your own business without beeing an expert at something. There are two options tho, either you make your business knowledge a business itself or you have the money to hire the people you need to do stuff you can’t. While people with problem solver attitude and beeing an expert at something can all be great business leaders, because not figuring something out is not an option.
Matthew hey Matt do you code iOS app?
This is the only negative to development jobs. The ones that require this sort of pressured interview.
James Liscombe are this kind of coding interviews common?
Eduardo Fernández Díaz yes
@@eduardofernandezdiaz5264 This is like the only way you're interviewed.
I have one coming up soon 😢
Breathe the pressure, come play my game I’ll test ya.
the math knowledge for this is sure gonna come in handy when he starts working in a few weeks gluing apis and learning the aws sdk 🤔😆😆😆
@@BootlegKoolaid no
haha isn't that the sad truth
Yeah pretty dumb stuff these interviews... always the same textbook question with no real application. These engineers are stuck is the 80s and don't want to grow out of it.
@Winston Mcgee There is no math in gluing API's either... That is his point.
lmfao!!!
For the one-liner programmers this would be solution for the technical questions
# Reverse string function
def reverse_string(input_str):
return "".join(str[::-1])
# Find missing element in the list
def find_missing_element(list_a, list_b):
return [x for x in list_a if x not in list_b]
regarding to the variables names in the find_missing_element function, I think it need to be clear which one is the full list and which is the partial list.
A side note, the interviewer said that he would use "str" as a variable name for the reverse function but actually I am not fan of using just "str" because it's a python built-in function and it might cause a syntax error.
Please continue doing this.... So helpful 👍
This guy solving the first problem.
Interviewer: "Stop it. It's dead already!"
Why not [::-1] for reverse?
Can you explain the space and time complexity of the internal Python implementation of that syntax?
@@sliderBro No new allocation, it's (O)n, because it's only using the step argument of string slicing. It's the equivalent of starting at &string + sizeof(string) and decrementing the pointer by 1 until 0 in C. Pro Tip: A strong understanding of C really helps out in python, as the types in python are usually more complex object types from C (list, dict, etc).
Hell, dude could've just "for i in range(len(string), -1 -1)" and it would've been better.
@@mattymattffs dude. That immediately went through my head
What the hell was the point of that?
And im not quite sure but appending it to the end of the list would make that O(n) so better than his concatenation
raskec1 exactly
I can't believe it take almost the entire interview to come across an alternate algorithm of sum(full) - sum(partial) = missing element
Yes, so it's basically can be done in O(n) time and O(1) space! I was also thinking about why didn't find the solution. Because when the interviewer said "only one element missing" then my first thought was missing element = sum(full)-sum(partial)
I've been programming for 5 years and knew the answer instantly, but not with the XOR... Wtf. My whole life is a lie.
Interviewer: "Such as heap sort, which you may vaguely remember"
Interviewee: "......yep"
when everyone is saying these questions are easy but you don't know whats going on...
It's kind of fundamental stuff as far as programming goes. You can program without knowing this, but unless you have a basic understanding of time & space complexity, you can accidentally write code that is suuuper slow.
@@joshodom9046 I'm confused about time complexity. What is the time complexity of string reverse using prepend approach? I'm thinking its N log2 N
@@kristupasantanavicius9093 in a language like python, strings are immutable, so you create a new string through copying. Copying a string with m characters will take m operations. If you perform the copy operation in a loop, from 1 to n, you get 1 + 2 + 3 + ... + n-1 + n. You might know that this can also be expressed as n*(n+1) / 2. Expanded, this becomes n^2 / 2 + n / 2. We aren't interested in coefficients, and only the most significant term, so this all becomes O(n^2).
In practice, copying a string with m characters might only take m/8 instructions (copying a word at a time, instead of a byte at a time). However, if you plug this into the above, you will still get O(n^2), because the coefficients are discarded. Note that either way, this copy operation is O(n).
Time complexity is compositable; if you are combining 2 algorithms, or using an algorithm in a loop, you can use the time complexities of the individual algorithms to find the overall time complexity.
Hope this all makes sense
@@joshodom9046 Nope, it does not... Where can self taught programmer learn such a things.
@@mardvorak2 well, I learned the concept in my data structures and algorithms class in college. I bet you could find a free course online that covers this. Otherwise, I dunno, the internet has everything nowadays
Couldn't hear very well, but I tried following along with the results:
def reverse(x):
return x[-1::-1]
i = reverse('Hello!')
print(i)
"""
"""
# 08:14
def findMissing(x, y):
for i in x:
if i not in y:
return i
x = [4, 12, 9, 5, 6]
y = [4, 12, 9, 6]
z = findMissing(x, y)
print(z)
"""
I don't know. Never worked in a company that cares about time complexity. Unless you are doing low level, high-speed services, it really doesn't matter. What matters more is readability and maintainability.
Really? I think these interviews are exaggerated but time and space complexity knowledge was important even for me who only did internships and haven't graduated yet.
@@windskm In the general industry, it doesn't matter. Everything is based on how quickly you can get a product to market. Firms are more than happy for you to use a couple more E2 instances to handle the load and get the feature 50% faster to the users because you used a pre-defined logic.
Another good example is immutable functional programming, every "map, flatmap, filter etc" will create a new collection or monad. It's wasteful cpu-timewise (and memory wise). But it's more deterministic, easier to read and faster to get to the market.
Even in data science, rarely who would want you to manually rewrite neural nets from scratch if you can simply wire them with pre-written modules by Google.
Now, there are exceptions (as I mentioned). The core teams. They must care about deep level dynamics. If your team develops the core frameworks that will be used by other teams, every small delay in your core will impact their end products.
@@artursvancans9702 ahhh gotcha. Yes, I think that makes senses when developers don't need to care about server bills. Still, if there's a clear O(n) solution to a problem than why do an O(n**2)? I think that's why companies who run a lot of their infrastructure (google, mcsft, facebook) want every single one of their SWE engineers to know this, even if they are front-end, back-end, dev-ops, low-level or whatever.
@@artursvancans9702 I agree about "memory wise". Cpu-timewise - it depends what your map/filter/grep is doing.
@@ItsMeChillTyme It always depends on the job culture. I have seen some contractors trying to keep everything as secretive as possible. Mostly happens in corporate environments. However, usually you work in a team, your features are PR'ed or worked in pairs. The convoluted code will just simply not get to the prod. Even if you work solo, in most cases your tech lead or head of tech will follow Bus Factor, that will make sure at least 2 other people can replace you at any point.
TLDR - It happens. But in shitty companies.
9:20 if the arrays are numeric I would just add up the values to get the missing one by subtraction.
But that is very limited.
edit: Ah ok, it is mentioned at 19:30
bruh that's like 2nd grade problem. just to Return list(x for x in full_set if x not in partial_set).That would also work if there are more than 1 element missing.
@@Sennken I always envy the US for teaching programming in 2nd grade.
Listening to this muted, sounds good
Great interview, some commentators are obviously extremely infatuated with themselves and do not understand what stress is until they are at an interview themselves, but this guy did awesome. Really cool I greatly enjoyed this and shows I have some common thinking.
It is a mock interview on the other hand.
@@VirtuelleWeltenMitKhan it is? I sounded like a real one. That guy was nervous as heck i would be too. But hope i will be more confident
@@ninjaninja9954 It is in the description of the video:
"This is a recording of a mock interview in Python by a senior Airbnb engineer"
@@VirtuelleWeltenMitKhan ic. Yeah he is just nervous in general. All these questions arejust algo stuff
For improving time complexity at 4:46 he could run x[::-1]
One cool recursive way of doing the first one that I learned is this:
def reverse(s):
# Base Case
if len(s)
I don't think the complexities are correct
Interviewer would actually use str as variable name? Yikes
str = "hello"
one = str(1)
.....
He is probably more familiar with other programming languages other than Python, although he knows the strings are immutable in Python :)
there is special place in hell for people who, in python, name their variables with a data type: int, str, dict ...
I think we can just XOR all elements in two Array. cus if A^x = B, then A^A^x = A^B, then we got the missing element is x = A^B.
Technical interview: loosely translated, an hour of ignoring the fact modern languages handle these operations for us so we can make ourselves feel clever.
Interviewer: You need to implement a function to reverse a string, how would you do it?
Bad answer: Explain how to write a program to reverse a string.
Good answer: Use the built-in string libraries reverse function every language has.
Interviewer: You need to divide numbers but your dog ate your / key, what do you do?
Bad answer: Explain how to divide using bitwise operations and subtraction.
Good answer: Get a new keyboard.
Interviewer: They can't afford a new keyboard.
Good answer: Quit and get a new job, this place is going bankrupt.
the interviewer said that he would name the string str at 26:06 but that no one would actually do that since str() is a built in function in python lol
You can name function arguments str in python without any issues, as long as you don't need to use native str() in the function
@@justarandomcitizen210 i was wrong, it actually does compile but it's just not good practice. sometimes it works but nobody who codes in python would do that since it's a native function and this can lead to many errors/unintended consequences. this is okay in java, C, and many other languages but not python. just a nit picky detail
The interviewer doesn't have to know the language, how do you expect him to know each and every language?
What he's testing is your problem solving
@@chappie3642 I mean I would except him to at least know what you should and shouldn't name stuff in Python if he's gonna suggest something like that
@@chappie3642 The correct way to solve all the questions is to go to stackexchange and copy and paste the answer because it's already there for you.
In the second question of finding the missing number, is there any reason for not using the solution as "return sum(a)-sum(b)"?
in my opinion that’s totally fine and it was the first solution I thought about.
For the particular input, it would work. but it would easily break for anything else like
set1 = [1,2]
set2 = [1,2,3,4]
this would return 7
amzshow4life that’s got 2 elements missing lol
Samuel Moss lmao 😂 it will work with any valid 2 sets as mentioned in the interview. Runtime would be linear dependent on the size of the arrays cause we would have to iterate through them to sum up. space complexity should also be linear. And implementation would be super easy. Arithmetic operation on arrays is reliable and easy.
integer type overflow, I guess
Can't you reverse a string in python by creating a slice that starts at the ending position and moves backwards?
def reverse(x):
return x[::-1]
I think there is no faster way to reverse a string in python but this is still O(n) time complexity.
Not really what the interviewer wants to see most likely
It was kinda hard to hear what they were saying so sorry if my question is dumb, but in 10:10, why not just do:
def find_missing(full_set, partial_set):
missing_items = (set(full_set) - set(partial_set))
return missing_items
Why did he type all the extra stuff if you're just trying to find the missing item/items of the list? Again, this could be a dumb question. Were they just looking for different ways to get the job done?
xor solution caught me off guard, so genius, no way I'd ever come up with something like that myself
Pretty smooth interview.
I got asked "How to serialize a tree structure" in my last interview 🤷♂️
Nobody Cares Serialisation and deserialization is essentially taking a tree data structure and removing the values in a certain order (tree shifting each time) and putting it into a new tree. The only difference compared to a linear data structure is the order of removal and order of placement instead of FIFO
@@LandCruisin well you can ask the interviewer and he/she will now be flustered to answer the question. You have essentially turned the tables lmao
I am not a CS guy. But you can serialize any sort of trees into essentially an XML or JSON like file right or am i wrong on this ?
@@pointinpolyhedron yes that's kind of correct it's just you have to keep track of where all the null values are and how many branches there are for each node before you insert into JSON. That's the tricky part
Does anyone know if he has a vid with using C++?
For the second problem: Simple swift solution which just sums up each array and returns the difference which is the missing element. O(N) time O(1) space
func findMissing(_ fullArray: [Int], _ partialArray: [Int]) -> Int {
let sumOfFull = fullArray.reduce(0, +)
let sumOfPartial = partialArray.reduce(0, +)
return sumOfFull - sumOfPartial
}
If there are multiple items missing.. we just make a set from the partial array and iterate through the full array and keep track of what items aren't contained in the set: O(N) Time & Space
var set: Set = []
var missingNums: [Int] = []
for num in partialArray {
set.insert(num)
}
for num in fullArray {
if set.contains(num) == false {
missingNums.append(num)
}
}
return missingNums
For the problem at 9:16,
couldn't you just add up all the integers in each array, do array1 - array2 and get your answer?
Yes and he says that later
@@goost0852 ah, I didn't finish the video
And yet you never use this in real working environment. (When nerds become the bosses)
Those are the worst interviews. I would rather want to see reverse python built-in function rather than that overly convoluted for-loop solution. A better tech interview would be them talking about higher-level and architectural problems.
You are both missing the point. He is testing his problem solving skills and his thought process, that's why on many interviews I hear "please think out loud". Whether the problem he solves is useful doesn't matter at all.
NDD He’s asking for specific computer science problems to solve. This problems have hardly any application in real life. You could be dismissing real problem solvers for folks that read a Wikipedia article before the interview.
Can somebody explain to me the time complexity of string reverse? What do they mean Big O on N? O(n)? Then the interviewee says "its another N"??
You can't have 2N, because time complexity is not measuring the time taken, but rather the time taken relative to the number of elements.
Also, prepending a string like that is not O(n). Inserting to the front of a string (assuming the string is contiguous in memory) is exponential curve. The code would become unusable with just a few elements because you need to allocate/move the entire array to make space for the element being inserted to the front.
Its actually a very interesting question. What is the time complexity or string reverse using string prepend? Maybe somebody could elaborate? Its definitely exponential in some form, not sure which exact one though.
By "another n" he meant that the concatenation inside of the loop makes the algorithm O(n^2). It is not exponential, but quadratic. His solution was using a list to allow for constant writing.
@@kristupasantanavicius9093 not exponential. it is quadratic / parabolic
By the way, mind you this is just 1st round. It's not like he is going to get an offer by reversing a string.
Then you have to do multiple technical rounds consisting of design and architecture related questions.
Nowadays they test EVERYTHING.
From developer common sense to architecture of the system.
After 5-6 rounds of this you get a result which is again very low for such companies.
Where the hell is the code output?
first question answer in typescript :
function reverseString(str: string) {
const splitedString = str.split(' ');
const stringLength = splitedString.length - 1;
let arr: string[ ] = [ ];
for (let index = stringLength; index >= 0; index--) {
arr.push(splitedString[index])
}
return arr.join(' ');
}
22:49
What do you guys think about getting the sum of each list and subtracting the difference? Only will work if you expect one number to be missing
Yeah, thats a smart solution, well done. Same time complexity, but excellent space complexity.
I came to the comment section to see why this was not what was done....
@@user-ob5hj5vn8c Sincere comment? I can't tell sarcasm on RUclips.
What makes it great Space Complexity?
I'm self teaching myself to code, but without a CS background, these topics confuse me a bit and trying to work on it
not your fault or anything but these interviews are so painful to watch, I hate these sorts of situations
well im gunna go brush up on time complexity
Really not hard unless you wanna be specific like setx - sety is actually O(len(setx)) avg case in Py but this guy wasnt expected to know that either. Anything that does one thing is O(1), a loop is O(n), except for loops where you can break or otherwise not process all elements those are log n. And nested loops are multiplied [2 nested for loops would be O(n.n) aka O(n²), non nested loops would be O(n+n)]. Also good to do in interview if you're confident is ask if they want to know avg or worst case
Ah rite, well luckily I don't have an interview for a long time so I'll hopefully be ready by then hehe
0x1 thx man that didn’t sound quite right
Not as painful as reading through job postings.
why cant I just sum first and second and subtract them if they are unique numeric ids?
Exactly what i did. Wouldn't work if multiple items are missing though
That's still O(n) since you need to run through each element once. Also, like he said, there's the risk of overflow and underflow in the sum, as the sum also scales with the input.
int missing_item(vector v1 , vector v2){
int sum1 = 0;
int sum2 = 0 ;
for(auto x :v1)sum1+=x;
for(auto x : v2)sum2+=x;
return max(sum1,sum2) - min(sum1,sum2);
}
Why did they never actually run any of the code? Like they never called any of the functions... I didn't watch the whole thing to see if there were any clear mistakes, but they kept saying 'it works' when they really only checked if the interpreter would syntactically accept that code...
They're checking for process, logic and problem-solving, not linting for small errors in the code... would be my guess anyways
Matt Billenstein What did you think was happening everytime he said “let’s give it a quick run” followed by long silence, followed by him saying “it works”? Here’s the last one of about five or so times it happened: 23:10
He was running the code on his end, probably even copied it directly out of the interview interface and onto a separate environment just so he could see the results and say whatever he wanted to the interviewee (maybe even lie or mislead them in the results to see if they stick by and defend their code or roll over and assume it’s wrong even when it isn’t)
I really do hope that most prospective technical employees know that just because you don’t see something on screen doesn’t mean that it isn’t happening on the other end. Otherwise all our future backend developers will start to leave for GUI and front end development not realizing there’s more that makes their programs work than what they actually see. 23:10
Dave Hyler just checking syntax - what do you think is happening?
@@HylerMusic I've done a bunch of these - never seen someone run it off-screen when you can just run it in the tool there.
Matt Billenstein what do I think is happening? Exactly what I stated is happening, the code IS indeed being run and it confirms it on screen every time it runs on the timestamp of “extenuated at”. Look at the time value changing above the part that says “Mammoth Avenger ran 29 lines of Python.” And notice how every time he runs it the time stamp changes it to confirm he ran it again at the most recent time?
So “what do I think happened”? I think Mammoth Avenger’s code was RUN several times by him and/or the interviewer, because it literally says it was and even confirms it every time above “ran code” changes (and I recall it changing at least five times)
Interviewer: Pick whatever language you want.
Interviewee: Ok then I pick *assembler*
😱😂
Hahah. Imagine picking something really esoteric looking, like J or something
PowerPC machine code written raw in a hex editor ;)
For most jobs worth wanting, more important than big O is *being cool*. Being friendly, easy to chat with, and interested in the person you’re talking to.
This comment deserves a higher rating
Do Airbnb engineers use 5$ walmart microphones? Goodness the first impressions...
Python scripters are very poor. The rates are extremely low. Due to low learning curve and low intelligence required to learn it. But this guy still don’t know basic stuff.
@@johnmadsen37 My brain hurts reading this.
@@johnmadsen37 nice troll
@@gilfhunter42069 hehe yes. actually, data scientists use py -- high mathematics and stats or genetics - very high skillset, very high pay. but that is probably 5% of all the jobs. the rest is like every other language - an average (of programmers) person can do it. So especially for this vid, my statement is most likely right on the money.
@@johnmadsen37 Well, I don't know. As long as you need a degree for the job, the pay of a python software engineer (which is usually connected to machine learning, data science or simillar fields, because why else would you want to use python in enterprise situations) is high
To all the people who are commenting that these are real world problems or they wont be used in development, i am sorry to inform you that this interview isn't intended to check your programming skill to glue API or other stuff. The main aim of these type of interviews is to check the approach a person uses to get to the solution, if he/she gets stuck at some point, then what is their attitude towards that difficulty. Real world problems dont get solved during the one hour or half hour interview. They require people who built solutions to a problem, there is nothing special about people who glue API together. API is based on work did by engineers who are capable to solve such problems.
I had one of these "blackboard" interviews with Indeed. Honestly, it did not prove that I was a good Python developer or not. I was more nervous than anything while doing it.
Isn't Heap sort O(N) space?
Solution at 11:29 is logically incorrect if we have duplicates in first array and that duplicate is missing from second array and since he set() those array, the output would be empty set
lol when you ask the interviewer if you can google the answer xD
For the second, what if i sum up all the number and then minus the other's sum
Better yet, to avoid potential overflows (if not Python), XOR all the numbers and you get the missing one.
If only one number is missing then I like:
def find_missing(x, y):
return sum(x) - sum(y)
1. return x[::-1]
2. Just do binary xor for all numbers in both arrays, the result will be equal to the missing number. O(n) time, O(1) space. Like:
return functools.reduce(itertools.chain(arr1, arr2), operator.xor)
no built ins
Is there a reason we can't see the output when he runs it? Was this a "passing grade" interview, meaning did he make it and could it have been better?
Very cool. I definitely did not think of xor solution.
Probably best to remember space and time complexity and in=place algorithms.
16:50 fun fact, python uses an insane mostly-in-place merge/insertion sort hybrid as its sorting algorithm -- timsort! en.wikipedia.org/wiki/Timsort
The questions are really simple:
#Question 1
def reverse(s):
return s[::-1]
s = "abc"
print(reverse(s))
#"cba"
#Question 2
def findLast(l1,l2):
for i in l1:
if i not in l2:
return i
l1 = [4,12,9,5,6]
l2 = [4,9,12,6]
print(findLast(l1,l2)) #5
Why isn’t your second answer’s logic more popular?
find missing function can use bit-wise NAND to arrive at O(1) solution. both interviewer and interviewee are mistaken
So interesting that people often assume atting charscto a string is O(1) operation. This must have been his thought Wenn claiming it is linear in time. I really loved the xor approach (:
Damn dude I see you everywhere (Bitcoin twitter)
As far as I remember Joel Spolsky even has an article about people not knowing how basics work
What other professions require you to take a practical exam to get a job?
I never used xor on integers and find it quite interesting. Is it correct to assume that this only works if there is only 1 missing element in the second set? While playing around a bit I realized that when 2 numbers are missing in the second set the 'xor_sum' will sometimes be the sum of the missing values and sometimes the difference between the missing values. So if the question was to find the sum of the missing integers in the second set there would be no reliable way to do it using xor, correct?
Edit: Also I don't get what is the drawback of just adding up all integers in the first list and then subtracting all integers in the second list, wouldn't that be the same thing? And then it would even work to get the sum in case multiple values are missing. There would also be no extra space required for that approach. The more I think about it the more I get confused about it so would be great if somebody could clarify
Benjamin The problem with sum is overflow.
@@Kriishna47 Does that really make a difference for python? There is no maximum integer value in python and it's simply limited by the available memory.
edit: I would guess the advantage of using xor would then still be that the sum is not getting that huge and we don't use that much memory, so in some cases it can probably make a difference
You're right about xoring with multiple missing values won't give you the correct value, but it kind of makes sense. You only have 1 integer as an output, and you're trying to find 2 values, so your output is going to be garbage in some way.
Why does xoring work in the first place? Because of the following properties:
n ^ n = 0
0 ^ m = m
And xoring is fully commutative, so:
a ^ b ^ c ^ x ^ b ^ c ^ a = x
Because of these properties, you can do a lot of cool tricks with it. For example, if you have numbers a, b, c, you can make a parity value: p = a ^ b ^ c. Then, let's say you lose the value of b, but you still have a, c, and p. You can find b by: b = a ^ c ^ p. Note that a ^ b ^ c ^ p = 0 . This is a basic data redundancy algorithm (e.g. raid 5 uses this)
@@joshodom9046 Thanks for that awesome explanation.
def find_missing(lst1, lst2):
for x in lst2:
if x in lst1:
lst1.remove(x)
return(lst1[0])
This is the simplest solution without sets
If you wanted to really piss him off during the string reverse, you could have just used a RTL character and said it's O(1). :^)
u"\u202E"
You're welcome.
No you're just deferring the operation to some OS specific stuff which you probs dono the time complexity of
@@doldol1 The time complexity is O(1), tard boy.
It's just RTL instead of the default LTR. The text renderer works the same way.
What you mean. This sounds intriguing
@@Gbyrd99 Basically that string becomes a character, and the character tells the text render to do what it does normally in reverse. So basically you can type backwards. I'm not sure if RUclips sanitizes unicode, but if it does you'll see this backwards:
This is a test. Thsi text should be backwards.
I think convert list to set in the find_missing problem is not a good choice since if the missing one is just one of the duplicate pairs, and you just drop it away
so what is the time complexity of the first solution ? O(N^2) ?
Neither of you were right about which sorting algorithm Python uses. It's not a modified quicksort, but a modified mergesort that uses insertion sort once the sublists get small enough for improved cache behavior called "Timsort"
en.wikipedia.org/wiki/Timsort
Isn't the find_missing O(n logn)? When you subtract the sets it has to compare every element of set A with up to every element of set B. Then it subtracts the element from set B if it finds it. Worst case scenario, O(n logn).
def StringReverse(astring):
astring = str(astring)
reversed_string = astring[::-1]
return reversed_string
This is a much easier way of writing a function which reverses strings
I feel this would be better for the 2nd question no?
def find_missing(x, y):
missing = None
for n in x:
if n not in y:
missing = n
return missing
Rhys doing “if n not in y” is O(N), so overall it would be O(N^2).
In java StringBuilder can be used to have o(n) complexity
second question :
let tab = [4, 12, 9, 5, 6]
let tab2 = [4, 9, 12, 6]
let res = []
tab.forEach(val =>!tab2.includes(val) && res.push(val))
console.log(res);
Easy questions but I’d probably fail because of my lack of understanding big O. As in I couldn’t tell if linear or anything. Any recommendation of great video on big o?
Not sure about videos but Cracking The Coding Interview has a chapter on big O and would probably be an interesting and relevant read if you're interested in stuff like this.
I think he's doing a good job, but in these types of interviews, you need to kind of show a little stress and perhaps a show of speed, while also being personable. It's kind of like... uhm... uh... ect. You don't want to sound arrogant or cocky, but you do want to sound sure.
Stephan Salas do you code iOS apps?
I don't know if I would agree. Not being sure and admitting to it, but showing your thought process and how you come up with a solution to something you haven't done before shows how you would deal with new challenges as well. And that could also be a good thing. Wouldn't it?
lol this is so funny. um hmmmm ummmmm hmmmm so this goes like this, now we increment i,hmmmm ummm, there we go, the optimal solution for dijkstra's algorithm.(thinking in mind: god damn it, that was so hard, it was hard because I had to fake that I never saw this problem before, but I remember it word to word, variable to variable **cough**cough)
and then that person ended up getting $400k offer from Google.
Could you pick Haskell as the language for this?
the interviewer sounds like DJ Vlad
I'm at 3:46. I'm guessing it isn't Big O(n) because every time he loops he has to rebuild all of those chars over again because the string is a brand new object every time. My guess is Big O(N^2) as he currently has it.
yep! if he had just ran the for loop backwards and added to the output that it would have been O(n)
I need to learn more from this man.
4:31 when you start blaming the language lmao
10:47 interviewer did that too lmfao
1st:
def rev(x):
return x[::-1]
print(rev("Apple")
2:
def find_missing(arr1, arr2):
result =0
for i in arr1+arr2:
result ^= i
return result
print (find_missing([4,2,5,5,6],[2,6,5,4]))
x[::-1] is python syntax sugar and is equivalent to reverse(x). The interviewer explicitly asked for own implementation.
@@artursvancans9702 oh okay
8:16 "Ok that looks good" NO IT DOESNT
yeah it could be done in one line
def reverse(str):
return str[::-1]
No idea about the space time continuum mumbo-jumbo, though. =/
The functions are very easy but then the interviewer throws in questions like what are the time and space complexities of sorting algorithms. That's going to catch anyone off-guard, especially junior developers.
Idk if the interviewer was aware that his constructive criticism on naming was a mute point in python. Str is a reserved word. I would just comment what the variable is above the function or in a docstring like you would in any production code.
TheRealFarm *moot(not being demeaning, just thought it’d be nice to know)
Regarding the interview - he might’ve advised it so that the interviewee can utilise what the interviewer said for other languages should they get the job
While I agree that calling a variable str is a horrible idea, it's perfectly valid. str is *not* a reserved word. It's a function just like all others and can be overwritten if you wanted to do so. There are a handful of keywords in python that are reserved (like del, assert, return, yield, print (in py2)) but everything that is a function can be overwritten.
18:24 quick sort would be log(n)? emmm sry ? isn't it nLog(n)?
They probably are talking about space complexity, which it is. You could have sounded more humble. It makes me feel stupid when I sound uppity and later realize that I was the one who was actually wrong.
Python does not use Quicksort lol. It uses Timsort which is a hybrid sort using both merge sort and insertion sort
@@kieranhorganmallow Can you show me any link or documentation that says it is quicksort not mergesort?
Any article could be wrong so lets go straight to the source.
github.com/python/cpython/blob/master/Objects/listobject.c#L1881
This is the code that performs the merge operation on a list sort.
github.com/python/cpython/blob/master/Objects/listsort.txt
You can also take a look at this link which describes and compares the performance of the sort
@@kieranhorganmallow Also, I just noticed you said quicksort is faster on average than merge sort, quicksort has the same speed as mergesort both on average and in the best case. The advantage of QS over MS is that QS uses O(log(n)) space complexity where MS needs O(n)