Integers – Equal to Index

The program must accept N integers and print the integers which are equal to their index value as the output. If there is no such integer, the program must print -1 as the output.

Input :

6
5 4 2 3 6 5

Output :

2 3 5

Explanation:
Here 2, 3 and 5 are the integers equal to their index value.

Here are the various methods and logic.

C++

Capture5 1

Python :

C :

IMG 20200421 WA0008 1
#C code by Agent Cherry
IMG 20200421 WA0009 1
#C code by Agent Cherry
Capture7
2020 04 21
#C code by Agent Falcon
Previous Article

Integer - Exactly Three Digits

Next Article

function getStringFromParentheses

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *