The Number of Positions Coding Question — Asked in Codeforces rated 1000.

Problem Statement :

Petr stands in line of n people, but he doesn’t know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.

Input Format:

The only line contains three integers n, a and b (0 ≤ a, b < n ≤ 100).

Output Format:

Print the single number — the number of the sought positions.

Given:

3 1 1

Output:

2

Explanation of Test case:

The possible positions in the example are: 2 and 3 (if we number the positions starting with 1).

Code:

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

--

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

FITEVO the first multiplayer #move2earn game (chapter 2)

Options and tools for finding the shortest route.

Developing an Intellij IDEA Plugin for a Custom Language— Tutorial 1-Setting up the environment

Using Caching to Speed up Your Python Code

5 Tricky SQL Queries Solved — Cooding Dessign

Microsoft Interview Experience: Senior Software Engineer

Conquering the Microservices Dependency Hell at Postman, with Postman — (Part 3)

Introduction to Springboot!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Placewit

Placewit

Upskilling students for tech placements!

More from Medium

Print Level Wise — Coding Question

7/4 leet code

The Zen of grinding LeetCode problems: Day 3 — Getting easier

LeetCode 21- Merge Two Sorted Lists