Python interview with a Google engineer: Edit distance string comparison

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

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

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

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

    "let me think this through"
    *goes on stackoverflow for 5 minutes*

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

    bruh why does my heart rate go up when watching these

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

    Really good interview overall. Easy problem in the beginning but quite challenging under a set time limit by the end.
    The ending is awkward though and I love it! "Good luck with all your interviewing!" "Thanks! You.. you as well." sounds like something I would do haha

    • @RJ.CreativeStudios
      @RJ.CreativeStudios 5 ปีที่แล้ว +19

      Simon Kay well the interviewer is also "interviewing" other candidates lol

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

      You call this a good interview? Don't think this helps finding good engineers.

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

      @@Madinko12 What's wrong with it? Shows problem solving skills

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

      @@SimonsTechShow I don't agree 😕. If you prepare before the interview, you can become good at solving this specific kind of questions and it does not make you a better developer or engineer. It makes you better at this specific type of interviews just like playing chess doesn't make you suddenly good at maths or game theory. Even worse, I think it's possible to be a quite bad engineer, train hard on this sort of exercices and succeed. Conversely, you can be a quite good engineer and just completely fail. It's so far away from the problems you encounter on a daily basis IMO, it doesn't tell anything about how competent you are for the job. At least, if I were the interviewer, I wouldn't have had any clue on whether the interviewee is able or willing to follow the changes in the industry, is able to solve real-world problems with proper tooling (and why he would use that tool instead of some other), knows how to test his code and why, how he behaves in front of an open problem (can he find heuristics to simplify it?), does he have a profound knowledge of what he does/uses or is he just a superficial person…
      If you really want to evaluate problem solving skills, I think a Google Hashcode style open-problem is a better fit. The interviewee doesn't have to code live which causes some other issues and bias. You don't even need to look for a particular unique answer (which doesn't exist in real life anyways). You can just discuss with him of his answer, see if he knows the limitations, implications, evolutivity, if he has ideas on how to improve it. Talking of converting an n.log(n) algorithm to n, when 99.999% of the time it won't matter and will just make your code far less readable for the next person or yourself is ridiculous. And when on top of that your stack is mostly in a scripted language.

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

      the interviewer is autistic af

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

    For anyone learning - there is actually a bug in the final solution of ins_del_compare() (with tolereance = 1). For strings with edit distance > 1, but length difference = 1 (e.g. "abdeX" and "abCdeF" function will throw StopIteration instead of returning false.

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

      Which he could have caught, but his solution was just not scalable (in terms of longer edit distance) from the start.

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

    13:30 Minor nitpick. The space complexity of that code is O(n) just because range is used rather than xrange. In python2 range generates a list.

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

      No need for range at all, he could just iterate the string itself.

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

      @@sanshinron Iterating through the string itself will not do since he needs elements from both strings. The pythonic thing to do in that case is probably to use zip to iterate both in parallel. Python2's zip has the same problem as range though, so you would have to use itertools.izip in that case to get the lazy version.

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

      So the question is, why is he using python2 :p

    • @gabrielb.2886
      @gabrielb.2886 5 ปีที่แล้ว

      @@alcesmir iterating through the string just for counting, not for using the elements, just as he is iterating through the range for counting only.

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

      @@osquigene so he can write print instead of print()

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

    When they introduced the tolerance ... the solution i had was just a improvement of his first solution
    Something like :
    do you see any edge case i didnt think about ?
    def case_insensitive_compare(s1, s2):
    err_margin = 3
    l_s1, l_s2 = len(s1), len(s2)
    index, err_counter = 0, 0
    while index < max(l_s1, l_s2) and err_counter

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

    I dislike how the interviewer went RIGHT into the question. No greetings, no introduction... The guy said “it’s my first one of these” and the dude literally didn’t answer lol

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

      Philgob yeah that’s disappointing, the same happened to me yesterday, I thought maybe I did something wrong and they’re not talking to me, but it’s pretty standard!

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

      I had an 45min coding interview where I had a long conversation with the interviewer, turns out later that the time spend on discussion was part of the coding challenge. I could not complete my challenge in less than 30 min. Of course I failed, I do not recommend wasting time during the coding task, keep all the talk for after.

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

    #clickbait I wanted to see a Mighty Eel vs. an Intergalactic Avenger. This isn't even a SciFi channel movie.

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

    I'm majoring in Comp Sci. and seeing interview questions like these get me scared cuz I like have zero confidence in my abilities.

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

      With time and hard work comes confidence in your abilities. Everyone was afraid at first.

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

      Don't worry, they are all BS programming exercises they found in a book. Head over to Stackexchange and you'll find the solution posted to one of the other 10,000 people that have gotten the same question.

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

      Yeah your daily job wont use much if any of this. I personally learned on my own through MIT freeware courses and projecteuler.net problems. The project eulers are actually kind of fun and you'll make break throughs if you really work on them but you need to have gotten through your first comp sci course or have equivalent experience to solve them. Some of them are extremely difficult specifically the ones for me anyways involving geometry and stuff.

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

      95% of these interviews are useless. They happen because no one knows a better way to assess and compare candidates.

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

      Surprisingly insecurity is most likely among the ones who start programming through school.

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

    i'm pretty sure the interviewiee was searching the internet, you can hear clicks and typing during the long silences

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

      I believe Google allows you to access the internet if you want. I saw it in one of such interviews where the interviewee asks the interviewer if he can quickly check something on the internet.

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 5 ปีที่แล้ว +2

      Mind you interviewer notices it all, and can "grade" you down, in his report or whatever they make, for that. I mean, you don't even know what they're searching, and pretty often these algos are the ones commonly asked, or atleast some component of it is.

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

      Welcome to programming. Most of your time will be spent on stack overflow... Being a good programmer is also about being able to quickly find what is the source of the said problem and therefore find a solution quickly and effectively. Now chances are someone else before you ran into that problem which is why we also require to be able to browse forums & documentation in a way to minimize time spent looking for the solution and be apply to apply it in regards to our code.

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

      If a company expects you to memorize every single detail of a language and it's libraries, they are idiots.

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

    There is an error with the code at 30:00. Let's take the input "AA" "BAB", in that case the length check passes, but the checks will go like
    "(A)A" "(B)AB" not a match, skip in longer to get "(A)A" "B(A)B" which matches
    "A(A)" "BA(B)" not a match, skipping the longer string raises a StopIteration (and the program crashes)

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

      Exactly, a counter variable which counts the number of times one of the strings had to be advanced once more would have worked better for once because of scalability, and he should have caught these exceptions.

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

    A different approach to the second part with the tolerance!
    def str_comp_dist2(str1,str2,tolerance):

    list1 = max(list(str1.lower()),list(str2.lower()))
    list2 = min(list(str1.lower()),list(str2.lower()))
    len_missing = len([True for i in list1 if i not in list2]) + len([True for i in list2 if i not in list1])
    if len_missing

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

    i did this for the second part of the problem:
    def compare(str1,str2):
    err=0
    order = sorted([str1,str2],key=lambda x: len(x), reverse=True)
    if len(order[0]) - len(order[1]) > 1:
    return False
    for i in order[0]:
    if i.upper() not in order[1].upper():
    err +=1
    if err > 1:
    return False
    return True

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

    This is painful for me because I approach so many problems with future-proofing in mind. I started mapping a solve out in my head and I immediately assumed the difference tolerance should be optional and settable to any integer. That would make this problem particularly difficult for me because I'd be distracted the whole trying to make such a narrow solution.

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

      I think that's a sign of more planning needed before solving

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

    For 8:31, if you're trying this stuff, please, please, use Python 3. There's no point in using Python 2 nowadays. It's soon ending support (January of 2020 if I remember correctly) and Python 3 provides quite a few nice abstractions to deal with the pain of strings and encoding. Also not to hate, but that solution is atrocious, a much better solution, which nice Python 3 abstractions would have been:
    -----
    def case_insensitive_compare(s1, s2):
    if len(s1) != len(s2):
    return False
    if s1 is s2:
    return True
    return all(a.casefold() == b.casefold() for a, b in zip(s1, s2))
    ---
    This makes use of a few tricks. First it checks if s1 and s2 are the same object in memory with is. Python (or CPython anyway) is quite smart and will try to optimise by storing a string in memory, and if another variable with the same string is created it will simply point to the same memory address (you can test this by creating two variables with the same string characters, and doing id(string) on each)
    Second, all() with the generator comprehensions and zip(). zip() returns a tuple of the iterators you pass it, in this case s1 and s2. It stops when one of the iterators is consumed. all() takes an iterator of True and False values, and if all are True it returns True (or False at the first False value). By using a generator comprehension, we can make it short circuit (so end early) at the first False value.
    Third, casefold(). This is Python's 3 attempt, with Unicode, to do case insensitive comparisons. Plenty of languages have special characters, with special case rules. casefold() provides the base lower string to use for comparison.

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

    Well since he did the first function really well, I think a simple counter would do just fine. When they have the lengths different by 1 for instance, you can book a key,value pair for each character and their counts. First string will create the hash and second will add on to it. In the case 'ABC' and 'ABCD' for example the hash would look like: ,,,. If there are more than one '1' in the value list, it will return false. When user is asked for the edit distance, you do the same with one difference and that is you will not check the false statement for 'more than one 1 in the value list' but more than 1 in the value list'. I haven't tried this just typing while watching but I think this works and the code will look a lot cleaner and easier.

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

      Would not work in case of ABC and ABDD in case tolerance for edit distance is 1...

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

    The guy knows some python (2 though) for sure, but he's never taken an algorithm course, Levenshtein distance and dynamic programming are so standard he would have at least remembered when he heard "edit distance". It's pretty clear he's reading about it at some point. From my point of view that's a long way from the technical level a Google engineer should have!

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

      /r/iamverysmart

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

      @@TheMaxofSpades ^^

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

      If he didn't know, or just forgot, then it's pretty impossible to figure it out in a couple of minutes.

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

      pretty sure he google searched that part off-screen..

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

      But he did mention it at the end of this video. So I am pretty sure he knows it. So your assumption that he doenst know it is at least wrong. Either that or he quickly googled it lmao.

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

    8:20 that damn Macbook click

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

      hahaha

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

    Tried to follow along, this was my java solution. Tips appreciated!
    public static boolean caseInsensitiveCompare(String a, String b){
    int editDistance = 0;
    int editLimit = 1;
    int smallLength = a.length() > b.length() ? b.length() : a.length();
    int diff = Math.abs(a.length() - b.length());
    if(diff > editLimit){
    return false;
    } else {
    editDistance += diff;
    }
    for(int i = 0; i < smallLength; i++){
    if(editDistance > editLimit){return false;}

    if(Character.toUpperCase(a.charAt(i)) != Character.toUpperCase(b.charAt(i))){
    editDistance++;
    }
    }
    return true;
    }
    I could also stick the tolerance as a method parameter and replace editLimit with the tolerance value

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

    def compare(s1,s2,tolerance):
    its1 = iter(s1)
    its2 = iter(s2)
    miss = 0
    for _ in range(max(len(s1),len(s2))):
    if next(its1,'none').upper() != next(its2,'none').upper():
    miss = miss + 1
    if miss > tolerance:
    return False
    return True
    print(compare('AB','abcde',2))

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

      As I've commented a bit earlier that would not work.

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

    I'm pretty sure that's Joma's voice xD

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

      I was thinking more Kumar from Harold and Kumar the whole time lol

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

    def compare(s1, s2, dis):
    if dis < abs(len(s1) - len(s2)):
    return False
    for i in range(min(len(s1), len(s2))):
    if s1[i].upper() != s2[i].upper():
    return compare(s1[i+1:], s2[i:], dis-1) or compare(s1[i:], s2[i+1:], dis-1)
    return True

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

    public boolean compareCaseInsensitive(String str1,String str2){
    return(str1.equalsIgnoreCase(str2));
    }
    //unless we're asked to define equalsIgnoreCase() itself

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

    first i would check string length then see if first and last letter are the same then execute

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

    25:00 "aw shit"

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

    Even in the best case, final code around 12.25 will have time complexity of O(n) since he is checking length of both the strings. And len() function has linear complexity.

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

      The len() function is not linear time, it is constant time. A list maintains a size variable that is O(1) time to access. The size is updated on each insertion / deletion of the list. Thus, when you need the len() it just returns that member variable under the hood. It doesn't count all the elements each time

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

      @@davidgaster
      Thanks. Didn't know that.

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

    I followed the questions and got to this code:
    def case_insensitive_compare(strA,strB, tolerance):
    str1, str2 = sorted([strA, strB], key=len)
    if len(str2)-len(str1) > tolerance:
    return False
    flag = 0
    for char in range(len(str1)+(len(str2)-len(str1))):
    if char+flag == len(str1):
    return True
    if str1[char+flag].upper() != str2[char].upper():
    flag -= 1
    if flag < -tolerance:
    return False
    return True

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

      len(str1)+(len(str2)-len(str1)) == len(str2) also in some usecases (ie. case_insensitive_compare('AbCdE', 'acdef', 2), strings are equal length, same number of insertions and deletions) your code will give a false negative. But good approach!

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

    In my opinion, in a real interview, the candidate would have been rejected. Reasons:
    1. Too many hints.
    2. Sub-optimal solution.
    3. Time / Space Complexity calculations were not sure either.
    Given these many flaws and considering the no. of candidates companies get, am sure its a reject. Sorry, no on-site.

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

    This seems to be mocked up interview ! Google uses Google Docs :) !!

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

    Will a comparison between the ID(variable) function and if they are == then it is true and if not false work?

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

    why not to use a map of upper case letters and increment each one if there is one in the s1 and s2 and then see if all of them are 2 except 1?

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

      wont be O(1) memory anymore

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

      Not only you assume that every letter is only used once but you also lose order: abcdef != fedcba

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

      Order is fixable by mantaining an index of letter in word in the map. But memory O(1) is indeed lost. Then we need to move two indices if they are equal and move only one if they are not and say the difference is 1, if that happens again - return false. This is probably what he is doing. This Python code is so unreadable I'm not sure but it has to be it. Thanks for pointing out about memory complexity.

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

    def string_diff(str1, str2):
    short, long = sorted([str1, str2], key=lambda s: len(s))
    diff=0
    for i in range(len(long)):
    if i > len(short)-1:
    diff+=1
    continue
    if short[i].lower() != long[i].lower():
    diff+=1
    return diff

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

      This does not work. string_diff('abc', 'dabc' ) should give a difference of 1, but this gives 4. You need to modify the index you're comparing after a found difference. I've posted a solution below.

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

      @@dirklaren7266 You're right, my solution does not cover many cases

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

      @@dirklaren7266 You're right, my solution does not cover many cases

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

    The Mighty El is pausing with that silence that comes with looking up shit on StackOverflow

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

    I'm confused, is the interviewer the Google engineer or the interviewee?

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

      @Winston Mcgee oh I see

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

    def edit_distance_compare(s1, s2, tolerance=2):
    # O(max(s1, s2)) time; O(1) space
    # Not expecting equality very often
    if abs(len(s1) - len(s2)) > tolerance:
    return False
    # s2 is never shorter
    if len(s1) > len(s2):
    s1, s2 = s2, s1
    offset = 0
    for i, c1 in enumerate(s1):
    c1 = c1.lower()
    while True:
    c2 = s2[i + offset].lower()
    if c1 == c2:
    break
    else:
    offset += 1
    if offset > tolerance:
    return False
    return offset

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

    s1_iter = iter(s1) killed me xD

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 5 ปีที่แล้ว

      Why?

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

      @@VivekYadav-ds8oz There is no reason to create an iterator, strings are iterable, there is no reason to call range as we don't need the index (use izip). Smaller other things: use all (/any) in these case, using python2 instead of python3 for an interview is strange. Finally you can even use map as the loop does more or less nothing interesting here (if you use all/any).
      In the end you could have (python3):
      def comp(x, y):
      def letter_eq(chars):
      a, b = chars
      return a.upper() == b.upper()
      return len(x) == len(y) and all(map(letter_eq, zip(x, y)))
      It does the exact same thing, but it looks like python code (if you prefer you could still split the last test in two lines, if you find it more readable).

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

      @@dorrelmatad160 at that time even 3.4 was released

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

      osquigene are you a senior eng

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

    Which Ide or software they are using ?

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

      Amit Joshi Sublime Text I’m guessing

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

      It's easy they are using just vim

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

      looks like a tool made specifically for these interviews where there is a set of problems and you select your language. the style of the editor looks like sublime. ps if you arent on neovim you should be.

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

    The guy was googling, and reading haha

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

    def edit_distance_str(s1,s2,tolerance=0):
    short_str, long_str = sorted((s1,s2),key=len)
    edit_distance=len(long_str)-len(short_str)
    if edit_distance > tolerance:
    return False
    else:
    for i in range(0,len(short_str)):
    if short_str[i].lower() not in long_str.lower():
    edit_distance = edit_distance + 1
    if edit_distance > tolerance:
    return False
    return True

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

    what do they mean by the time and space complexity?

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

      As a function of the length of the string, L, how long will the program take on the highest order, and how much space will it take. Answers would be something like Linear or Big O of L, quadratic or Big O of L^2.
      Usually this is under Big O notation, which has a wikipedia for more information.

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

      Thank you

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

    don't know how to answer any of the questions from 5:23 and onwards. gg

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

      arkoraa don’t know how to answer any of the questions from 0:00

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

      i could answer most this in c++ or C# but not in python

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

    I hate to say it, but I would fail this guy. Weird iterator code, incorrect line #20, incorrect running times, taking forever to answer the basic questions, and escaping the last question by saying you had to leave.

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

    He could've used the first function, remove the first if statement. take in tolerance as a parameter, set a counter "differences = 0" then change the if not statement to increment the differences counter. then add an if differences == tolerance return False. anyone see an issue with this?

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

      Yes. You only have insertions and deletions, not modifications, so the distance between 'abc' and 'adc' is 2, not 1.

  • @pixelation.channel
    @pixelation.channel 4 ปีที่แล้ว

    Second case would've been fixed if he used lower instead of upper, no extra credit.

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

    Testing for the nitty gritty details of a language, and their ability to prematurely optimize, seems like a really shitty way to evaluate somebody.

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

    /* C++ version solution of case insensitive strings.
    */
    int isEqual(string a, string b)
    {
    a = allLowerCase(a);
    b = allLowerCase(b);
    if(a == b){
    return 1;
    }else{
    return 0;
    }
    }
    string allLowerCase(string a)
    {
    for(int i = 0; i < a.length(); i++){
    if(a[i] >= 65 && a[i]

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

    Once more... They are complicating the python code for a simple algorithms...
    Doesn't he just want confirmation that they strings will be the same - but not easily confused with another string?
    for example, by only having the length of the code and upper as parameters for being the same word, the both strings could have been confused as being the same although they were not.. by another word that was equally long as the other.
    Instead of confusing himself - he could have just done this simple code to make sure that you knew what to do with these strings if they are different or the same:
    def function(s1, s2):
    s1 = s1.lower()
    s2 = s2.lower()
    s_one_len = len(s1)
    s_two_len = len(s2)
    if s_one_len == s_two_len:
    print('ITS TRUE')
    if s1 == s2:
    print('Its double TRUE')
    if s1[::1] == s2[::1]:
    print('Its tripple true')
    else:
    print('ITS false')
    function('abc12','ABC12')

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

    the ammount of "likes" and "uhm" kills me man

  • @lucaspk33.
    @lucaspk33. 5 ปีที่แล้ว

    I tested on the python shell: a = 'ábc' b = 'ÁBC' and then a.upper() == b.upper() and was returned True.

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

    I'm calling bs, because Google starts interviews by explaining the process first. Second, they use Google docs to do the interview.

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

      Read the second paragraph of the video description…

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

      @@spesterwecial so not really an interview.

    • @dr.derekrobinson1920
      @dr.derekrobinson1920 5 ปีที่แล้ว +3

      This is most certainly a mock interview. If you disagree, you are wrong lol

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

      It's interviewing.io, you get to interview with real tech company engineers for practice. You are granted only 2 or 3 interviews. If you do well on any, then you can decide to share your info with the interviewer and if they liked you they could actually ask you to interview for real with them. But if the interview didn't go well you can stay anonymous. It's good practice and good if you're job hunting, big tech companies really do use it.

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

    Funny how it becomes "This is a recording of a mock interview..." when the title states "Technical interview with a Google engineer:..." Classical clickbait. Never knew the product but first point is negative cuz of the deception you're trying to use. Shall I report?

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

    Gosh.. just keep a counter of the edit distance.. way simpler..

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

      I just wrote a stupid solution , its working , I'm not sure if there are some cases it won't work , I just posted in comments here

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

      def compare(s1,s2,tolerance):
      its1 = iter(s1)
      its2 = iter(s2)
      miss = 0
      for _ in range(max(len(s1),len(s2))):
      if next(its1,'none').upper() != next(its2,'none').upper():
      miss = miss + 1
      if miss > tolerance:
      return False
      return True
      print(compare('AB','abcde',2))

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

      @@ijazahmad722 Well no, it won't work, just take the example of 'bc' and 'abc' with tolerance 1, that will return False with your algorithm, while the answer is True.

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

    tough...

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

    Uh uh uh uh uh uh uh IM SHITTING MY PANTS!!! Uh! Uh uh!

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

    this is so easy though..
    sizeVar=math.abs(str1.len-str2.len)
    if sizeVar>tolerance :
    return false
    numMistakes=sizeVar
    iterate index through one stringSize
    if char i of either string is nonexistent (i==len of one of the strings)
    return true
    if char i.upper of str1 != char i.upper of str2
    numMistakes++
    if(numMistakes>tolerance)
    return false
    after iterate
    return true

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

      Razer420 this wouldnt work i dont think. your check for equality requires the same char at the same index, if there was a deletion, youd add a mistake but then every character after that, would also be considered a mistake since youre not accounting for the deletion when indexing. a fix i think would be to keep track of mistakes, and then figure out which string has the deleted one probably the shorter string and always have the index check by i - mistakes (i - #deleted) but then im still not fully sure this would fix everything.

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

      Not even close :)

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

    This guy kinda sucks at being interviewed. Speak up chap.

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

    Python 2...ew

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

    Y no c++

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

    This dude is not ready for a real interview

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

    Python Interview for those who are wondering

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

      No one was wondering 😂

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

      @@omarhabra6689 It said it at the beginning, and they freaking wrote it the whole time.. if someone was wondering.. why is he even watching this video when he doesn't know anything about coding

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

      @@omarhabra6689 And just because it has likes doesnt mean that they needed the information..

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

      Lmao

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

    Google has huge amount of computing resources and top notch researchers, can't they develope an AI to interview candidates? It would save a ton of costly man hours spent on interviewing...

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

      No they can't. I think you are watching too much AI hype videos. It's not even close to that at THIS point. Maybe someday.

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

      If they develop an AI that can take interviews of this level then there is no need to hire software engineers... AI can do that job better

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

    Hurry up and take your site out of beta ffs

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

    I wouldn’t hire this guy just because of how many times he say “uhh, umm”... very annoying!

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

      Damn, I wouldn't hire you because you are a human and human needs to be maintained

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

      Dat Dude LOL

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

      And i wouldn't hire you because you seems like a prick to others.

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

      I wouldn't hire you coz you use too many dots "..." 😂

  • @alexp-ru
    @alexp-ru 5 ปีที่แล้ว

    You're a BAD programmer

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

    def string_diff(str1, str2):
    short, long = sorted([str1, str2], key=lambda s: len(s))
    diff=0
    for i in range(len(long)):
    if i > len(short)-1:
    diff+=1
    continue
    if short[i].lower() != long[i].lower():
    diff+=1
    return diff