Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,346 members, 7,812,000 topics. Date: Monday, 29 April 2024 at 05:51 AM

See The Question I Was Asked During An Online Interview - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / See The Question I Was Asked During An Online Interview (2082 Views)

I Asked Chatgpt To Write A Poem About Nairaland. Here's The Output / with how Much Can I create An Online Retail Website And APP? / Then I For Some Reason Didn't Reach The Question. (2) (3) (4)

(1) (2) (Reply) (Go Down)

See The Question I Was Asked During An Online Interview by Peterpan007(m): 10:35am On Oct 16, 2022
See the question I was asked

Re: See The Question I Was Asked During An Online Interview by RepoMan007: 11:13am On Oct 16, 2022
You came to tell us instead of trying. Did the interviewer disable your PrintScreen button?

1 Like

Re: See The Question I Was Asked During An Online Interview by Fourpockets: 11:49am On Oct 16, 2022
Peterpan007:
See the question I was asked
Is it a foriegn remote job interview
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 12:48pm On Oct 16, 2022
RepoMan007:
You came to tell us instead of trying. Did the interviewer disable your PrintScreen button?


Nope!!!!

I actually did but I want to see if I was on point or I missed it
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 12:49pm On Oct 16, 2022
Fourpockets:

Is it a foriegn remote job interview

Nope a Nigerian tech company...
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 1:10pm On Oct 16, 2022
Use a hash map and your key should be the opening values of the given HTML tags. The values should be it's coresponding closing tag. Split string and loop through and if opening tag and closing tag of each element is found return true else false

1 Like

Re: See The Question I Was Asked During An Online Interview by Nobody: 1:29pm On Oct 16, 2022
tensazangetsu20:
Use a hash map and your key should be the opening values of the given HTML tags. The values should be it's coresponding closing tag. Split string and loop through and if opening tag and closing tag of each element is found return true else false
split it by what?

1 Like

Re: See The Question I Was Asked During An Online Interview by Nobody: 1:33pm On Oct 16, 2022
My approach would probably be to use substrings?

get first index of ">" to get the end of an opening tag, then get last index of "<" to get the start of the last closing tag. cut the string and compare the tags

repeat till there is no "<>"


Seems oddly inefficient though
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 1:36pm On Oct 16, 2022
DrLevi:

split it by what?

You can split the string normally so it's an array when you loop through it. I also forget you need to keep a visited array that will either return true or false if we find all keys or not. If theres ever a false in the array return false if it's all true return true.

1 Like

Re: See The Question I Was Asked During An Online Interview by Fourpockets: 1:50pm On Oct 16, 2022
Peterpan007:


Nope a Nigerian tech company...
Ok
Hint, split the string into an array so it'll be easier to work on
Re: See The Question I Was Asked During An Online Interview by islamics(m): 3:33pm On Oct 16, 2022
@tensa Is it possible to split a string without a delimeter? I think that is what @DrLevi means by asking "split by what?".

@Op Flexisaf is showing in your browser oooo; is this for Flexisaf?

My idea of solving never balance for head. I am thinking of stack stuff. Like the common bracket problem.
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 4:35pm On Oct 16, 2022
Op I hope you didn't switch tabs when taking this test. We use coderbyte at the company I work for and I volunteered to take our recruitment test to gauge how fair it is to applicants and it practically takes a video of your screen. It also notifies how many times you leave the tab and if you copy or paste when you switch tabs it flags your answers for plagiarism which leads to an automatic rejection.

10 Likes

Re: See The Question I Was Asked During An Online Interview by faruqa97: 4:42pm On Oct 16, 2022
Why would you be given 5 minutes for this question or am I seeing something else, anyway, you split the string by byte, since this is an HTML question, you can assume UTF-8 encoding, you don't have to split everything at once and then store in memory, you can do it byte by byte and switch the state machine depending on the character emitted, more like tokenization.

Here is the thing, this question, requires the knowledge of state machine and a basic understanding of HTML spec or the algorithm it uses in closing unclosed tags (I don't even think you need it self), it's a simple algorithm, you can use stack for it.

Let me give you a quick way I'll solve this, whenever you encounter an opening tag (e.g <div>, you push it in the stack of open tags, when you encounter it's closing partner (e.g </div>), you loop the opening tag stack backwards until you match it's opening tag, and as such, you close it.

I didn't see the last section of that question but it seems it is saying, you should return the tag that wasn't closed, you can either record the tags that wasn't closed while you were pushing to the opening tag stack, or loop the opening tag stack until you found one that isn't closed, then return it.

1 Like

Re: See The Question I Was Asked During An Online Interview by LikeAking: 4:53pm On Oct 16, 2022
Nice!

It's a leetcode questions in disguise..

Using a simple hash map will do the trick..

1 Like

Re: See The Question I Was Asked During An Online Interview by Hannania(m): 5:25pm On Oct 16, 2022
Peterpan007:
See the question I was asked
Valid Parentheses come to mind right now smiley

1 Like

Re: See The Question I Was Asked During An Online Interview by namikaze: 7:37pm On Oct 16, 2022
Peterpan007:
See the question I was asked
This is valid parentheses in disguise, simplifying the input should work, something like:

import re

def solve(s):
html_elems = set("b i div em p".split())
tokens = re.sub("[<>]"," ", s).split()
stack = []
for token in tokens:
if token in html_elems:
stack.append(token)
elif token[1:] in html_elems:
if stack == []:
return token
elif stack[-1] != token[1:]:
return token[1:]
else:
stack.pop()
return stack[0] if stack != [] else True

1 Like

Re: See The Question I Was Asked During An Online Interview by namikaze: 7:39pm On Oct 16, 2022
Hannania:
Valid Parentheses come to mind right now smiley
exactly

1 Like

Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 7:53pm On Oct 16, 2022
islamics:
@tensa Is it possible to split a string without a delimeter? I think that is what @DrLevi means by asking "split by what?".

@Op Flexisaf is showing in your browser oooo; is this for Flexisaf?

My idea of solving never balance for head. I am thinking of stack stuff. Like the common bracket problem.


Yes it for flexisaf
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 7:54pm On Oct 16, 2022
tensazangetsu20:
Op I hope you didn't switch tabs when taking this test. We use coderbyte at the company I work for and I volunteered to take our recruitment test to gauge how fair it is to applicants and it practically takes a video of your screen. It also notifies how many times you leave the tab and if you copy or paste when you switch tabs it flags your answers for plagiarism which leads to an automatic rejection.


I didn't switch tabs...
I did the obj section and this was the second part.
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 7:58pm On Oct 16, 2022
Thanks guys for the comments. It means a lot at least I've learnt something.
I tried to solving it but I didn't go far, I'm sure I did well in the obj section but not to sure of this particular question..

I'm hoping for the best from the interview.
Thanks guys smiley
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 7:59pm On Oct 16, 2022
namikaze:

This is valid parentheses in disguise, simplifying the input should work, something like:

import re

def solve(s):
html_elems = set("b i div em p".split())
tokens = re.sub("[<>]"," ", s).split()
stack = []
for token in tokens:
if token in html_elems:
stack.append(token)
elif token[1:] in html_elems:
if stack == []:
return token
elif stack[-1] != token[1:]:
return token[1:]
else:
stack.pop()
return stack == []


Omo!!!!!
Re: See The Question I Was Asked During An Online Interview by emmyN(m): 8:02pm On Oct 16, 2022
tensazangetsu20:
Op I hope you didn't switch tabs when taking this test. We use coderbyte at the company I work for and I volunteered to take our recruitment test to gauge how fair it is to applicants and it practically takes a video of your screen. It also notifies how many times you leave the tab and if you copy or paste when you switch tabs it flags your answers for plagiarism which leads to an automatic rejection.

I took a coderbyte test on Friday and used the built in browser feature to look up some MDN documentation stuff. But when I clicked on the search result, it opened in a new tab. Could this be grounds for disqualification too?
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 8:07pm On Oct 16, 2022
Peterpan007:



I didn't switch tabs...
I did the obj section and this was the second part.

const openingTags = str.match(/<\w+>/g)
const closingTags = str.match(/(<\/\w+>wink/g);

const strObj = {
'<div>': '</div>',
'<p>': '</p>',
'<i>': '</i>',
'<p>': '</p>',
'<em>': '</em>',
'<b>': '</b>',
};

// there might not be the same number of opening and closing tags
const max = Math.max(openingTags.length, closingTags.length);

for (let i = 0; i < max; i++) {
if (strObj[openingTags[i]] !== closingTags[closingTags.length - 1] && strObj[openingTags[i]] !== closingTags[0]) {
return (openingTags[i]).replace(/<|>/g, '');
}
closingTags.splice(closingTags.indexOf(strObj[openingTags[i]]),1);
}

return "true";

The question has even been solved online

https://stackoverflow.com/questions/62462345/how-to-check-if-dom-elements-are-correctly-nested

2 Likes

Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 8:08pm On Oct 16, 2022
emmyN:


I took a coderbyte test on Friday and used the built in browser feature to look up some MDN documentation stuff. But when I clicked on the search result, it opened in a new tab. Could this be grounds for disqualification too?

Yes it actually also checks when you look up things online through their in search engine and tells your employer what exactly you searched for. Please next time when taking another coding assessment. Use another laptop or tablet or mobile device if you intend to search anything.
Re: See The Question I Was Asked During An Online Interview by emmyN(m): 8:13pm On Oct 16, 2022
tensazangetsu20:


Yes it actually also checks when you look up things online through their in search engine and tells your employer what exactly you searched for. Please next time when taking another coding assessment. Use another laptop or tablet or mobile device if you intend to search anything.

Okay. Was actually surprised when it opened in a new tab. I think it was a glitch in the system, because the second time I did a search, it used the in-built browser to return the MDN result.
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 8:16pm On Oct 16, 2022
emmyN:


Okay. Was actually surprised when it opened in a new tab. I think it was a glitch in the system, because the second time I did a search, it used the in-built browser to return the MDN result.

LoL don't mind them it's a trap.
Re: See The Question I Was Asked During An Online Interview by SeaTrade(m): 8:22pm On Oct 16, 2022
tensazangetsu20:


Yes it actually also checks when you look up things online through their in search engine and tells your employer what exactly you searched for. Please next time when taking another coding assessment. Use another laptop or tablet or mobile device if you intend to search anything.
Hi bro.
Quick one.
Please how possible is it to recover data from a dead android phone in Nigeria?
I know it's possible cos I've done some research on it and it says it can be recovered using softwares.
So I'm wondering If we have capable hands that can do that here as most of these phone guys are just so analogue.
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 8:33pm On Oct 16, 2022
SeaTrade:
Hi bro.
Quick one.
Please how possible is it to recover data from a dead android phone in Nigeria?
I know it's possible cos I've done some research on it and it says it can be recovered using softwares.
So I'm wondering If we have capable hands that can do that here as most of these phone guys are just so analogue.
Yeah it's possible but then dependent on the level of damage to the phone. The phone still has to come on to be able to access the data through a software. If you are in lagos there's lots of people that will easily do this in computer village
Re: See The Question I Was Asked During An Online Interview by SeaTrade(m): 8:36pm On Oct 16, 2022
tensazangetsu20:

Yeah it's possible but then dependent on the level of damage to the phone. The phone still has to come on to be able to access the data through a software. If you are in lagos there's lots of people that will easily do this in computer village
Yes it comes on very well,just the display that's bad as the screen remains black throughout, even after changing screen.
Okay thank you so much for the information.
Re: See The Question I Was Asked During An Online Interview by AlchemyOfCodes: 9:22pm On Oct 16, 2022
Omo grin questions dey Sha. Make I kukuma take my leave o
Re: See The Question I Was Asked During An Online Interview by Peterpan007(m): 9:44pm On Oct 16, 2022
tensazangetsu20:


const openingTags = str.match(/<\w+>/g)
const closingTags = str.match(/(<\/\w+>wink/g);

const strObj = {
'<div>': '</div>',
'<p>': '</p>',
'<i>': '</i>',
'<p>': '</p>',
'<em>': '</em>',
'<b>': '</b>',
};

// there might not be the same number of opening and closing tags
const max = Math.max(openingTags.length, closingTags.length);

for (let i = 0; i < max; i++) {
if (strObj[openingTags[i]] !== closingTags[closingTags.length - 1] && strObj[openingTags[i]] !== closingTags[0]) {
return (openingTags[i]).replace(/<|>/g, '');
}
closingTags.splice(closingTags.indexOf(strObj[openingTags[i]]),1);
}

return "true";

The question has even been solved online

https://stackoverflow.com/questions/62462345/how-to-check-if-dom-elements-are-correctly-nested

See question for internship role oo not junior dev yet oo.. Wawu
Re: See The Question I Was Asked During An Online Interview by tensazangetsu20(m): 9:53pm On Oct 16, 2022
Peterpan007:






See question for internship role oo not junior dev yet oo.. Wawu


How much is the salary of the job?

(1) (2) (Reply)

Which One Do U Use For Internet Browsing Zoom,multilinks,starcom,mtn? / I Need Help On Waec Offline Installation / Programming School/training Firm For A Young Graduate In Lagos/lekki-ajah Axis

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 58
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.