Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Finding Profession
Easy Accuracy: 60.91% Submissions: 645 Points: 2

Consider a special family of Engineers and Doctors with following rules :

1. Everybody has two children.
2. First child of an Engineer is an Engineer and second child is a Doctor.
3. First child of an Doctor is Doctor and second child is an Engineer.

We can represent the situation using below diagram:

                E
/        \
E          D
/   \       /  \
E     D     D    E
/ \   / \   / \   / \
E   D D   E  D  E  E  D


Given level and position(pos) of a person in above ancestor tree, find profession of the person.

Example 1:

Input: level = 4, pos = 2
Output: Doctor
Explaination: It is shown in the tree given
in question.

Example 2:

Input: level = 3, pos = 4
Output: Engineer
Explaination: Already given in the tree in
question.

You do not need to read input or print anything. Your task is to complete the function profession() which takes level and pos as input parameters and returns 'd' if it is a doctor. Otherwise return 'e'. The driver code will output Doctor for 'd' and Engineer for 'e' itself.

Expected Time Complexity: O(log(level))
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ level, pos ≤ 150