Skip to content

Instantly share code, notes, and snippets.

@bogas04
Last active April 8, 2019 05:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogas04/b0d72ec3056422b25eeaa07fe74228b5 to your computer and use it in GitHub Desktop.
Save bogas04/b0d72ec3056422b25eeaa07fe74228b5 to your computer and use it in GitHub Desktop.
SumoLogic Interview Questions - Senior Software Engineer (UI)

Sept 2017

Following are the details of the interview questions asked by SumoLogic (Noida) for Senior Software Engineer (UI) role. I did clear the interviews and was offered the position with a very handsome package.

Round 0

The round began with the very first call from the Abhishek Porwal, the Tech Recruiter of the firm. He very briefly explained about the company, its work, culture & about the position they were intending to inteview me for.

I was really nervous and excited at the same time. This was my first frontend-related as well as lateral job interview. There were too many "what if?" & "would they ask this?" questions going on in my head.

Anyway, the call concluded with him sending me a link of an assignment, which was supposed to be completed within 24 hours. The task was to implement a dialog with two input fields that were supposed to auto-complete, and also react to changes to each other, without use of any library for autocompletion (<datalist/> included). It was also important to make it as close as possible to the design mockup.

You can check my submission here. It was very interesting to make all this within a day. I also took care of things like accessibility (tabbing/arrow key support).

Round 1

This was comprised of two parts, both were telephonic (Skype + Collab editor).

Round 1.1 - JS Fundamentals

  • What's wrong with following piece of code?
var a = "apple";
a[0] = "A";
  • What are immutable types?

  • How to implement the above properly ?

  • What is this in following code snippets

// global namespace
console.log(this);

// inside a function in global namespace
function hello () {
  console.log(this);
  return 'Hello';
}

// inside an arrow function in global namespace
const greet = () => {
  console.log(this);
  return 'Greetings';
}

// a method of object
var Dog = {
  bark: function () {
    console.log(this)
  }
}

// a class method
class Animal {
  eat () {
    console.log(this);
  }
}
  • What is prototype?

  • How is it used for inheritance ?

  • What is the difference between abc.prototype and abc.__proto__?

  • How can we stop a function from getting hoisted ?

  • What will be the output of following code ?

var i = 0;

for(; i < 10; i++) {
  setTimeout(() => console.log(i), 0);
}
  • What is synchronous code ? What is asynchronous code ?

  • What is event loop ?

  • What is callback hell ?

  • What are promises ? How do they solve that problem ?

I struggled with this & prototypes. I encourage everyone to sit and take time to wrap their heads around it.

Round 1.2

This round was around coding. I loved this round as I pretty much aced it :P However I was very scared of this round, as I thought I might be asked about complex data structures & algorithms.

  • Find largest string in a nested array
function longerOf (a, b) {
  return a.length > b.length ? a : b;
}

function getLargestString (arr) {
   // Solution
    
    return arr
      .reduce((longestSoFar, value) =>
        typeof value === 'string'
          ? longerOf(longestSoFar, value)
          : longerOf(longestSoFar, getLargestString(value))
      , '');
    
  
}

// Tests
const strings = ["a", "ab", ["abcd", "derfg", ["asdasd", "DGdgdfsg", "asdgsdfhsdhf", "sdafsafsadfsadfsdfsadf"], "sdfsdfsd", "asdfsaf"], "sdafasdf", "sdfsadf", "sadfsafsd"]

console.assert(getLargestString(["a", "bc", "bcd"]) === "bcd")
console.assert(getLargestString(strings) === "sdafsafsadfsadfsdfsadf")
  • Flatten a folder tree stored in JSON.

Input

const root = {
  value: 1,
  children: [
    {
      value: 2,
      children: [
        {
          value: 5,
        },
      ],
    }, {
      value: 3,
    }, {
      value: 4,
      children: [
        {
          value: 6,
        }
      ],
    },
  ]
};

function flattenTree (node) {
   // Solution
  
// base case

if (!node.children) { return [ node.value ]; }

const flattendChildren = node

.children

.map(flattenTree)

.reduce((arr, v) => [ ...arr, ...v ], []);

return [ node.value, ...flattendChildren ];

}

console.assert(flattenTree(tree) === [ 1, 2, 5, 3, 4, 6 ])
  1. Debug given code. Find complexity. Optimize.
function isUnique (arr, itemIndex){
  for (let i = 0; i < arr.length; i++) {
    if (itemIndex !== i && arr[itemIndex] !== arr[i]) {
      return true;
    } else {
      return false;
    }
  }
}

function uniq (arr) {
  let _uniq = [];
  for (let i = 0; i < arr.length; i++) {
    if (isUnique(arr, i) {
      _uniq.push(arr[i]);
    }
  }
  return uniq;
}
Solution
  • Return statement is wrong, will cause problem
  • O(n^2)
  • Use hashmap approach. You may use `Set` or plain object with values as keys.
  • I used keys approach, had to fix for "1" vs 1. I simply prepended _ for strings.
  • obj[typeof value === "string" ? `_${value}` : value] = value

Round 2.1

  • Implementing a Function.prototype.curry function that accepts some args and returns curried version.
  • Repaint vs reflow. Some questions around when would something cause a repaint and reflow. Use this page for referrence.
  • Flexbox related questions using a sample CSS code. Practice with flexbox froggy
  • Then same example with float.
  • What’s box-sizing ? How is clearfix class written ?
  • position:absolute vs position:relative

Round 2.2

Random chit chat. How can we speed up SumoLogic.com. what things we’ve done wrong? What’s done right? Then he asked random questions, probably to check communication skills or confidence. I doubt answer mattered to those questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment