Missing item list difference: Python interview with an Airbnb engineer

Поделиться
HTML-код
  • Опубликовано: 22 дек 2024

Комментарии • 832

  • @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 5 лет назад +897

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

  • @jamieguthrie1760
    @jamieguthrie1760 5 лет назад +879

    Got the awkward goodbyes down perfectly!

    • @irvinge4641
      @irvinge4641 5 лет назад +11

      lol

    • @newinhuman
      @newinhuman 5 лет назад +10

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

    • @danielgitahi2847
      @danielgitahi2847 5 лет назад +1

      Lmaoooo. My ribs

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

  • @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 5 лет назад +13

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

  • @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 5 лет назад +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

  • @UncleT0ny
    @UncleT0ny 5 лет назад +893

    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 лет назад +75

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

  • @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 лет назад +550

    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.

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

  • @happybroski2112
    @happybroski2112 4 года назад +17

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

  • @TurtlesWrath
    @TurtlesWrath 5 лет назад +66

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

    • @mattwyd2161
      @mattwyd2161 5 лет назад

      ageofwar2000 negative indexing is bad form

    • @qwarlockz8017
      @qwarlockz8017 5 лет назад

      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

  • @danielmateofitness7618
    @danielmateofitness7618 5 лет назад +54

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

  • @nislaav6712
    @nislaav6712 5 лет назад +74

    literally 27 min of my deepest anxiety

  • @bikesbeersbeats
    @bikesbeersbeats 5 лет назад +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.

  • @lahire1295
    @lahire1295 5 лет назад +32

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

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

  • @JackMarchetti29
    @JackMarchetti29 5 лет назад +31

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

  • @HighTimesTrader
    @HighTimesTrader 5 лет назад +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 5 лет назад +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 5 лет назад +1

      Probably not since it's a mock interview

  • @matthew4497
    @matthew4497 5 лет назад +573

    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?

  • @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 5 лет назад

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

  • @user-db1uj2px9l
    @user-db1uj2px9l 5 лет назад +675

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

  • @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 5 лет назад +11

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

  • @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 лет назад +71

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

    • @cameronratliff94
      @cameronratliff94 5 лет назад +1

      raskec1 exactly

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

  • @Skullarious
    @Skullarious 5 лет назад +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

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

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

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

  • @Nickdude6
    @Nickdude6 5 лет назад +30

    Listening to this muted, sounds good

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

  • @carlosalba9690
    @carlosalba9690 5 лет назад +4

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

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

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

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

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

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

  • @tahseenrahman2922
    @tahseenrahman2922 5 лет назад +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)"?

    • @cloud15487
      @cloud15487 5 лет назад +2

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

    • @realamztvs
      @realamztvs 5 лет назад

      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 5 лет назад +3

      amzshow4life that’s got 2 elements missing lol

    • @cloud15487
      @cloud15487 5 лет назад

      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 5 лет назад

      integer type overflow, I guess

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

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

  • @chromaetheral
    @chromaetheral 3 года назад +1

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

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

  • @GabeTheYabe
    @GabeTheYabe 5 лет назад +11

    Does anyone know if he has a vid with using C++?

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

  • @adrianzekaoui118
    @adrianzekaoui118 5 лет назад +1

    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?

    • @goost0852
      @goost0852 5 лет назад +1

      Yes and he says that later

    • @adrianzekaoui118
      @adrianzekaoui118 5 лет назад

      @@goost0852 ah, I didn't finish the video

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

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

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

  • @Gbyrd99
    @Gbyrd99 5 лет назад +5

    Where the hell is the code output?

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

  • @kiorq
    @kiorq 4 года назад +3

    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

    • @user-ob5hj5vn8c
      @user-ob5hj5vn8c 4 года назад

      Yeah, thats a smart solution, well done. Same time complexity, but excellent space complexity.

    • @cyriacignatius
      @cyriacignatius 4 года назад

      I came to the comment section to see why this was not what was done....

    • @daveh9941
      @daveh9941 3 года назад

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

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

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

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

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

  • @lukkash
    @lukkash 5 лет назад +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 ;)

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

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

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

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

  • @soyoutube22
    @soyoutube22 4 года назад +1

    Isn't Heap sort O(N) space?

  • @gsb22
    @gsb22 4 года назад

    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

  • @__-to3hq
    @__-to3hq 5 лет назад +20

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

  • @yueliang5604
    @yueliang5604 5 лет назад +4

    For the second, what if i sum up all the number and then minus the other's sum

    • @ronaldmackee3401
      @ronaldmackee3401 5 лет назад

      Better yet, to avoid potential overflows (if not Python), XOR all the numbers and you get the missing one.

  • @JSmih7
    @JSmih7 3 года назад +3

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

  • @ArtyomPalvelev
    @ArtyomPalvelev 5 лет назад +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)

  • @karljay7473
    @karljay7473 5 лет назад +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?

  • @JesseLH88
    @JesseLH88 5 лет назад +1

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

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

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

    • @andres_javier
      @andres_javier 2 года назад

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

  • @Suhaschintala
    @Suhaschintala 5 лет назад +3

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

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

  • @IkePhillipRuffin
    @IkePhillipRuffin 4 года назад +1

    What other professions require you to take a practical exam to get a job?

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

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

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

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

  • @MrEmbrance
    @MrEmbrance 2 года назад

    so what is the time complexity of the first solution ? O(N^2) ?

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

  • @brettvantassel4325
    @brettvantassel4325 4 года назад

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

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

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

  • @franciscov511
    @franciscov511 3 года назад

    In java StringBuilder can be used to have o(n) complexity

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

  • @yohanabergz2750
    @yohanabergz2750 5 лет назад +1

    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?

    • @Lost1nTranslation
      @Lost1nTranslation 5 лет назад

      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.

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

  • @aibh7903
    @aibh7903 4 года назад

    Could you pick Haskell as the language for this?

  • @jackriver1999
    @jackriver1999 5 лет назад +38

    the interviewer sounds like DJ Vlad

  • @MR2SpyerJournal
    @MR2SpyerJournal 5 лет назад

    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.

    • @nahfamimgood
      @nahfamimgood 5 лет назад

      yep! if he had just ran the for loop backwards and added to the output that it would have been O(n)

  • @JulianColeman03
    @JulianColeman03 5 лет назад +13

    I need to learn more from this man.

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

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

  • @stevecarino246
    @stevecarino246 5 лет назад +16

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

    • @vazhaabdu4529
      @vazhaabdu4529 4 года назад

      yeah it could be done in one line

  • @davemittner5911
    @davemittner5911 3 года назад

    def reverse(str):
    return str[::-1]
    No idea about the space time continuum mumbo-jumbo, though. =/

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

  • @JustQuitBro
    @JustQuitBro 5 лет назад +1

    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.

    • @cokoala5137
      @cokoala5137 5 лет назад +2

      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

    • @alcesmir
      @alcesmir 5 лет назад

      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.

  • @mrala
    @mrala 4 года назад

    18:24 quick sort would be log(n)? emmm sry ? isn't it nLog(n)?

    • @pradiplamsal1403
      @pradiplamsal1403 3 года назад

      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.

  • @hektikethnik
    @hektikethnik 5 лет назад +2

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

    • @hektikethnik
      @hektikethnik 5 лет назад

      @@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 5 лет назад

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