Codeforces Circle Metro - Finding If 2 Trains Will Be At A Station At Same Time Logic Explained
Codeforces Circle Metro - Finding If 2 Trains Will Be At A Station At Same Time Logic Explained.
If you find this video helpful, please 'Like' & 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.
Problem Link : https://codeforces.com/problemset/problem/1169/A
Problem Description:
The circle line of the Roflanpolis subway has n
n
stations.
There are two parallel routes in the subway. The first one visits stations in order 1→2→…→n→1→2→…
1→2→…→n→1→2→…
All trains depart their stations simultaneously, and it takes exactly 1
1
minute to arrive at the next station.
Two toads live in this city, their names are Daniel and Vlad.
Daniel is currently in a train of the first route at station a
a
and will exit the subway when his train reaches station x
x
.
Coincidentally, Vlad is currently in a train of the second route at station b
b
and he will exit the subway when his train reaches station y
y
.
Surprisingly, all numbers a,x,b,y
a,x,b,y
are distinct.
Toad Ilya asks you to check if Daniel and Vlad will ever be at the same station at the same time during their journey. In other words, check if there is a moment when their trains stop at the same station. Note that this includes the moments when Daniel or Vlad enter or leave the subway.
Youtube channel: https://www.youtube.com/channel/UCrvpRH4lSRjp2T6btl0lf4w
https://github.com/maksrane100/codeforces_solutions
https://github.com/maksrane100/leetcode_solutions
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun #leetcode #codeforces #algorithm #algorithms #datastructure #datastructuresandalgorithms
Видео Codeforces Circle Metro - Finding If 2 Trains Will Be At A Station At Same Time Logic Explained автора Love-infused Cuisine
Видео Codeforces Circle Metro - Finding If 2 Trains Will Be At A Station At Same Time Logic Explained автора Love-infused Cuisine
Информация
9 января 2025 г. 22:36:23
00:14:10
Похожие видео