Missing item list difference: Python interview with an Airbnb engineer

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 834

  • @interviewingio
    @interviewingio  3 ปีที่แล้ว +3

    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&

  • @researchandbuild1751
    @researchandbuild1751 4 ปีที่แล้ว +897

    "Go ahead an pick whatever language you like to work in"
    "Ok i pick English, this should be easy"

  • @SumoCumLoudly
    @SumoCumLoudly 5 ปีที่แล้ว +752

    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?

  • @jamieguthrie1760
    @jamieguthrie1760 5 ปีที่แล้ว +880

    Got the awkward goodbyes down perfectly!

    • @irvinge4641
      @irvinge4641 5 ปีที่แล้ว +11

      lol

    • @newinhuman
      @newinhuman 4 ปีที่แล้ว +10

      Interviewer: Do you have any questions, I'll be happy to answer
      Me: Wtf is your x problem?

    • @danielgitahi2847
      @danielgitahi2847 4 ปีที่แล้ว +1

      Lmaoooo. My ribs

  • @MR2SpyerJournal
    @MR2SpyerJournal 5 ปีที่แล้ว +827

    Protip: if you know you're not going to get the job, just say I love you before you guys hang up.

    • @user-kv3pt6xy9w
      @user-kv3pt6xy9w 5 ปีที่แล้ว +39

      yeah, i dare you

    • @tommyphilip2000
      @tommyphilip2000 5 ปีที่แล้ว +33

      Yeah way to get yourself blacklisted from other acquaintances of that guy in other companies.

    • @pump8686
      @pump8686 5 ปีที่แล้ว +4

      What if it was between different gender lol

    • @VirtuelleWeltenMitKhan
      @VirtuelleWeltenMitKhan 5 ปีที่แล้ว +2

      It was a mock interview btw

    • @onee
      @onee 4 ปีที่แล้ว +13

      @@tommyphilip2000 Only a butt hurt moron would blacklist you. Anyone else would just shrug it off.

  • @UncleT0ny
    @UncleT0ny 5 ปีที่แล้ว +896

    just hearing this intro gave me anxiety

    • @user-kv3pt6xy9w
      @user-kv3pt6xy9w 5 ปีที่แล้ว +7

      glad he got accepted on the job

    • @chappie3642
      @chappie3642 5 ปีที่แล้ว +9

      I mean reversing a string isn't difficult at all

    • @UncleT0ny
      @UncleT0ny 5 ปีที่แล้ว +74

      @@chappie3642 sounds like youve never had a technical interview

    • @RandomShowerThoughts
      @RandomShowerThoughts 5 ปีที่แล้ว

      Chappie yeah

    • @effmerunning
      @effmerunning 5 ปีที่แล้ว +25

      I dont want to learn to code anymore

  • @spearPYN
    @spearPYN 5 ปีที่แล้ว +563

    he should've chosen 6502 assembly as his programming language of choice.

    • @coolkatmehrfth
      @coolkatmehrfth 5 ปีที่แล้ว +14

      spearPYN learning 8051 assembly rn, wanna die

    • @Microphunktv-jb3kj
      @Microphunktv-jb3kj 4 ปีที่แล้ว +8

      @@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 :)))

    • @simadovakin739
      @simadovakin739 2 ปีที่แล้ว

      Or brainf*ck

  • @santishorts
    @santishorts 5 ปีที่แล้ว +146

    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.

    • @enijar
      @enijar 5 ปีที่แล้ว

      Point well made

    • @oneforallah
      @oneforallah 5 ปีที่แล้ว +5

      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 !

    • @BootlegKoolaid
      @BootlegKoolaid 5 ปีที่แล้ว

      Santiago Méndez do you code iOS apps?

    • @BootlegKoolaid
      @BootlegKoolaid 5 ปีที่แล้ว

      Lucifer Morningstar do you code iOS apps?

    • @parabolicpawn
      @parabolicpawn 5 ปีที่แล้ว +2

      Oh yea?!? Then how are you supposed to know if they are a Replicant?! Due diligence dude. Due diligence.

  • @CardinalHijack
    @CardinalHijack 5 ปีที่แล้ว +551

    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.

    • @Pottymouth_
      @Pottymouth_ 5 ปีที่แล้ว +66

      Yep, there is no need to reinvent the wheel. It's inefficient and a waste of time.

    • @naetuir
      @naetuir 5 ปีที่แล้ว +57

      Practical tests, doing what the job requires on a daily basis, are the only reasonable way to test candidates. I agree completely.

    • @Loserfr
      @Loserfr 5 ปีที่แล้ว +18

      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.

    • @agytjax
      @agytjax 5 ปีที่แล้ว +21

      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.

    • @KeepItFresh02
      @KeepItFresh02 5 ปีที่แล้ว +1

      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.

  • @danielmateofitness7618
    @danielmateofitness7618 5 ปีที่แล้ว +54

    This guy clearly has more of an object oriented background. Interviewer was a data systems guy

  • @happybroski2112
    @happybroski2112 4 ปีที่แล้ว +17

    My favorite about the entire interview is the fact that the interviewer is called “The Legendary Artichoke.”

  • @bikesbeersbeats
    @bikesbeersbeats 4 ปีที่แล้ว +13

    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.

  • @TurtlesWrath
    @TurtlesWrath 5 ปีที่แล้ว +66

    dude just casually pulling out the xor. didn't know it could be used like that, pretty neat

    • @mattwyd2161
      @mattwyd2161 4 ปีที่แล้ว

      ageofwar2000 negative indexing is bad form

    • @qwarlockz8017
      @qwarlockz8017 4 ปีที่แล้ว

      Yea I put that in my notes now!

    • @redwoodenjoyer
      @redwoodenjoyer 4 ปีที่แล้ว

      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?

    • @Azgal0r
      @Azgal0r 4 ปีที่แล้ว +1

      ​@@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

    • @drew1998
      @drew1998 4 ปีที่แล้ว +2

      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

  • @censoredsmile2880
    @censoredsmile2880 5 ปีที่แล้ว +109

    "Such as heap sort which you may vaguely remember?" *long pause* "yep." as he exhales xD

    • @DaggerMan11
      @DaggerMan11 4 ปีที่แล้ว +2

      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.

  • @matthew4497
    @matthew4497 5 ปีที่แล้ว +574

    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.

    • @stevenf1384
      @stevenf1384 5 ปีที่แล้ว +54

      Finally someone said it

    • @QuiiKSyyntax
      @QuiiKSyyntax 5 ปีที่แล้ว +37

      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.

    • @matthew4497
      @matthew4497 5 ปีที่แล้ว +35

      @@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.

    • @QuiiKSyyntax
      @QuiiKSyyntax 5 ปีที่แล้ว +5

      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.

    • @BootlegKoolaid
      @BootlegKoolaid 5 ปีที่แล้ว

      Matthew hey Matt do you code iOS app?

  • @nislaav6712
    @nislaav6712 4 ปีที่แล้ว +75

    literally 27 min of my deepest anxiety

  • @user-db1uj2px9l
    @user-db1uj2px9l 5 ปีที่แล้ว +676

    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 🤔😆😆😆

    • @user-db1uj2px9l
      @user-db1uj2px9l 5 ปีที่แล้ว +3

      @@BootlegKoolaid no

    • @vetiarvind
      @vetiarvind 5 ปีที่แล้ว +23

      haha isn't that the sad truth

    • @tj8870
      @tj8870 5 ปีที่แล้ว +85

      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.

    • @tj8870
      @tj8870 5 ปีที่แล้ว +134

      @Winston Mcgee There is no math in gluing API's either... That is his point.

    • @dookie0311
      @dookie0311 5 ปีที่แล้ว +2

      lmfao!!!

  • @lahire1295
    @lahire1295 5 ปีที่แล้ว +32

    This is the Legendary Artichoke interviewing Mammoth Avenger, live on CTV news, back to you kelly !

  • @HighTimesTrader
    @HighTimesTrader 4 ปีที่แล้ว +7

    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.

    • @newinhuman
      @newinhuman 4 ปีที่แล้ว +1

      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.

    • @tbababauabbd2
      @tbababauabbd2 4 ปีที่แล้ว +1

      Probably not since it's a mock interview

  • @jamesliscombe9006
    @jamesliscombe9006 5 ปีที่แล้ว +89

    This is the only negative to development jobs. The ones that require this sort of pressured interview.

    • @eduardofernandezdiaz5264
      @eduardofernandezdiaz5264 5 ปีที่แล้ว +2

      James Liscombe are this kind of coding interviews common?

    • @xavierlu7634
      @xavierlu7634 5 ปีที่แล้ว +1

      Eduardo Fernández Díaz yes

    • @FinnPayton
      @FinnPayton 5 ปีที่แล้ว +13

      @@eduardofernandezdiaz5264 This is like the only way you're interviewed.

    • @RandomShowerThoughts
      @RandomShowerThoughts 5 ปีที่แล้ว

      I have one coming up soon 😢

    • @MrAmazinG023
      @MrAmazinG023 4 ปีที่แล้ว

      Breathe the pressure, come play my game I’ll test ya.

  • @JackMarchetti29
    @JackMarchetti29 5 ปีที่แล้ว +31

    When in doubt, always use a HashMap or Set (or a Dictionary to my C# people)

  • @VFXKitchen
    @VFXKitchen 5 ปีที่แล้ว +3

    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.

  • @varunagarwal28
    @varunagarwal28 5 ปีที่แล้ว +93

    Please continue doing this.... So helpful 👍

  • @swapnilingle4435
    @swapnilingle4435 4 ปีที่แล้ว +11

    This guy solving the first problem.
    Interviewer: "Stop it. It's dead already!"

  • @artursvancans9702
    @artursvancans9702 5 ปีที่แล้ว +35

    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.

    • @windskm
      @windskm 5 ปีที่แล้ว +12

      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.

    • @artursvancans9702
      @artursvancans9702 5 ปีที่แล้ว +14

      ​@@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.

    • @windskm
      @windskm 5 ปีที่แล้ว

      @@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.

    • @salmarwow
      @salmarwow 5 ปีที่แล้ว

      @@artursvancans9702 I agree about "memory wise". Cpu-timewise - it depends what your map/filter/grep is doing.

    • @artursvancans9702
      @artursvancans9702 5 ปีที่แล้ว +1

      @@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.

  • @vrezhgulyan6834
    @vrezhgulyan6834 5 ปีที่แล้ว +4

    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

  • @Matthew-tl2ng
    @Matthew-tl2ng 5 ปีที่แล้ว +17

    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.

    • @VirtuelleWeltenMitKhan
      @VirtuelleWeltenMitKhan 5 ปีที่แล้ว

      It is a mock interview on the other hand.

    • @ninjaninja9954
      @ninjaninja9954 2 ปีที่แล้ว

      @@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

    • @VirtuelleWeltenMitKhan
      @VirtuelleWeltenMitKhan 2 ปีที่แล้ว

      @@ninjaninja9954 It is in the description of the video:
      "This is a recording of a mock interview in Python by a senior Airbnb engineer"

    • @ninjaninja9954
      @ninjaninja9954 2 ปีที่แล้ว

      @@VirtuelleWeltenMitKhan ic. Yeah he is just nervous in general. All these questions arejust algo stuff

  • @cesarjom
    @cesarjom 4 ปีที่แล้ว +7

    I can't believe it take almost the entire interview to come across an alternate algorithm of sum(full) - sum(partial) = missing element

    • @SaddamHossain-vg4qe
      @SaddamHossain-vg4qe 4 ปีที่แล้ว +1

      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)

    • @GeneralZeroOfficial
      @GeneralZeroOfficial 4 ปีที่แล้ว +2

      I've been programming for 5 years and knew the answer instantly, but not with the XOR... Wtf. My whole life is a lie.

  • @sagarmoghe
    @sagarmoghe 5 ปีที่แล้ว +1

    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.

  • @Skullarious
    @Skullarious 4 ปีที่แล้ว +18

    Interviewer: "Such as heap sort, which you may vaguely remember"
    Interviewee: "......yep"

  • @luishernandez1001
    @luishernandez1001 5 ปีที่แล้ว +249

    when everyone is saying these questions are easy but you don't know whats going on...

    • @joshodom9046
      @joshodom9046 5 ปีที่แล้ว +48

      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
      @kristupasantanavicius9093 5 ปีที่แล้ว +1

      @@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

    • @joshodom9046
      @joshodom9046 5 ปีที่แล้ว +26

      @@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
      @mardvorak2 5 ปีที่แล้ว +1

      @@joshodom9046 Nope, it does not... Where can self taught programmer learn such a things.

    • @joshodom9046
      @joshodom9046 5 ปีที่แล้ว +4

      @@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

  • @devtanna77
    @devtanna77 5 ปีที่แล้ว +11

    Pretty smooth interview.
    I got asked "How to serialize a tree structure" in my last interview 🤷‍♂️

    • @BL0WUPFISH
      @BL0WUPFISH 5 ปีที่แล้ว

      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

    • @blasttrash
      @blasttrash 5 ปีที่แล้ว +1

      @@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

    • @pointinpolyhedron
      @pointinpolyhedron 5 ปีที่แล้ว

      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 ?

    • @devtanna77
      @devtanna77 5 ปีที่แล้ว

      @@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

  • @Nickdude6
    @Nickdude6 5 ปีที่แล้ว +30

    Listening to this muted, sounds good

  • @Wypipo
    @Wypipo 5 ปีที่แล้ว +4

    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.

    • @sends2aaron
      @sends2aaron 5 ปีที่แล้ว +1

      This comment deserves a higher rating

  • @skatefevur27
    @skatefevur27 5 ปีที่แล้ว +1

    One cool recursive way of doing the first one that I learned is this:
    def reverse(s):
    # Base Case
    if len(s)

    • @mgtowindia9549
      @mgtowindia9549 4 ปีที่แล้ว +1

      I don't think the complexities are correct

  • @Iammrunkown
    @Iammrunkown 3 ปีที่แล้ว +1

    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(' ');
    }

  • @doldol1
    @doldol1 5 ปีที่แล้ว +66

    Interviewer would actually use str as variable name? Yikes
    str = "hello"
    one = str(1)
    .....

    • @inancarin
      @inancarin 5 ปีที่แล้ว +15

      He is probably more familiar with other programming languages other than Python, although he knows the strings are immutable in Python :)

    • @tomciklukas
      @tomciklukas 4 ปีที่แล้ว +4

      there is special place in hell for people who, in python, name their variables with a data type: int, str, dict ...

  • @chromaetheral
    @chromaetheral 3 ปีที่แล้ว +1

    xor solution caught me off guard, so genius, no way I'd ever come up with something like that myself

  • @seanathin-c7n
    @seanathin-c7n 5 ปีที่แล้ว +5

    Idk how effective these tests are. I mean yes, it is good to know the syntax of a certain language as in-depth as you can. And you should be able to think about a problem given to you and think of multiple ways to get to the solution.
    But then again, going to stack overflow can get you your solution in a matter of seconds. What matters most on the job is your resourcefulness and persistence.
    You can't really determine that about a person just from one interview.

  • @lukkash
    @lukkash 4 ปีที่แล้ว +11

    Interviewer: Pick whatever language you want.
    Interviewee: Ok then I pick *assembler*
    😱😂

    • @user-ob5hj5vn8c
      @user-ob5hj5vn8c 4 ปีที่แล้ว

      Hahah. Imagine picking something really esoteric looking, like J or something

    • @travbrack
      @travbrack 4 ปีที่แล้ว

      PowerPC machine code written raw in a hex editor ;)

  • @ArtyomPalvelev
    @ArtyomPalvelev 4 ปีที่แล้ว +3

    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)

  • @jordanweir7187
    @jordanweir7187 5 ปีที่แล้ว +56

    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

    • @doldol1
      @doldol1 5 ปีที่แล้ว +8

      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

    • @jordanweir7187
      @jordanweir7187 5 ปีที่แล้ว

      Ah rite, well luckily I don't have an interview for a long time so I'll hopefully be ready by then hehe

    • @torinfaes6278
      @torinfaes6278 5 ปีที่แล้ว

      0x1 thx man that didn’t sound quite right

    • @crankyinmv
      @crankyinmv 5 ปีที่แล้ว

      Not as painful as reading through job postings.

  • @audigex
    @audigex 5 ปีที่แล้ว +50

    Technical interview: loosely translated, an hour of ignoring the fact modern languages handle these operations for us so we can make ourselves feel clever.

    • @yaosio
      @yaosio 5 ปีที่แล้ว +37

      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.

  • @mohamedelkaramany9863
    @mohamedelkaramany9863 4 ปีที่แล้ว

    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);
    }

  • @JDRudie
    @JDRudie 5 ปีที่แล้ว +12

    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
      @justarandomcitizen210 5 ปีที่แล้ว +2

      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

    • @JDRudie
      @JDRudie 5 ปีที่แล้ว

      @@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

    • @chappie3642
      @chappie3642 5 ปีที่แล้ว

      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

    • @JDRudie
      @JDRudie 5 ปีที่แล้ว +1

      @@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

    • @yaosio
      @yaosio 5 ปีที่แล้ว

      @@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.

  • @carlosalba9690
    @carlosalba9690 4 ปีที่แล้ว +4

    For improving time complexity at 4:46 he could run x[::-1]

  • @VirtuelleWeltenMitKhan
    @VirtuelleWeltenMitKhan 5 ปีที่แล้ว +7

    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

    • @Sennken
      @Sennken 5 ปีที่แล้ว

      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.

    • @VirtuelleWeltenMitKhan
      @VirtuelleWeltenMitKhan 2 ปีที่แล้ว +1

      @@Sennken I always envy the US for teaching programming in 2nd grade.

  • @mgtowindia9549
    @mgtowindia9549 4 ปีที่แล้ว +2

    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.

  • @RenePickhardt
    @RenePickhardt 5 ปีที่แล้ว +10

    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 (:

    • @youngKOkid1
      @youngKOkid1 5 ปีที่แล้ว

      Damn dude I see you everywhere (Bitcoin twitter)

    • @GrimSkin
      @GrimSkin 5 ปีที่แล้ว

      As far as I remember Joel Spolsky even has an article about people not knowing how basics work

  • @JSmih7
    @JSmih7 3 ปีที่แล้ว +3

    If only one number is missing then I like:
    def find_missing(x, y):
    return sum(x) - sum(y)

  • @WhiteSharkconcac
    @WhiteSharkconcac 4 ปีที่แล้ว +1

    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

    • @andresherrera458
      @andresherrera458 2 ปีที่แล้ว

      Why isn’t your second answer’s logic more popular?

  • @konnen4518
    @konnen4518 5 ปีที่แล้ว +3

    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

  • @__-to3hq
    @__-to3hq 5 ปีที่แล้ว +20

    lol when you ask the interviewer if you can google the answer xD

  • @Flintshadowrider
    @Flintshadowrider 5 ปีที่แล้ว +116

    Do Airbnb engineers use 5$ walmart microphones? Goodness the first impressions...

    • @johnmadsen37
      @johnmadsen37 5 ปีที่แล้ว +18

      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.

    • @dondev8005
      @dondev8005 5 ปีที่แล้ว +55

      ​@@johnmadsen37 My brain hurts reading this.

    • @gilfhunter42069
      @gilfhunter42069 5 ปีที่แล้ว +16

      @@johnmadsen37 nice troll

    • @johnmadsen37
      @johnmadsen37 5 ปีที่แล้ว +2

      @@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.

    • @gilfhunter42069
      @gilfhunter42069 5 ปีที่แล้ว

      @@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

  • @alexreinking
    @alexreinking 5 ปีที่แล้ว +1

    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

  • @txwylde
    @txwylde 4 ปีที่แล้ว +1

    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.

  • @jamesbondisamonkey
    @jamesbondisamonkey 3 ปีที่แล้ว +1

    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

  • @omrajyaguru289
    @omrajyaguru289 4 ปีที่แล้ว +5

    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.

    • @skilltestingman
      @skilltestingman 3 ปีที่แล้ว +1

      Not really what the interviewer wants to see most likely

  • @pedramkhoshnevis
    @pedramkhoshnevis 5 ปีที่แล้ว +56

    And yet you never use this in real working environment. (When nerds become the bosses)

    • @artursvancans9702
      @artursvancans9702 5 ปีที่แล้ว +12

      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.

    • @TheGargalon
      @TheGargalon 4 ปีที่แล้ว +4

      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.

    • @MartinMochetti
      @MartinMochetti 4 ปีที่แล้ว +6

      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.

  • @kenbarlow9023
    @kenbarlow9023 5 ปีที่แล้ว +3

    These are really awesome, please keep making them! :)

  • @billtsao6769
    @billtsao6769 5 ปีที่แล้ว +1

    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.

  • @n_fan329
    @n_fan329 4 ปีที่แล้ว

    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);

  • @swallowedinthesea11
    @swallowedinthesea11 4 ปีที่แล้ว

    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)
    """

  • @Suhaschintala
    @Suhaschintala 5 ปีที่แล้ว +3

    find missing function can use bit-wise NAND to arrive at O(1) solution. both interviewer and interviewee are mistaken

  • @user-dz6il2bx5p70
    @user-dz6il2bx5p70 4 ปีที่แล้ว +20

    4:31 when you start blaming the language lmao

    • @namansoood
      @namansoood 4 ปีที่แล้ว +1

      10:47 interviewer did that too lmfao

  • @benjaminterzic1260
    @benjaminterzic1260 5 ปีที่แล้ว

    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?

  • @raskec1
    @raskec1 5 ปีที่แล้ว +249

    Why not [::-1] for reverse?

    • @sliderBro
      @sliderBro 5 ปีที่แล้ว +118

      Can you explain the space and time complexity of the internal Python implementation of that syntax?

    • @linus7529
      @linus7529 5 ปีที่แล้ว +72

      @@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
      @mattymattffs 5 ปีที่แล้ว +21

      Hell, dude could've just "for i in range(len(string), -1 -1)" and it would've been better.

    • @youngcitybandit
      @youngcitybandit 5 ปีที่แล้ว +7

      @@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

    • @rashaadratliff-brown2734
      @rashaadratliff-brown2734 5 ปีที่แล้ว +1

      raskec1 exactly

  • @agytjax
    @agytjax 5 ปีที่แล้ว +2

    The solution for the second problem can be obtained better than O(N) : Difference between sum(original set) - sum(input set). This would work as the interviewer made it clear only one element would be missing (regardless of if elements were positive/negative integers)

    • @Timur21
      @Timur21 5 ปีที่แล้ว +3

      sum(original_set) - sum(input_set) is still O(N) (plus he actually talked about this exact solution in the interview)

  • @JesseLH88
    @JesseLH88 4 ปีที่แล้ว +1

    Very cool. I definitely did not think of xor solution.
    Probably best to remember space and time complexity and in=place algorithms.

  • @stevecarino246
    @stevecarino246 5 ปีที่แล้ว +16

    8:16 "Ok that looks good" NO IT DOESNT

    • @vazhaabdu4529
      @vazhaabdu4529 4 ปีที่แล้ว

      yeah it could be done in one line

  • @mattbillenstein
    @mattbillenstein 5 ปีที่แล้ว +9

    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...

    • @pearcake
      @pearcake 5 ปีที่แล้ว +6

      They're checking for process, logic and problem-solving, not linting for small errors in the code... would be my guess anyways

    • @HylerMusic
      @HylerMusic 5 ปีที่แล้ว +7

      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

    • @mattbillenstein
      @mattbillenstein 5 ปีที่แล้ว

      Dave Hyler just checking syntax - what do you think is happening?

    • @mattbillenstein
      @mattbillenstein 5 ปีที่แล้ว +3

      @@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.

    • @HylerMusic
      @HylerMusic 5 ปีที่แล้ว

      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)

  • @mattf.2142
    @mattf.2142 5 ปีที่แล้ว +3

    This has got to be the easiest interview ever. Here I am learning about increasing the runtime of recursive algorithms with memoization. I assumed these interviews were meant to break your will to live; this just increased my confidence tenfold.

    • @huey1153
      @huey1153 5 ปีที่แล้ว

      Jan Hoekstra it’s not, and a lot of jobs have training anyways

  • @landonpowell6296
    @landonpowell6296 5 ปีที่แล้ว +16

    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.

    • @doldol1
      @doldol1 5 ปีที่แล้ว

      No you're just deferring the operation to some OS specific stuff which you probs dono the time complexity of

    • @landonpowell6296
      @landonpowell6296 5 ปีที่แล้ว +5

      ​@@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.

    • @Gbyrd99
      @Gbyrd99 5 ปีที่แล้ว

      What you mean. This sounds intriguing

    • @landonpowell6296
      @landonpowell6296 5 ปีที่แล้ว +10

      @@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 TH-cam sanitizes unicode, but if it does you'll see this backwards:
      ‮This is a test. Thsi text should be backwards.

  • @sablesoul
    @sablesoul 4 ปีที่แล้ว +1

    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.

  • @JulianColeman03
    @JulianColeman03 5 ปีที่แล้ว +13

    I need to learn more from this man.

  • @stephansalas1464
    @stephansalas1464 5 ปีที่แล้ว +18

    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.

    • @BootlegKoolaid
      @BootlegKoolaid 5 ปีที่แล้ว

      Stephan Salas do you code iOS apps?

    • @dalulu418
      @dalulu418 5 ปีที่แล้ว +3

      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?

    • @blasttrash
      @blasttrash 5 ปีที่แล้ว +1

      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.

  • @jackriver1999
    @jackriver1999 5 ปีที่แล้ว +38

    the interviewer sounds like DJ Vlad

  • @tahseenrahman2922
    @tahseenrahman2922 4 ปีที่แล้ว +7

    In the second question of finding the missing number, is there any reason for not using the solution as "return sum(a)-sum(b)"?

    • @cloud5887
      @cloud5887 4 ปีที่แล้ว +2

      in my opinion that’s totally fine and it was the first solution I thought about.

    • @realamztvs
      @realamztvs 4 ปีที่แล้ว

      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

    • @samuelmoss2480
      @samuelmoss2480 4 ปีที่แล้ว +3

      amzshow4life that’s got 2 elements missing lol

    • @cloud5887
      @cloud5887 4 ปีที่แล้ว

      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.

    • @bringoff
      @bringoff 4 ปีที่แล้ว

      integer type overflow, I guess

  • @thekillervulture
    @thekillervulture 5 ปีที่แล้ว

    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]))

    • @artursvancans9702
      @artursvancans9702 5 ปีที่แล้ว +1

      x[::-1] is python syntax sugar and is equivalent to reverse(x). The interviewer explicitly asked for own implementation.

    • @thekillervulture
      @thekillervulture 5 ปีที่แล้ว

      @@artursvancans9702 oh okay

  • @FrankRaofighton
    @FrankRaofighton 5 ปีที่แล้ว +1

    Three solutions in 10 minutes for find_missing
    #use set Time O(n), Space O(n)
    def find_missing1(arr1, arr2):
    sa = set(arr2)
    for a in arr1:
    if a not in sa:
    return a
    return None
    print(find_missing1([1,2,3,4,5],[5,4,3,1]))
    #use math sum, Time O(n), Space O(1)
    def find_missing2(arr1, arr2):
    return sum(arr1) - sum(arr2)
    print(find_missing2([1,2,3,4,5],[5,4,3,1]))
    #use bit operation, Time O(n), Space O(1)
    def find_missing3(arr1, arr2):
    ans = 0
    for a in arr1:
    ans ^= a
    for a in arr2:
    ans ^= a
    return ans
    print(find_missing3([1,2,3,4,5],[5,4,3,1]))

  • @kristupasantanavicius9093
    @kristupasantanavicius9093 5 ปีที่แล้ว +4

    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.

    • @kristupasantanavicius9093
      @kristupasantanavicius9093 5 ปีที่แล้ว

      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.

    • @kraemer-raimund
      @kraemer-raimund 5 ปีที่แล้ว +2

      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.

    • @gomorycut2000
      @gomorycut2000 4 ปีที่แล้ว

      @@kristupasantanavicius9093 not exponential. it is quadratic / parabolic

  • @kelvinroy-omoni9921
    @kelvinroy-omoni9921 4 ปีที่แล้ว

    for the problem where we find the missing item in an array, here's the logic i could come up with using javascript. i loop through the second array (using a typical for loop of course), so i check if an item from the second array is present in the first array. If it is, i'll delete it from the first array. I repeat this process until only the missing items are left in the first array. Then i just return it is as "THE MISSING ITEMS!!!".

  • @hectormoreno-bravo8399
    @hectormoreno-bravo8399 5 ปีที่แล้ว +6

    I wish they would've asked me this on my interviews.
    def missing(a, b):
    if len(a) > len(b):
    return sum(a) - sum(b)
    elif len(a) == len(b):
    print(“there is nothing missing”)
    else:
    return sum(b) - sum(a)

    • @orshy1
      @orshy1 5 ปีที่แล้ว

      They did discuss that approach

    • @micaevski
      @micaevski 5 ปีที่แล้ว

      your answer does not account for integer overflow.

    • @bramvandyck1273
      @bramvandyck1273 5 ปีที่แล้ว +2

      def missing(a,b):
      return abs(sum(a)-sum(b))

  • @thadude3
    @thadude3 5 ปีที่แล้ว +2

    I hate these types of interviews. This is why I will never leave my current job.

  • @jayanths1221
    @jayanths1221 5 ปีที่แล้ว +2

    I've always wondered, are you allowed to chose JavaScript as your language of choice for these kind of interviews or does it need to be a programming language?

    • @sb_dunk
      @sb_dunk 5 ปีที่แล้ว

      No idea whether you can pick it, but JavaScript is definitely a programming language.

    • @garrycotton7094
      @garrycotton7094 5 ปีที่แล้ว

      These days especially, JavaScript is a programming language. Yes, it's interpreted, but it's used in so many frameworks outside of just web now that it definitely qualifies.

    • @jayanths1221
      @jayanths1221 5 ปีที่แล้ว

      @@garrycotton7094 By programming language, I mean languages like Java, Python, C++ etc

    • @garrycotton7094
      @garrycotton7094 5 ปีที่แล้ว +1

      @@jayanths1221 No, I understand, you're talking about compiled languages. I'm just saying that these days, JavaScript's interpreted nature really isn't a problem and generally only snobs will turn their nose up at it for that reason.

    • @sb_dunk
      @sb_dunk 5 ปีที่แล้ว

      @@garrycotton7094 There's also nothing to stop JavaScript from being compiled either, right?
      I work with a few guys that turn their noses up at it, I think largely due to it not being strongly typed and its association with web development.

  • @Zuberaa
    @Zuberaa 5 ปีที่แล้ว +3

    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
      @Kriishna47 5 ปีที่แล้ว +1

      Benjamin The problem with sum is overflow.

    • @Zuberaa
      @Zuberaa 5 ปีที่แล้ว +1

      @@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

    • @joshodom9046
      @joshodom9046 5 ปีที่แล้ว +4

      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)

    • @Sciexful
      @Sciexful 5 ปีที่แล้ว +1

      @@joshodom9046 Thanks for that awesome explanation.

  • @kevnation5556
    @kevnation5556 5 ปีที่แล้ว +11

    def reverse(x):
    if x=='':
    return ''
    else:
    return x[-1]+reverse(x[:-1])

    • @msquarme
      @msquarme 5 ปีที่แล้ว +10

      def reverse(x):
      return x[::-1]

    • @Naton
      @Naton 5 ปีที่แล้ว

      what magic is this....it's Beautiful!!!

    • @alcesmir
      @alcesmir 5 ปีที่แล้ว

      Have fun throwing exceptions when I throw strings larger than ~1000 at you.

    • @alcesmir
      @alcesmir 5 ปีที่แล้ว +6

      @xOr Python's default recursion limit is 1000.

  • @RujulSolanki
    @RujulSolanki 3 ปีที่แล้ว

    Just xor the two arrays, result is the missing item. A^A=0 and A^0=A

  • @Venipa
    @Venipa 4 ปีที่แล้ว +3

    i call my variables whatever i want :(
    x is superior than any other variable name !

  • @karljay7473
    @karljay7473 4 ปีที่แล้ว +1

    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?

  • @Lambdaphile
    @Lambdaphile 2 ปีที่แล้ว

    Kinda tired right now, but I think he could find the missing item in just O(n) with something like this:
    function findMissing(fullArray, partialArray) {
    let index = 0, fullArraySum = 0, partialArraySum = 0;
    // Using while instead of for because we don't want to do an extra iteration
    // for finding the fullArray length.
    while (fullArray[index] !== undefined) {
    fullArraySum += fullArray[index];
    partialArraySum += partialArray[index] ?? 0;
    index++;
    }
    return fullArraySum - partialArraySum;
    }
    findMissing([4, 12, 9, 5, 6], [4, 9, 12, 6]);
    // 5

  • @hektikethnik
    @hektikethnik 4 ปีที่แล้ว +2

    Python does not use Quicksort lol. It uses Timsort which is a hybrid sort using both merge sort and insertion sort

    • @hektikethnik
      @hektikethnik 4 ปีที่แล้ว

      @@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

    • @hektikethnik
      @hektikethnik 4 ปีที่แล้ว

      @@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)

  • @rmccaber
    @rmccaber 4 ปีที่แล้ว

    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

    • @xycno
      @xycno 4 ปีที่แล้ว

      Rhys doing “if n not in y” is O(N), so overall it would be O(N^2).

  • @spencerkemp5701
    @spencerkemp5701 5 ปีที่แล้ว +10

    def find_missing(full, part):
    return sum(full) - sum(part)
    O(n) time
    O(1) space

    • @JamesBos
      @JamesBos 5 ปีที่แล้ว +1

      Spencer Kemp nice and elegant!

    • @evge
      @evge 5 ปีที่แล้ว +4

      In the video they talk about why this solution is incorrect.

    • @adaai2384
      @adaai2384 5 ปีที่แล้ว +1

      The requirements never said all of the integers were positive.

    • @vadivadiJ
      @vadivadiJ 5 ปีที่แล้ว

      This is pretty shorthand solution that may sound great, but you may never know how big numbers can be, and thus it could be a very space-cost solution. In my experience - such an answer is the one those that interviewers want to hear only in mention(about space complexity, and that it is not preferred), period.

    • @javiertw89
      @javiertw89 5 ปีที่แล้ว

      Nice

  • @HettyPatel
    @HettyPatel 5 ปีที่แล้ว +9

    Shouldve done String [::-1]

    • @DasBeatz
      @DasBeatz 4 ปีที่แล้ว

      Can't use internal features of the language apparently.

  • @joshodom9046
    @joshodom9046 5 ปีที่แล้ว +2

    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

  • @lalalandd123
    @lalalandd123 5 ปีที่แล้ว

    so, is
    def rev():
    user = input()
    new = ""
    for x in range(len(user)):
    new += user[-(x+1)]

    print(new)
    rev()
    an acceptable answer for the first q? i know he said no python features but i guess i dont really know what that limits

    • @lalalandd123
      @lalalandd123 5 ปีที่แล้ว

      and going off this, does this work for the main problem (i used a different test set to make sure it works)
      def findmissing(first,second):
      temp = 0
      missing = 0
      pas = 0
      for x in first:
      pas = 0
      temp = x
      for y in second:
      if temp == y:
      pas += 1
      if pas == 0:
      missing = temp
      print(missing, "is the missing number")

      findmissing([23,19,7,3,6,4,57,39,20,68,91,82,848,297],[23,19,7,3,6,4,57,39,20,68,91,848,297])

  • @anynamecanbeuse
    @anynamecanbeuse 4 ปีที่แล้ว

    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

  • @sabrishgopalakrishnan5156
    @sabrishgopalakrishnan5156 5 ปีที่แล้ว +9

    why cant I just sum first and second and subtract them if they are unique numeric ids?

    • @ekeneakpati4620
      @ekeneakpati4620 5 ปีที่แล้ว +1

      Exactly what i did. Wouldn't work if multiple items are missing though

    • @mindsauce3
      @mindsauce3 5 ปีที่แล้ว +2

      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.

  • @anonymousx935
    @anonymousx935 4 ปีที่แล้ว +2

    first solution is not O(n), its O(n^2)