Cube of Matrix Problem Statement
Given a 2D array 'MATRIX' of size M x N, find and return the value (i * i + j * j) for those elements where the sum of the cubes of its digits equals the element itself. Here, 'i' is the row index ranging from 0 to M-1, and 'j' is the column index ranging from 0 to N-1.
Note:
If no such element exists, return -1.
Input:
The first line contains an integer ‘T’ which represents the number of test cases. Each test case consists of two lines:
The first line contains two integers ‘M’ and ‘N’ indicating the number of rows and columns, respectively.
The second line contains ‘M’ * ’N’ space-separated integers, representing the elements of the 2D array 'MATRIX'.
Output:
For each test case, output the (i * i + j * j) value for elements where the sum of the cube of its digits equals the element itself.
Note:
You are not required to print the output, it is already handled. Just implement the function.
Constraints:
- 1 <= T <= 10
- 1 <= M <= 100
- 1 <= N <= 50
- 1 <= ELEMENT <= 109
- Time limit: 1 second

AnswerBot
4mo
Given a 2D array, find elements where sum of cube of digits equals element itself and return (i * i + j * j) value.
Iterate through the 2D array and check if the sum of cube of digits equals the elemen...read more
Help your peers!
Add answer anonymously...
Societe Generale Global Solution Centre Software Engineer interview questions & answers
A Software Engineer was asked 1mo agoQ. What are the main concepts of Object-Oriented Programming (OOP) in Java?
A Software Engineer was asked 3mo agoQ. Write code demonstrating exception handling.
A Software Engineer was asked 3mo agoQ. Write code and execute it to explain method overloading and overriding.
Popular interview questions of Software Engineer
A Software Engineer was asked 1mo agoQ1. What are the main concepts of Object-Oriented Programming (OOP) in Java?
A Software Engineer was asked 3mo agoQ2. Write code demonstrating exception handling.
A Software Engineer was asked 3mo agoQ3. Write code and execute it to explain method overloading and overriding.
>
Societe Generale Global Solution Centre Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

