{"id":"90c8013d-dc55-478f-ab56-7c05bbf9e481","name":"First Index And Last Index","description":"1. You are given a number n, representing the size of array a.\r\n2. You are given n numbers, representing elements of array a.\r\n\r\nAsssumption - Array is sorted. Array may have duplicate values.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements\r\nA number d","outputFormat":"A number representing first index\r\nA number representing last index","constraints":"1 &lt;= n &lt;= 1000\r\n1 &lt;= n1, n2, .. n elements &lt;= 100\r\n1 &lt;= d &lt;= 100","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\n\r\nint main(){\r\n int n;\r\n cin>>n;\r\n int* arr = new int[n];\r\n for(int i = 0 ; i < n; i++){\r\n cin>>arr[i];\r\n }\r\n int data;\r\n cin>>data;\r\n \r\n // write your code here\r\n \r\n \r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"n= int(input())\n\nlists= []\n\nfor i in range(0, n):\n ele= int(input())\n lists.append(ele)\n \ndata= int(input())\n\n# write your code here"}},"points":10,"difficulty":"easy","sampleInput":"15\r\n1\r\n5\r\n10\r\n15\r\n22\r\n33\r\n33\r\n33\r\n33\r\n33\r\n40\r\n42\r\n55\r\n66\r\n77\r\n33","sampleOutput":"5\r\n9","questionVideo":"https://www.youtube.com/embed/PFaoQ72ziNk","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"d73b864e-002d-4115-a16a-d77afb475aa1","name":"First Index And Last Index","slug":"first-index-and-last-index","type":1}],"next":null,"prev":{"id":"2f403e8a-be97-46b7-87e4-4e4fb487fdb0","name":"First And Last Index","type":3,"slug":"first-and-last-index"}}}

First Index And Last Index

1. You are given a number n, representing the size of array a. 2. You are given n numbers, representing elements of array a. Asssumption - Array is sorted. Array may have duplicate values.

{"id":"90c8013d-dc55-478f-ab56-7c05bbf9e481","name":"First Index And Last Index","description":"1. You are given a number n, representing the size of array a.\r\n2. You are given n numbers, representing elements of array a.\r\n\r\nAsssumption - Array is sorted. Array may have duplicate values.","inputFormat":"A number n\r\nn1\r\nn2\r\n.. n number of elements\r\nA number d","outputFormat":"A number representing first index\r\nA number representing last index","constraints":"1 &lt;= n &lt;= 1000\r\n1 &lt;= n1, n2, .. n elements &lt;= 100\r\n1 &lt;= d &lt;= 100","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\n\r\nint main(){\r\n int n;\r\n cin>>n;\r\n int* arr = new int[n];\r\n for(int i = 0 ; i < n; i++){\r\n cin>>arr[i];\r\n }\r\n int data;\r\n cin>>data;\r\n \r\n // write your code here\r\n \r\n \r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"n= int(input())\n\nlists= []\n\nfor i in range(0, n):\n ele= int(input())\n lists.append(ele)\n \ndata= int(input())\n\n# write your code here"}},"points":10,"difficulty":"easy","sampleInput":"15\r\n1\r\n5\r\n10\r\n15\r\n22\r\n33\r\n33\r\n33\r\n33\r\n33\r\n40\r\n42\r\n55\r\n66\r\n77\r\n33","sampleOutput":"5\r\n9","questionVideo":"https://www.youtube.com/embed/PFaoQ72ziNk","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"d73b864e-002d-4115-a16a-d77afb475aa1","name":"First Index And Last Index","slug":"first-index-and-last-index","type":1}],"next":null,"prev":{"id":"2f403e8a-be97-46b7-87e4-4e4fb487fdb0","name":"First And Last Index","type":3,"slug":"first-and-last-index"}}}
plane

Editor


Loading...

First Index And Last Index

easy

1. You are given a number n, representing the size of array a. 2. You are given n numbers, representing elements of array a. Asssumption - Array is sorted. Array may have duplicate values.

Constraints

1 <= n <= 1000 1 <= n1, n2, .. n elements <= 100 1 <= d <= 100

Format

Input

A number n n1 n2 .. n number of elements A number d

Output

A number representing first index A number representing last index

Example

Sample Input

15 1 5 10 15 22 33 33 33 33 33 40 42 55 66 77 33

Sample Output

5 9

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode