DEV Community

Cover image for Software Engineer 2 UI Interview at Microsoft

Software Engineer 2 UI Interview at Microsoft

Dhilip kumar on October 17, 2020

Hello there, For those who don't know me, do check out my website and my other blogs. I recently accepted Microsoft's offer for Software Engineer...
Collapse
 
xerxes3117 profile image
Vaibhav Sharma

Are there any restrictions in machine coding round? Like you have to use pure JavaScript only etc. Or do they allow using any FE frameworks also?

Collapse
 
dhilipkmr profile image
Dhilip kumar • Edited

Yes, ๐Ÿ˜…Vanilla JavaScript and No Css Frameworks allowed!!!

Collapse
 
cryptic022 profile image
Pankaj Kumar

Do you need to create backend as well or you will get json response for mail/chat application?

Thread Thread
 
dhilipkmr profile image
Dhilip kumar • Edited

You don't have to create backend! The package you receive will have a dummy function which keeps giving you data in a regular interval, all you need to do it listen to it.

Thread Thread
 
cryptic022 profile image
Pankaj Kumar

Basically you need to call the api, create skeleton and add filters on Json , right?

Thread Thread
 
dhilipkmr profile image
Dhilip kumar

On those lines along with the constraints added in the requirements

Thread Thread
 
cryptic022 profile image
Pankaj Kumar

Thanks ๐Ÿ˜Š

Collapse
 
xerxes3117 profile image
Vaibhav Sharma • Edited

Thanks. Great article!!

Collapse
 
alankrit_v profile image
ALANKRIT{v}

Congrats sir,
I wanted to know if they will let you solve the DS algo problems in javascript or its benificial to go for python,java or c++
And which language did you choose to practice ds-algo problems on leecode?
I am a begineer and only know javascript so should I continue to practice ds in javascript or do I have to learn python/java for that.
Thank you for your time!

Collapse
 
dhilipkmr profile image
Dhilip kumar

As the role was for UI Engineer, it is best that you use javascript to code! I coded in javascript and practised in leetcode in Js

Collapse
 
alankrit_v profile image
ALANKRIT{v}

Thank you so much sir! and again congratulation on your new job ๐Ÿ˜Š

Thread Thread
 
dhilipkmr profile image
Dhilip kumar

Thanks man ๐Ÿค“

Collapse
 
ronaldorawat profile image
Ronaldo

Hi Dhilip, could you please share resources from where we can prepare for the same. I got rejected by Flipkart and the rounds were same. 1st Machine Coding, 2nd- Problem Solving/DS, 3rd- UI Tech, 4th- Product Round, 5th- Final Round.

Apart from practising on the leetcode, please share other resource from which the UI Developers should prepare for Machine Coding, UI Tech rounds. It will be a great help.

Thanks

Collapse
 
dhilipkmr profile image
Dhilip kumar

As per the "Industry standards" ๐Ÿ˜›

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
benjamingr profile image
Benjamin Gruenbaum

This annoyed me so much I signed up to dev.to

Collapse
 
dhilipkmr profile image
Dhilip kumar

Hey Benjamin,

I am not sure why you're annoyed about the post๐Ÿ˜…๐Ÿ˜… but the implementation didn't actually call for handling all the edge cases, they were looking into how I was able to think through if I were to design its polyfill.

Thread Thread
 
benjamingr profile image
Benjamin Gruenbaum

To be clear - I am not annoyed about your post but about your experience. It just sounds way too hard for an hour interview :]

Collapse
 
uloco profile image
Umut TopuzoฤŸlu

Were you allowed to google stuff?

Collapse
 
dhilipkmr profile image
Dhilip kumar

In round 1 yes! But not in the other rounds!

Collapse
 
retronav profile image
Pranav Karawale

Could you please tell me about what to pursue as formal education because I am in 11th and I too want to pursue web development in the future. BTW I liked your article and experience :) !!

Collapse
 
dhilipkmr profile image
Dhilip kumar

Pursuing BE in Computer science and engineering gave me a better understanding about computer software, its internals and mainly data structures & algo. If you want to pursue formal education + web you could do the same! However there are people who are not even attending colleges and getting enough knowledge abt web through bootcamps and their own projects and are getting placed in MNCs.

Collapse
 
retronav profile image
Pranav Karawale

Thank you Dhilip!! I was in a big confusion about this but finally you helped me!! :)

Collapse
 
carefreeladka profile image
Pawan Kumar

`
function findRepeatingIndex(string) {
const map = {};
for (let i = 0; i < string.length; i++) {
const char = string[i];
if (!map[char]) {
map[char] = { startingIndex: i };
} else {
map[char].endIndex = i;
}
}
const result = [];
for (const [char, charIdx] of Object.entries(map)) {
const { startingIndex, endIndex } = charIdx;
if (endIndex > 0) {
result.push([startingIndex, endIndex]);
}
}

return result;
}

console.log(findRepeatingIndex("hellooooloo"));

const dictionary = {
hellolo: true,
};

function canBeFormed(input) {
if (input in dictionary) {
return true;
}
for (let i = 0; i < input.length; i++) {
if (input[i] === input[i + 1]) {
const newInput = input.slice(0, i) + input.slice(i + 1);
if (canBeFormed(newInput)) {
return true;
}
}
}
return false;
}

const input = "hellooooloo";
const op = canBeFormed(input);
console.log(op); // true

const dict = {
hi: true,
hello: true,
world: true,
};

function spaceSeparator(input) {
if (input === "") {
return "";
}
for (let i = 1; i <= input.length; i++) {
const word = input.slice(0, i);
if (word in dict) {
const rest = spaceSeparator(input.slice(i));
if (rest !== null) {
return word + " " + rest;
}
}
}
return null;
}

const str = spaceSeparator("helloworld"); // "hello world"
const str2 = spaceSeparator("helloworldhi"); // "hello world hi"
const str3 = spaceSeparator("helloworldh"); // ""
console.log(str);
console.log(str2);
console.log(str3);

const word = "example";
const threshold = 1000000000;
const windowSize = 3600; // 1 hour in seconds
const counts = new Array(windowSize).fill(0);
let totalCount = 0;

function processTweet(tweet) {
if (tweet.includes(word)) {
const timestamp = Math.floor(Date.now() / 1000); // current timestamp in seconds
const index = timestamp % windowSize; // index in the counts array
totalCount -= counts[index]; // subtract the count at the index from the total count
counts[index] = tweet.split(word).length - 1; // count the number of occurrences of the word in the tweet
totalCount += counts[index]; // add the new count to the total count
if (totalCount >= threshold) {
console.log(
Alert: ${word} repeated ${totalCount} times in the last hour
);
}
}
}

// Example usage:
processTweet("This is an example tweet");
processTweet("Another example tweet with the word example");

class LRUCache {
constructor(maxSize, expiryTime) {
this.maxSize = maxSize;
this.expiryTime = expiryTime;
this.cache = new Map();
this.head = null;
this.tail = null;
}

async get(key, fn) {
const entry = this.cache.get(key);
if (entry) {
if (Date.now() < entry.expiryTime) {
this.moveToHead(entry);
return entry.value;
} else {
this.removeEntry(entry);
}
}
const value = await fn();
const newEntry = { key, value, expiryTime: Date.now() + this.expiryTime };
this.cache.set(key, newEntry);
this.addToHead(newEntry);
if (this.cache.size > this.maxSize) {
const removedEntry = this.removeTail();
console.log(Cache burst: removed entry with key ${removedEntry.key});
}
return value;
}

addToHead(entry) {
entry.prev = null;
entry.next = this.head;
if (this.head) {
this.head.prev = entry;
} else {
this.tail = entry;
}
this.head = entry;
}

moveToHead(entry) {
if (entry === this.head) {
return;
}
if (entry === this.tail) {
this.tail = entry.prev;
this.tail.next = null;
} else {
entry.prev.next = entry.next;
entry.next.prev = entry.prev;
}
this.addToHead(entry);
}

removeEntry(entry) {
if (entry === this.head) {
this.head = entry.next;
} else if (entry === this.tail) {
this.tail = entry.prev;
this.tail.next = null;
} else {
entry.prev.next = entry.next;
entry.next.prev = entry.prev;
}
this.cache.delete(entry.key);
}

removeTail() {
const entry = this.tail;
this.tail = entry.prev;
if (this.tail) {
this.tail.next = null;
} else {
this.head = null;
}
this.cache.delete(entry.key);
return entry;
}
}

// Example usage:
const cache = new LRUCache(3, 10000); // max size of 3 entries, expiry time of 10 seconds
async function fetchData(key) {
console.log(Fetching data for key ${key});
return new Promise((resolve) =>
setTimeout(() => resolve(Data for key ${key}), 1000)
);
}
console.log(await cache.get("key1", () => fetchData("key1")));
console.log(await cache.get("key2", () => fetchData("key2")));
console.log(await cache.get("key3", () => fetchData("key3")));
console.log(await cache.get("key1", () => fetchData("key1"))); // should hit cache
console.log(await cache.get("key4", () => fetchData("key4"))); // should trigger cache burst
console.log(await cache.get("key2", () => fetchData("key2"))); // should hit cache

`

Answers for above quetions . Hope it helps someone

Collapse
 
vijayprwyd profile image
vijayprwyd

Thanks very much for sharing the questions . Just a doubt , Is round 4 Problem 2 a backtracking problem ? Can't we solve it with 2 loops ( one iterating each element of dictionary until a match is found and the inner one for comparing string and dictionary element ) and use 2 pointer here ? Are there any optimised solutions ?

Collapse
 
tracycss profile image
Jane Tracy ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿ’ป

All the best. You got this!!!!

Collapse
 
plxity profile image
Apoorv Taneja

Congratulations on your offer :)
Can you please tell how did you write polyfill for a promise? I tried implementing it but not able to succeed?

Collapse
 
dhilipkmr profile image
Dhilip kumar

Sure I'll check if I have a copy and ll share it across

Collapse
 
nguyenan1201 profile image
An Nguyen

Congrats on the offer. How many years does Software Engineer 2 requires? Is it 5 year?
I only have 2 years of industrial experience and all the questions are pretty overwhelming.

Collapse
 
jean182 profile image
Jean Aguilar

True I just have an interview coming and I'm pretty scared by looking at this post.

Collapse
 
vijayprwyd profile image
vijayprwyd

Sample Promise polyfill implementation
gist.github.com/vijayprwyd/b408541...

Collapse
 
lakbychance profile image
Lakshya Thakur

Brilliant article ๐Ÿ”ฅ. One query though. How much of the UI framework stuff they asked you about ?

Collapse
 
debjits1 profile image
Debjit Sinha

Can you provide any link or reference for the of the questions in round 2?

Promise based memoization with a given cache size behaving
as an LRU cache with an expiry time and auto cache burst

Collapse
 
imvetri profile image
Vetrivel

Congratulations! and Thanks for writing your experience.

My profile got shortlisted for a role,
I started to panic,
found your post, and the panic vanished.

Collapse
 
ashimasingla20 profile image
Ashima Singla

How did you approach this one ?
Consider you are getting millions of tweets per second,
you have to alert whenever a particular word is repeated
billion times in any 1 hour time frame (moving window)

Collapse
 
maalik profile image
Malik Bagwala

This is extremely motivating, keep up the good work. Which resource would you suggest for complex data structures and algorithms?