Round 1
Questions:
-
Triangle and Points
You are given the coordinates of a triangle with three vertices:- (x₁, y₁)
- (x₂, y₂)
- (x₃, y₃)
Additionally, you are provided the coordinates of two points:
- Point p: (xₐ, yₐ)
- Point q: (xq, yq)
Your task is to determine the following:
Output:
- Print
1
if the triangle cannot be formed. - Print
2
if both p and q lie inside the triangle. - Print
3
if only point p lies within the triangle. - Print
4
if only point q lies within the triangle. - Print
5
if neither point lies inside the triangle.
Input Format:
- Coordinates of the triangle vertices:
x₁, y₁, x₂, y₂, x₃, y₃
- Coordinates of the points p and q:
p(xₐ, yₐ), q(xq, yq)
Example:
Input: Triangle: (0, 0), (5, 0), (0, 5) Point p: (1, 1) Point q: (6, 6) Output: 3 # Only point p lies inside the triangle.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 2
Questions:
2. Array Operations
You are given an array of n
elements and two variables, x
and y
.
In each operation, you can:
- Subtract
x
from one element of the array. - Subtract
y
from the remaining elements.
Your task is to find the minimum number of operations required to make every element of the array ≤ 0.
Input Format:
- The first line contains an integer
n
, the number of elements in the array. - The second line contains
n
space-separated integers representing the array. - The third line contains two integers,
x
andy
, wherex > y
.
Output:
Print the minimum number of operations to make each element ≤ 0.
Example:
Input: 5 10 20 30 40 50 5 2 Output: 13
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 3
Questions:
3. Roman Numerals in Strings
You are given a string that contains a name followed by Roman numerals.
Your task is to return a vector of strings that stores:
- The string name.
- The numerical value of the Roman numeral (converted to integer).
The names should be in ascending order, and if the names are the same, the numbers should also be sorted in ascending order.
Input Format:
- A list of strings where each string is in the format:
name RomanNumeral
.
Output:
Return a vector of strings, sorted by name and numeral value.
Notes:
- The Roman numeral, when converted to a number, is at most two digits.
Example:
Input: John IX Mary XV John VIII Mary IX Output: ["John 8", "John 9", "Mary 9", "Mary 15"]
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.