• Thursday , 28 May 2020

JavaScript interview with a Google engineer

Code Canyon

Check out the feedback by the Google interviewer and the full transcript on https://interviewing.io/recordings/Javascript-Google-3/

This is a recording of a mock interview in JavaScript by a senior Google engineer on https://interviewing.io. Interviewing.io offers senior engineers free, anonymous technical interview practice with engineers from Facebook, Google, and more.

Disclaimer: All interviews conducted on interviewing.io are anonymous. In this case, we got explicit permission from the interviewer and interviewee to share the recording publicly. Interviewing.io has the sole right to distribute the content.

Original source

3d Ocean

Related Posts


  1. CardinalHijack
    December 4, 2019 at 19:28

    As far as I'm aware this is one of the most difficult "challenges" they ask.

  2. gil benjano
    December 4, 2019 at 19:28

    The question isn't clear. What would happen in this case: ABBA, BAAB? should it return AB or BA?

  3. Adrian R
    December 4, 2019 at 19:28

    Doesn't the average use-case of this algorithm merit some consideration in terms of the cost of O(n^2) versus the cost of time spent optimizing? 😉 What kind of strings would ever be so long?
    var s1 = "<string 1>";
    var s2 = "<string 2>";
    var currentInd = 0, termInd = s1.length;
    var sol = "";

    for (currentInd; currentInd<s1.length; currentInd++) {
    for (var sub = termInd; sub > 0; sub–){
    if (s2.includes(s1.substring(currentInd, sub)) &&
    s1.substring(currentInd, sub).length > sol.length) {
    sol = s1.substring(currentInd, sub);

    console.log('Solution: ' + sol);

  4. Abdul Rehman Zahid
    December 4, 2019 at 19:28

    Hello Guys, I have cracked this problem using Python 3. If anyonen need its soluton hit me up

  5. Џон Мастерман
    December 4, 2019 at 19:28

    Poor guy..

  6. Manohar Yeluri
    December 4, 2019 at 19:28

    Me: started watching the video, mind blown after thinking for some time about the solution, started reading the freaking awesome comments.

  7. Ahsan Ali
    December 4, 2019 at 19:28

    function A (s1,s2){

    let result = {}

    let s2Array = […s2]

    let s1Array = […s1]



    if(res === res2){

    result[i] = res2




    return result;


    i solved this in 10m

  8. Stanislav Doskalenko
    December 4, 2019 at 19:28

    To be honest it’s pretty easy

  9. Raghu Madhavan
    December 4, 2019 at 19:28

    Much simpler one

    const str1 = 'ABACBDAB'
    const str2 = 'BDCADB'

    function subSequence(str1, str2) {
    const s1 = str1.split('');
    const s2 = str2.split('');
    const obj = {}
    const result = [];

    s1.map(a => {
    obj[a] = true

    s2.map(a => {
    if (obj[a]) {
    if (!result.includes(a))

    return result.join();

    console.log(subSequence(str1, str2))

  10. Jorge Ricaldi
    December 4, 2019 at 19:28

    I am pretty sure that I can resolve this problem in live too, but….. in 2 hours or more 🙁

  11. BGivo
    December 4, 2019 at 19:28

    Too common of a question, so you end up either with someone who has seen it and knows at least about the recursion solution, or someone who hasn't done a basic study loop and will in no way possible just think of the solution on the fly.

  12. Sanjeev Kumar
    December 4, 2019 at 19:28

    I would have solved it just in simple logic that goes in my head
    Start with first Array and and than check position of each element in 2nd for example take ABAZDC and BACBAD
    Character in First = {Positions (Index)in 2nd}
    A = {1,4}
    B = {0,3}
    A = {1,4}
    Z ={}
    D = {5}
    C = {2}
    Now I have (1,4,0,3,1,4,5,2) elements picked up no delete which does not fit in increasing pattern . skip duplicate and unique increasing pattern.
    ist pattern (1,4,5)
    second (1,3,4,5) . These index in second are = ABAD

    2nd Example
    Now I have (4,0,0,2,4,5) skip duplicate and find increasing pattern
    ist = 4,5
    2nd = (0,2,4,5) = GTAB

    a ={0,1}
    (0,1,0,1,0,1,0,1) skip duplicate and find increasing pattern
    first (0,1) = aa

  13. P K
    December 4, 2019 at 19:28

    In my second year of college for CS, and I been stressing a lot lately need some tips. So I had a lab of 10 problems and I did all of them except #9 which had 3 parts, I had 2 parts working and the 3rd wasn’t fully working. I went to the TA’s which weren’t much help lol. Ever since then I felt like I don’t know if I want to continue doing this, but that might because of how much stress I was under that week from all my classes plus this lab. I talked to my teacher about this and he said I’m doing better than about 70% of the class, even though that’s good I still been feeling super stressed out and not sure if this major is even for me anymore. Lol any suggestions or tips? Sorry for the long comment

  14. kaz u
    December 4, 2019 at 19:28

    nerd interview XD cringe

  15. Pi 3.1415
    December 4, 2019 at 19:28

    function subsequence(s1,s2){
    let subS="";
    let tmp="";
    let idx=0;
    let start=0;
    for(let i=start;i<s1.length;i++){

    Could work but its complexity is like n^3 lol

  16. Avery Mikael
    December 4, 2019 at 19:28

    I didn't understand the question until like i read the comments lmao, but took 5 mins to code it. Just copied s1 with let, mapped over s2 and if a letter occured in s1 return true, then cut s1 till after that letter(so that you know you are always moving forward with the letter check), then just turn s2 array into a string

  17. MrTastee
    December 4, 2019 at 19:28

    Could someone explain me why "ABAZDC", "BACBAD" => "ABAD" ?. It should be just "ABA", that "Z" triggers a -1 for the indexOf, It should reset the process and returns "ABA".

  18. Brennan Smith
    December 4, 2019 at 19:28

    This isn't a "javascript interview". It's a problem solving exercise that lets them evaluate how you think, how you approach things, how well you adapt when your initial assumptions fail hard etc etc. Hence the beginning question: "what language do you want to do use?" They could give a shit if its java or C++ or js.

  19. DigtBrain2
    December 4, 2019 at 19:28

    it's like they don't learn how to use dynamic programming any more … yeah why should you learn the basics if your future employer needs just someone to turn that angular app into a vue one … right?

  20. Dexter Porter
    December 4, 2019 at 19:28

    The shortest possible solution I can think of

    function checker(s1,s2){

    const str = [];

    const arrS1 = […s1];

    const arrS2 = […s2];

    for(let i = 0; i < arrS1.length; i++){

    if(arrS2.indexOf(arrS1[i]) > -1){





    return str.join('');


  21. Wi Fi
    December 4, 2019 at 19:28

    I think I solved this

    // "ABAZDC", "BACBAD" => "ABAD"

    // "AGGTAB", "GXTXAYB" => "GTAB"

    // "AA", "AAAA" => "AA"

    // "ABC", "XYZ" => ""

    function go(a, b) {

    if (a === "" || b === "") {

    return ""


    if (b.length > a.length) {

    const c = a

    a = b

    b = c


    function getNextMatchingChar(x, y, pattern) {

    if (!x.length || !y.length) {

    return pattern


    for (let i = 0; i < x.length; i++) {

    const char1 = x[i]

    for (let j = 0; j < y.length; j++) {

    const char2 = y[j]

    if (char1 === char2) {

    const newX = x.splice(i + 1)

    const newY = y.splice(j + 1)

    return getNextMatchingChar(newX, newY, pattern + char1)




    return pattern


    const res = getNextMatchingChar(a.split(''), b.split(''), '')

    console.log('res', res)


    go("ABAZDC", "BACBAD")

  22. calvin yip
    December 4, 2019 at 19:28

    Watching this I feel stress af lol and I am a computer science student lol.

  23. Jason Ennis
    December 4, 2019 at 19:28

    Every comment here deserve 1k like .. even mine .

  24. Amrish Kushwaha
    December 4, 2019 at 19:28

    Tried it

    function getLongestSubseq(s1,s2) {
    let result = "";
    let start = 0;
    if(s1.length === 0 || s2.length === 0) {
    return result;
    for(let i = 0; i < s1.length; i++){
    j = start;
    while(j< s2.length) {
    if(s1[i] === s2[j]){
    result = result + s2[j];
    start = j + 1;
    return result;
    function LongestSubseq(s1,s2) {
    const first = getLongestSubseq(s1,s2);
    const second = getLongestSubseq(s2,s1);
    if(first.length > second.length) {
    return first;
    } else {
    return second;
    console.log(LongestSubseq("AGGTAB", ""));

  25. emmlog
    December 4, 2019 at 19:28

    if this question was for a front end role the interviewer is out of mind

  26. Northern Wealth Anarchy Perimeter
    December 4, 2019 at 19:28


    Iterate over each char of s1.

    Search for first matching char of s2.
    If letter is found, concatenate to new string s3 and remove all characters leading up to the matching char of s2

    At end of loop, Return s3

  27. Quote
    December 4, 2019 at 19:28

    Here is my solution: https://github.com/Quoteme/Interviews/blob/master/js/longestSubstring.js

    const cs = (x,y) => {
    if(!x.length || !y.length)
    return "";
    return x[0] + cs( x.slice(1), y.length>0? y.slice(y.indexOf(x[0])+1):"" );
    return cs( x.slice(1), y )

    const lcs = (x,y) => Array.from(x)
    .map( (e,i) => x.slice( i ) )
    .map( e => cs( e,y ) )
    .reduce( (a,c) => a.length>c.length?a:c , "" )
    just pass your strings into lcs (_l_ongest _c_ommon _s_ubsequence) and you will get the right answer.
    I used only 12 lines of code and finished in ~45 minutes (but it should have been less, if only i didnt need to set up node.js)

  28. TheCommentBeatKiller
    December 4, 2019 at 19:28

    So i got in to watching these google interviews today….I really use to think I was at least a half decent programmer.

  29. Marco Castellano
    December 4, 2019 at 19:28

    My solution: https://gist.github.com/marktellez/7c667755dadc25815fa03f56bdc683a1

    I have been coding since 1997. ( codementor.io/marktellez ) These coding "challenges" are a waste of time and do little to show the intelligence of the coder nor do they ever come up in "real world" coding…. I have written trading algorithms, blockchain tech, gambling software, RNA sequencing libraries, music sequencing, video and text based games, and countless projects to do with social networks.

    A much better challenge would be to throw someone into a pull request for a real bug and see how they dig through a codebase, read code, and come up with a way to write a test for the solution to the bug. This is just a jerk off fest.

  30. pankaj suthar
    December 4, 2019 at 19:28

    Which tool or website you are using for interview live coding?

  31. Tobi Lukan
    December 4, 2019 at 19:28

    function proc(a,b,aLim) {

    let l = [];

    let bLim = 0;

    for(let i=aLim; i<a.length; i++) {

    for(j=bLim; j<b.length; j++) {

    if(a[i] == b[j]) {

    bLim = j+1;






    return l.join("");


    function longest(a,b) {

    let strAr = [];

    for(let i=0; i<a.length; i++) {



    return strAr.reduce((acc='', val) => (val.length < acc.length) ? acc : val);


  32. Dion Curchin
    December 4, 2019 at 19:28

    I had to watch / listen at 1.5x because I was losing my mind with the long pauses, ums and ahs and oh boy’s

  33. Pulits
    December 4, 2019 at 19:28

    I solved this problem a while ago in LeetCode. I solved it by myself without using Google. It took around 2-3 hours, but I did it. I consider myself a decent engineer.

    Here's the deal. The thing with these types of interviews is that you have a time limit. Also, someone is pushing you not only to solve it but also to solve it efficiently. You need to perfectly and casually explain your answer and reasoning and already have a better solution if possible and have a regular chit-chat with that guy like if it was nothing special. Also, it is most likely that you won't even have a text editor.

    If you pass through that struggle, you need to repeat that for another 5-6 rounds of the same hell (depending on the company). If one interviewer doesn't like you for whatever reason, it's over, even if you solved the problem. Once you are done with the tech interview, there are also behavioral interviews.

    From my experience (interviewing at Google and Microsoft), the interviewer will rarely help you, if at all.

    My friends who work at any of the big four prepared themselves for a year and repeated the process several times. This interview is "easy mode" compared to the real thing.

Leave A Comment

You must be logged in to post a comment.