0% found this document useful (0 votes)
1 views4 pages

Java Test 1

The document outlines five programming challenges involving arrays and matrices. These include identifying leaders in an array, calculating the boundary sum of a matrix, counting element frequencies without using a HashMap, determining automorphic numbers, and finding saddle points in a matrix. Each challenge includes input examples, expected outputs, and relevant concepts for implementation.

Uploaded by

athaprachanai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Java Test 1

The document outlines five programming challenges involving arrays and matrices. These include identifying leaders in an array, calculating the boundary sum of a matrix, counting element frequencies without using a HashMap, determining automorphic numbers, and finding saddle points in a matrix. Each challenge includes input examples, expected outputs, and relevant concepts for implementation.

Uploaded by

athaprachanai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Leaders in an Array ⭐⭐

A number is called a leader if it is greater than all elements to its right.

Input

Plain text

16 17 4 3 5

Output

Plain text

17 5

Explanation

17 is greater than all elements after it.

5 is the last element, so it is always a leader.

Concepts: Arrays + Nested Loops

2. Matrix Boundary Sum ⭐⭐⭐

Find the sum of only the boundary elements of a matrix.

Input

Plain text

33

123

456

789

Output

Plain text
40

Explanation

Boundary elements:

Plain text

123

4 6

789

Sum = 40

Concepts: Matrix + Conditions

3. Frequency of Every Element ⭐⭐⭐

Count how many times each element appears in an array.

Input

Plain text

1213214

Output

Plain text

1 -> 3

2 -> 2

3 -> 1

4 -> 1

Condition: Don't use HashMap.

Concepts: Arrays + Nested Loops + Boolean Logic

4. Automorphic Number ⭐⭐⭐


A number is automorphic if its square ends with the same digits as the
number.

Example

Plain text

5² = 25

Ends with 5 → Automorphic

Plain text

25² = 625

Ends with 25 → Automorphic

Input

Plain text

25

Output

Plain text

Automorphic Number

Concepts: Loops + Math Logic

5. Saddle Point in Matrix ⭐⭐⭐⭐

A saddle point is:

Smallest element in its row

Largest element in its column

Input

Plain text

33

123

456
789

Output

Plain text

Explanation

7 is the smallest in its row and largest in its column.

Concepts: Matrix + Multiple Traversals

You might also like