Questions d'entretien

Entretien pour Frontend Engineer

-

Meta

Round 1: Given a string and a style array render HTML pretty much like a rich text editor. For example: 'Hello, world', [[0, 2, 'i'], [4, 9, 'b'], [7, 10, 'u']] Output: '<i>Hel</i>l<b>o, w<u>orl</u></b><u>d</u> something like that.

Répondre

Réponses aux questions d'entretien

3 réponse(s)

1

I used a hash map and a stack to store the indices. I pushed the style into a stack and popped off when I hit the index. I had to write the output so I took care of not having invalid HTML having the <b> and <u> mixed up. This particular use case I had to take care. The interviewer gave me some hints around the hash map but I came up with the algorithm and implemented almost through the complete hour.</u></b>

Utilisateur anonyme le

0

You can answer it as an algorithm question. Or you can answer it like a true FEE by leveraging the platform. 1. Flatten the tags into a single array of open and close tag pairs. 2. Sort the flattened tags by injection index. 3. Insert tags in reverse order to preserve shifting index. 4. Join the string and pass it to innerHTML and let the browser handle the rest

Utilisateur anonyme le

0

Hey! I am trying to solve this problem. Can you give me some direction?

Utilisateur anonyme le

Ajouter des réponses ou des commentaires

Pour commenter ceci, connectez-vous ou inscrivez-vous.