Report Node JS Developer Backend Brunoderenzisrubinetti26
Report Node JS Developer Backend Brunoderenzisrubinetti26
92.4 Bruno de Renzis PDF generated at: 27 May 2024 18:39:15 UTC
Score
92.4% • 152 / 165
scored in Node JS Developer (Backend) in 31 min 38 sec on 27 May 2024 13:05:39 -05
Candidate Information
Email [email protected]
Invited by Sandra
Coding patterns
1 question
Skill Distribution
Node.js
1 0%
Basic
JavaScript
2 50%
Basic
JavaScript
3 50%
Advanced
Problem Solving
4 100%
Basic
Tags Distribution
Medium 96% Javascript 0%
Questions
Time
Status No. Question Skill Score
Taken
1 min
APIs in Express JS 2 Node.js
2 27 0/5
Multiple Choice (Basic)
sec
3 min
JavaScript Function JavaScript +1
3 38 2.5/5
Multiple Choice (Basic)
sec
20
GET Requests for GIF Images min Problem
5 75/75
Approximate Solution 12 Solving (Basic)
sec
1. Express JS Incorrect
Question description
response.end([
{ name: "Alice", age: 25 },
{ name: "Bob", age: 30 },
]);
} else {
response.writeHead(404, { "Content-Type": "text/plain" });
response.end("Not found");
}
})
.listen(3000);
Interviewer guidelines
The code has a syntax error. The response.end method is called with an array as its argument, which will
cause a TypeError to be thrown because response.end expects a string or a buffer. To fix this error, the
array should be converted to a JSON string using JSON.stringify.
Candidate's Solution
The server responds with a JSON array that contains user data.
The server responds with a plain text message that contains the request data.
No comments.
Question description
setImmediate(() => {
a /= 2;
});
process.nextTick(() => {
a += 2;
});
console.log(a);
res.end("End");
});
Interviewer guidelines
The exact order in which these operations are executed is not guaranteed, and can change based on
various factors such as the state of the system, the availability of resources, and the behavior of the event
loop.
So, while the output of the code will always be a specific value, that value may not be the same each time
the code is executed, as it can be influenced by the conditions of the system at runtime.
Candidate's Solution
10
The output is not guaranteed to be a specific value as the execution order may vary.
The output throws an error because the execution order is not guaranteed.
No comments.
Question description
Have a look at the following code snippet and select the appropriate statement(s):
Candidate's Solution
No comments.
Question description
Given a list of strings comprised of a name and a Roman numeral, sort the list first by name, then by the
decimal value of the Roman numeral.
In Roman numerals, a value is not repeated more than three times. At that point, a smaller value
precedes a larger value to indicate subtraction. For example, the letter I represents the number 1, and
V represents 5. Reason through the formation of 1 to 10 below, and see how it is applied in the following
lines.
I, II, III, IV, V, VI, VII, VIII, IX, and X represent 1 through 10.
XX, XXX, XL, and L are 20, 30, 40, and 50.
For any other two-digit number < 50, concatenate the Roman numeral(s) that represent its multiples
of ten with the Roman numeral(s) for its values < 10. For example, 43 is 40 + 3 = 'XL' + 'III' = 'XLIII'
Example
names = ['Steven XL', 'Steven XVI', 'David IX', 'Mary XV', 'Mary XIII', 'Mary XX']
The result with Roman numerals is the expected return value. Written in decimal and sorted, they are
['David 9', 'Mary 13', 'Mary 15', 'Mary 20', 'Steven 16', 'Steven 40']. The return array is ['David IX', 'Mary
XIII', 'Mary XV', 'Mary XX', 'Steven XVI', 'Steven XL'].
Function Description
Complete the function sortRoman in the editor below.
Constraints
1 ≤ n ≤ 50
Each names[i] is a single string composed of 2 space-separated values: givenName and
romanNumeral.
romanNumeral represents a number between 1 and 50, inclusive.
1 ≤ |givenName| ≤ 20
Each givenName starts with an uppercase letter ascii[A-Z] which is followed by lowercase letters
ascii[a-z].
There is a space between givenName and romanNumeral
Each names[i] is distinct.
Input from stdin will be processed as follows and passed to the function.
The first line contains an integer n, the size of the array names.
Each of the next n lines contains an element names[i].
SAMPLE CASE 0
Sample Input
STDIN Function
----- -----
2 → names[] size n = 2
Louis IX → names = ['Louis IX', 'Louis VIII']
Louis VIII
Sample Output
Louis VIII
Louis IX
Explanation
Sort first by givenName then, if givenName is not unique, by the value of the Roman numeral. In
decimal, the list is sorted ['Louis 8', 'Louis 9'].
SAMPLE CASE 1
Sample Input
STDIN Function
----- -----
2 → names[] size n = 2
Philippe I → names = ['Philippe I', 'Philip II']
Philip II
Sample Output
Philip II
Philippe I
1 'use strict';
2
3 import { WriteStream, createWriteStream } from "fs";
4 process.stdin.resume();
5 process.stdin.setEncoding('utf-8');
6
7 let inputString: string = '';
8 let inputLines: string[] = [];
9 let currentLine: number = 0;
10
11 process.stdin.on('data', function(inputStdin: string): void {
12 inputString += inputStdin;
13 });
14
15 process.stdin.on('end', function(): void {
16 inputLines = inputString.split('\n');
17 inputString = '';
18
19 main();
20 });
21
67 }
68
69 function main() {
70 const ws: WriteStream = createWriteStream(process.env['OUTPUT_PATH']);
71
72 const namesCount: number = parseInt(readLine().trim(), 10);
73
74 let names: string[] = [];
75
76 for (let i: number = 0; i < namesCount; i++) {
77 const namesItem: string = readLine();
78 names.push(namesItem);
79 }
80
81 const result: string[] = sortRoman(names);
82
83 ws.write(result.join('\n') + '\n');
84
85 ws.end();
86 }
87
TIME MEMORY
TESTCASE DIFFICULTY TYPE STATUS SCORE
TAKEN USED
Testcase
Easy Sample Success 1 0.0392 sec 42 KB
0
Testcase
Easy Sample Success 1 0.0432 sec 41.9 KB
1
Testcase
Easy Sample Success 1 0.0331 sec 42 KB
2
Testcase
Easy Sample Success 6 0.0351 sec 42.1 KB
3
Testcase
Easy Hidden Success 11 0.04 sec 42 KB
5
Testcase
Easy Hidden Success 11 0.0401 sec 42.1 KB
6
Testcase
Easy Hidden Success 11 0.0384 sec 41.9 KB
7
Testcase
Easy Hidden Success 11 0.0376 sec 42 KB
8
Testcase
Easy Hidden Success 11 0.0366 sec 42 KB
9
No comments.
Back-End Development
Question description
You are given a log file with a list of responses, some of the records in the log file may contain filenames.
Generate a new file containing the unique names of all gif files that were requested via GET and that had
a response code of 200.
A sample and the structure of the text file containing the responses are given below.
"GET
[01/Jul/1995:00:00:12
burger.letters.com
- - /shuttle/countdown/video/livevideo.GIF 200 0
-0400]
HTTP/1.0"
Hostname of
The HTTP
the host that
- - Timestamp Format The request is enclosed in quotes response
made the
code.
request
Given a filename that denotes a text file in the current working directory. Create an output file with the
name "gifs_" prefixed to the filename (gifs_filename) which stores the unique gif filenames that match
the requirements.
Write the name of a GIF file (without its path) to the output file, for each of the records in the input file
which satisfy the below:
The GIF file was requested by a GET request.
The record has an HTTP response code of 200.
Note:
The output file has to be written to the current directory.
The line order in the output file does not matter.
There must not be any duplicates (if duplicates exist, you will receive only 70% of the score).
Constraints
The log file contains no more than 2 × 105 records.
Input from stdin will be processed as follows and passed to the function.
The only line contains a string filename, the name of the log file.
SAMPLE CASE 0
Sample Input 0
hosts_access_log_00.txt
Sample Output 0
Given filename = "hosts_access_log_00.txt", process the records in hosts_access_log_00.txt and create
an output file named gifs_hosts_access_log_00.txt that contains the following rows:
livevideo.GIF
count.gif
NASA-logosmall.gif
KSC-logosmall.gif
Explanation 0
The log file hosts_access_log_00.txt contains the following log records:
0
d104.aa.net - - [01/Jul/1995:00:00:15 -0400] "GET /images/NASA-logosmall.gif HTTP/1.0" 200 786
A GET request requested a file named livevide.GIF and the HTTP response code was 200.
2. The sixth log record:
In both records, a GET request requested a file named count.gif and the HTTP response code was
200.
3. The seventh log record:
A GET request requested a file named NASA-logosmall.gif and the HTTP response code was 200.
4. The eighth log record:
A GET request requested a file named KSC-logosmall.gif and the HTTP response code was 200.
Append the four distinct GIF file names satisfying our conditions to the output file.
1 process.stdin.resume();
2 process.stdin.setEncoding('ascii');
3
4 let consoleInput = '';
5 process.stdin.on('data', (data) => {
6 consoleInput += data;
7 });
8
9 process.stdin.on('end', () => {
10 consoleInput = consoleInput.split('\n');
11 main();
12 });
13
14 let currentLine = 0;
15 function readLine() {
16 if (currentLine >= consoleInput.length) {
17 return null;
18 }
19
20 return consoleInput[currentLine++];
21 }
22
23
24
25 const fs = require('fs');
26 const readline = require('readline');
27 function main() {
28 const filename = readLine();
29 const outputFilename = `gifs_${filename}`;
30
31 const rl = readline.createInterface({
32 input: fs.createReadStream(filename),
33 output: process.stdout,
34 terminal: false
35 });
36
37 const gifSet = new Set();
38
39 rl.on('line', (line) => {
40 const regex = /GET\s+(\/[^\s]*\/[^\s]*\.gif)\s+HTTP\/1\.0"\s+200/i;
41 const match = line.match(regex);
42 if (match) {
43 const gifPath = match[1];
44 const gifName = gifPath.split('/').pop();
45 gifSet.add(gifName);
46 }
47 });
48
49 rl.on('close', () => {
50 const gifArray = Array.from(gifSet);
51 fs.writeFileSync(outputFilename, gifArray.join('\n') + '\n');
52 });
53 }
54
55
TIME MEMORY
TESTCASE DIFFICULTY TYPE STATUS SCORE
TAKEN USED
TestCase
Easy Hidden Success 3/3 0.1393 sec 66.4 KB
10
TestCase
Easy Hidden Success 3/3 0.1502 sec 67.4 KB
11
TestCase
Easy Hidden Success 3/3 0.2163 sec 68.5 KB
12
TestCase
Easy Hidden Success 3/3 0.2256 sec 68.7 KB
13
No comments.