Ho presentato la mia candidatura online. La procedura ha richiesto 2 settimane. Ho sostenuto un colloquio presso Crossover for Work nel mese di giu 2024
Colloquio
1)Basic fit 2) Cognitive Aptitude 3) Complex Problem-solving 4) AI Augmented Defect Resolution 5) AI Augmented Feature Development 6) Interview
Interviewer was rude, since he knows only JAVA, he expects me to know everything that he knows
You are working on a backend system that retrieves data from a database. The database has two tables: users and posts. Each user can have many posts, and each post belongs to a user.
You are notified that the system is experiencing a performance drop in production, and you isolate the issue to the following snippet:
async function getUsersWithPostCountAndEarliestPostDate() {
const users = await db.query('SELECT u.id AS user_id, u.name AS user_name FROM users');
for (let user of users) {
const posts = await db.query('SELECT * FROM posts WHERE user_id = ?', [user.id]);
user.post_count = posts.length;
user.earliest_post_date = posts.reduce((earliest, post) => post.created_at < earliest ? post.created_at : earliest, Infinity);
if (user.earliest_post_date === Infinity) {
user.earliest_post_date = null;
}
}
return users;
}
What type of problem does this code have? How do we fix it?
Ho presentato la mia candidatura online. La procedura ha richiesto 2 settimane. Ho sostenuto un colloquio presso Crossover for Work (Campo Grande, ) nel mese di ott 2024
Colloquio
Applicants must achieve a high IQ test score. After initial code tests and interviews, a proctored IQ test is repeated. These tests measure only test-solving ability, and their validity is controversial. Talented individuals with anxiety may perform poorly, for instance.
Domande di colloquio [1]
Domanda 1
Submit this JS code to ChatGPT, asking for it to explain and solve the performance issues.