Тёмный

CSES - Collecting Numbers explained and solved completely in HINDI 

Deepak Joshi
Подписаться 358
Просмотров 1,4 тыс.
50% 1

Question Link : cses.fi/proble...
You are given an array that contains each number between 1…n exactly once. Your task is to collect the numbers from 1 to n in increasing order.
On each round, you go through the array from left to right and collect as many numbers as possible. What will be the total number of rounds?
Input
The first line has an integer n: the array size.
The next line has n integers x1,x2,…,xn: the numbers in the array.
Output
Print one integer: the number of rounds.
Constraints
1≤n≤2⋅105
Example
Input:
5
4 2 1 5 3
Output:
3

Опубликовано:

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 2   
@piyushsingh9320
@piyushsingh9320 Год назад
hello bhai , please provide intution on how to think/approach to a problem. The people who are searching for solutions of problems don't want code ,we want the thought process of how to approach a problem. No hate ,just a suggestion.
@deepak_joshi_the_conqurer_
@deepak_joshi_the_conqurer_ Год назад
Hello Piyush!! I am sorry to hear that , for this particular question the intuition that I generated here is to maintain a Visited array that we commonly use in graph problems).
Далее
[CSES][Sorting and Searching] Traffic Lights
17:45
Просмотров 6 тыс.
Barno
00:22
Просмотров 658 тыс.
Meni yerga urdingda
00:20
Просмотров 487 тыс.
[CSES][Sorting and Searching] Collecting Numbers II
18:16
Intro to CSS (Basic Selector Usage)
31:00
[CSES][Sorting and Searching]  Missing Coin Sum
19:57
Winning Google Kickstart Round C 2020
30:57
Просмотров 3,9 млн