Codenation / Trilogy Innovations Test Experience April 2022 Online
Question Details
Problem 1Dr. Betra has become bored with his research on human hair. So he decided to breed pigeons.He bought N pigeons from the shop. The shopkeeper advised him to make s...
Full Details
Problem 1 Dr. Betra has become bored with his research on human hair. So he decided to breed pigeons. He bought N pigeons from the shop. The shopkeeper advised him to make sure that the pigeons were not facing each other at any point in time. Dr. Betra forgot about this and placed the pigeons in a row to feed them, tell Dr. Betra the minimum number of pigeons should he pick up and switch the direction towards which it is facing. L denotes a pigeon at ith index is facing a pigeon at (i - 1)th index, while R denotes a pigeon at ith index is facing a pigeon at (i + 1)th index.
Constraints 1 <= N <= 10 5 Input Format The first argument is a string A denoting the direction each pigeon is facing.
Output Format Returns a single integer denoting the minimum number of pigeons direction must Dr. Betra switch.
Example Input Input 1: A = LLLLLL Input 2: A = RLLLLL Example Output Output 1: 0 Output 2: 1 Example Explanation Explanation 1: All the pigeons are facing left. So the configuration is already good.
Explanation 2: We only need to switch the direction of the first pigeon to make sure no two pigeons are facing each other. Problem 2 Carl and Bernhard were trying to solve a problem, but they were stuck on graph theory this time. The problem is as follows: Given a tree A nodes given in the form of a 2D array B, where each row consists of two integers denoting the presence of an edge between the two integers. Also, given another 2D array C of Q queries, each row consists of 3 integers -U, V, and W. Find out the closest node to W on the path from U to V, where a path between the two nodes means a subtree in the form of a line graph with the two nodes as endpoints. Process each query and return an array denoting the answer to each query.
Constraints 2 <= A <= 10 5 1 <= Q <= 10 5 1 <= B[i][0], B[i][1] <= N (B[i][0] != B[i][1]) |B| = A - 1 1 <= U, V, W <= N (U != V)
Input Format The first argument is the integer A, denoting the number of nodes in the tree. The second argument is the 2D array B, denoting the edge of the tree. The third argument is the 2D integer array C, denoting the queries.
Output Format Returns an integer array denoting the answers to each query.
Example Input Input 1: A = 6 B = [ [1, 2], [1, 3], [1, 4], [3, 5], [3, 6]] C = [ [2, 5, 6], [5, 2, 6]]
Input 2: A = 6 B = [ [1, 2], [1, 3], [1, 4], [3, 5], [3, 6]] C = [ [2, 5, 1], [2, 5, 4]]
Example Output Output 1: [3, 3]
Output 2: [1, 1]
Example Explanation Explanation 1: The given tree is: 1 / | \ 4 3 2 / \ 5 6 The order of the U and V does not matter. So nodes 5, 3, 2, 1, and 2 lie in the required path. Node 3 is closest to 6. Problem 3 You are given an array B of positive integers of size 2xA. There are A rounds in total. In each round, you have to choose any two integers from the array and delete them. Your score in each round will be GCD(nums1, nums2) * round-number where num1 and num2 are the numbers you have chosen and round-number is the current round. Your total score will be the summation of the score that you have obtained in every round. Task: Determine the maximum total score The round-number starts from 1 and GCD(x, y) denotes the greatest common divisor of x and y.
Constraints 1 <= A <= 10 1 <= B[i] <= 10 9 Input format The first argument is integer A which denotes the number of rounds. The second argument is an array of integers B of 2xA size.
Output format Return the maximum score which you can obtain from the given array.
Example Input Input 1: A = 2 B = [3, 4, 9, 5]
Input 2: A = 3 B = [8, 5, 6, 25, 6, 16]
Example output:
Output 1: 7 Output 2: 41 Example explanation Explanation 1: The rounds can be placed as shown below: Round_number 1: Select num1 = 4 , num2 = 5. So the value of gcd(4, 5) * round_number equal to 1 * 1 = 1. Round_number 2: Select num1 = 3, num2 = 9. So the value of gcd(3, 9) * round_number equals to 3 * 2 = 6. Therefore the maximum total score equals = 1 + 6 = 7.
Explanation 2: The rounds can be placed as shown below: Round_number 1: Select num1 = 5 , num2 = 25. So the value of gcd(5, 25) * round_nuumber equal to 5 * 1 = 5. Round_number 2: Select num1 = 6, num2 = 36. So the value of gcd(6, 6) * round_number equals to 6 * 2 = 12. Round_number 3: Select num1 = 8 and num2 = 16 so the value of gcd(8,1 6) * round_number equals to 8 * 3 = 24. Therefore the maximum total score equals = 5 + 12 + 24 = 41.
About This Question
This is a reported interview question from a codenation interview for a swe role reported in 2024.
It covers the following topics: Trees, Strings, Sql, Graph, Math, Graphs, Arrays, Matrix .
More Codenation Interview Questions
About Codenation Interview Reports
This question was reported by a candidate who interviewed at Codenation. LeakCode aggregates interview reports from 10+ sources, including 1Point3Acres, Glassdoor, LeetCode Discuss, Blind, Reddit, Indeed, and Nowcoder. Each report is translated where necessary, deduplicated against existing entries, and tagged by company, role, round type, and reporting date.
Use this question as one calibration data point, not a memorization target. Companies typically rotate their question pools every 2-4 months; the exact wording of a 2024 question may differ from what you encounter today. The underlying pattern, difficulty level, and follow-up depth at Codenation are the higher-signal extractions to take from this report.
For broader preparation context, the Codenation interview process typically includes a recruiter screen, one or two technical phone screens, and a 4-5 round on-site loop covering coding, system design (at L4+ levels), and behavioral. Reports tagged on LeakCode show the round-by-round distribution and typical difficulty calibration. To browse questions filtered by round type and seniority, use the company hub linked above.
How To Practice This Type of Question
Solve similar problems on LeetCode under timed conditions (25-35 minutes per medium difficulty). The goal is pattern recognition: recognize the underlying technique (sliding window, two-pointer, BFS, memoized recursion, etc.) within 60-90 seconds of reading. Strong candidates verbalize their hypothesis out loud before coding, then iterate based on feedback. Weak candidates dive into implementation immediately, lose time on the wrong approach, and run out of time for follow-ups.
Companies update their question pools every 2-4 months. The exact wording of any given question may have been retired by the time you interview. Focus your prep on the pattern, not the specific problem. The patterns that appear in Codenation reports consistently are the ones worth investing in; one-off niche problems are not.
During Your Codenation Round
Apply the standard interview round template: clarify requirements (2-3 minutes), state your approach out loud and confirm direction with the interviewer (3-5 minutes), code with narration (15-25 minutes), test with concrete examples including edge cases (5 minutes), discuss optimization or trade-offs if time permits (5 minutes). This template is universally accepted across FAANG and adjacent companies; deviating from it produces weaker interviewer feedback signal.
The single most predictive failure mode in Codenation reports tagged "no hire": not asking clarifying questions. Interviewers are explicitly trained to weight this. Strong candidates ask 3-5 clarifying questions even on problems that look obvious; weak candidates dive into code immediately. The clarifying-question check is often the first signal recorded in the interviewer's written notes.