filmov
tv
Codeforces Bus of Characters - Interesting Coding Problem Solved Using Priority Queue

Показать описание
Codeforces Bus of Characters - Interesting Coding Problem Solved Using Priority Queue - Java Solution Discussed With Examples.
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 Description:
In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is wi centimeters. All integers wi are distinct.
Initially the bus is empty. On each of 2n stops one passenger enters the bus. There are two types of passengers:
an introvert always chooses a row where both seats are empty. Among these rows he chooses the one with the smallest seats width and takes one of the seats in it;
an extrovert always chooses a row where exactly one seat is occupied (by an introvert). Among these rows he chooses the one with the largest seats width and takes the vacant place in it.
You are given the seats width in each row and the order the passengers enter the bus. Determine which row each passenger will take.
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun
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 Description:
In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is wi centimeters. All integers wi are distinct.
Initially the bus is empty. On each of 2n stops one passenger enters the bus. There are two types of passengers:
an introvert always chooses a row where both seats are empty. Among these rows he chooses the one with the smallest seats width and takes one of the seats in it;
an extrovert always chooses a row where exactly one seat is occupied (by an introvert). Among these rows he chooses the one with the largest seats width and takes the vacant place in it.
You are given the seats width in each row and the order the passengers enter the bus. Determine which row each passenger will take.
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun
Комментарии