Problem Analysis:

This problem is based on the simple nested if else statement.

Here N friends want to visit somewhere. Therefore, first they need to purchase N tickets and also they need to check whether at least N seats are available in the bus or not. If all the requirements are fulfilled then they can visit successfully.

It can be solved in two approaches.

  1. Using nested if else

First we need to check at least N tickets (N <= T)  are available or not using an if condition. If at least N tickets are available then further we need to check if at least N seats (N <= S) are available or not, If seats are available they can visit otherwise they can’t visit successfully. If N tickets are not available then we don’t need to check whether seats are available or not we can simply say that they can’t travel.

  1. Using AND operator in the if statement

We can parallelly check both of the conditions that at least N tickets and N seats are available or not by using an AND operator to connect the conditions ((N <= T) && (N <= S))

Special Thanks:

Md. Mehedi Hasan Naim

Statistics

92% Solution Ratio
tanvir4nEarliest, May '23
Soikot22Fastest, 0.0s
Hamza_2305101680Lightest, 4.9 MB
sarbajit.6155Shortest, 81B
Toph uses cookies. By continuing you agree to our Cookie Policy.