[Cisco] OA 2025 start – 8 Mar (generic)

Question

The current selected programming language is Python3. We emphasize the submission of a fully working code over partially correct but efficient code. Use of certain header files are restricted. Once submitted, you cannot review this problem again. You can use print to debug your code. The print may not work in case of syntax/runtime error. The version of Python being used is 3.5.2.

Ray, Shiv and Ansh are conducting a survey for a group of people. The survey is only meant for twins but there are certain people who are not twins and wanting to take part in the survey.

Write an algorithm to help them identify the person from the given input who is not a twin.

Input

The first line of input consists of an integer InputArr_size, representing the number of entries in the array (N).

The next line consists of N space-separated integer elements in the array.

Output

Print the smallest value of the person who is not a twin from the given array of elements.

Note

If everyone present is a twin, then return -1.

Examples

Example 1:
Input:
7
1 1 2 3 3 4 4

Output:
2

Example 2:
Input:
4
1 1 2 2

Output:
-1


CISCO

The current selected programming language is Python3. We emphasize the submission of a fully working code over partially correct but efficient code. Use of certain header files are restricted. Once submitted, you cannot review this problem again. You can use print to debug your code. The print may not work in case of syntax/runtime error. The version of Python being used is 3.5.2.

Write an algorithm which finds out the elements which are largest in a row and smallest in a column in a matrix.

Input
The first line of input consists of two space-separated integers-
matrix_row and matrix_col, representing the number of rows in the matrix (N) and the number of columns in the matrix (M), respectively.

The next N lines consist of M space-separated integers representing the elements of the matrix.

Output
Print a number which is largest in a row and smallest in a column in the given matrix. If no element is found print -1.

Constraints
1 ≤ N, M ≤ 1000

Note
Each number in the matrix is a non-negative integer.

Example

Input:
3 3
1 4 2
3 8 6
5 9 7

Output:
3


cisco

Question

Write an algorithm which finds out the elements which are largest in a row and smallest in a column in a matrix.

Input
The first line of input consists of two space-separated integers -
matrix_row and matrix_col, representing the number of rows in the matrix (N) and the number of columns in the matrix (M), respectively.

The next N lines consist of M space-separated integers representing the elements of the matrix.

Output
Print a number which is largest in a row and smallest in a column in the given matrix. If no element is found print -1.

Constraints
1 ≤ N, M ≤ 1000

Note
Each number in the matrix is a non-negative integer.

Example

Input:
2 2
1 2
3 4

Output:
2

Explanation:
The number 2 at index (0,1) is the largest in its row and smallest in its column.
So, the output is 2.


我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

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