![]() |
There were 3 coding questions in 1-hour total time and it was conducted on code byte. All questions were on string based First Question: Program to find whether HTML tags are nested correctly or not — 10 marks (Easy) Have the function HTMLElements(str) read the str parameter being passed which will be a string of HTML DOM elements and plain text. The elements that will be used are: <b>, <I>, <em>, <div>, <p>. For example: if str is “<div><b><p>hello world</p></b></div>” then this string of DOM elements is nested correctly so your program should return the string true. If a string is not nested correctly, return the first element encountered where, if changed into a different element, would result in a Input: "<div><div><b></b></div></p>" Output: div Input: "<div>abc</div><p><em><i>test test test</b></em></p> Solution: I used stack data structure and re.split Python3
Second Question: String-Based problem. Python program to find the smallest substring or smallest window of a substring in a given string containing all characters of other string — (15 marks medium) The used window sliding algorithm is given in GFG only. GFG Link:- /archive/find-the-smallest-window-in-a-string-containing-all-characters-of-another-string/ Solution:- Python3
Third question: String Based problem. For me it was for the first time I have seen this question, It was hard too…… (25 marks) Hard. I don’t know what I got wrong but 3/8 test cases passed and time was over. Question: Have the function WildcardCharacters(str) read str which will contain two strings separated by a space. The first string will consist of the following sets of characters: +, *, $, and {N} which is optional. The plus (+) character represents a single alphabetic character, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many characters should appear in the sequence where N will be at least 1, $ represents any digit between 0-9. Your goal is to determine if the second string exactly matches the pattern of the first string in the input. For example: if str is “++*{5} gheeeee” then the second string in this case does match the pattern, so your program should return the string true. If the second string does not match the pattern your program should return the string false. The solution I wrote:- (Only 3 or 4 test cases passed out of a total of eight) So all of the solutions could not have been solved without the help of the internet. First Two questions I already practiced from GFG and Leetcode but the third question was out of the box so I took help. Any suggestions or critiques are warmly welcome. Awaiting the Results and will update you soon…Hasta La Vista!!!!!!!!! Python3
|
Reffered: https://www.geeksforgeeks.org
Interview Experiences |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |