Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Site Message

Only Premium Users can view the Question

Question: CITI Bank, Recent Online Assessment (30th August 2023) | Child's Parent
0
Entering edit mode

ADD COMMENTlink 2.6 years ago PoGo 2.5k
1
Entering edit mode

can you pls post the other questions too

ADD COMMENTlink 2.6 years ago robert • 10
0
Entering edit mode

Problem description is confusing. I am not sure if I understood the problem correctly.

But here's my observation:

- F is always N because the child can run at speed 1 and cover every parent's steps

- So the problem scope is reduced to find maximum V2 to cover all parent's steps

- If X1 % V1 == X2 % V1 then the child can run at speed V1 and cover every parent's steps

- Otherwise, the child can run at speed gcd(V1, X1 %V1, X2 % V1) to cover every parent's steps

class Solution:
    def calculateVelocity(self, parentPos: int, childPos: int, velParent: int, steps: int) -> [int, int]:
        if parentPos % velParent == childPos % velParent:
            return [steps, velParent]
        return [steps, math.gcd(velParent, parentPos % velParent, childPos % velParent)]

Complexity is both O(1)

ADD COMMENTlink 2.6 years ago Bilal Yasin • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts