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...
Top Software Engineer Interview Questions Asked at Societe Generale Global Solution Centre
Q. What are the main concepts of Object-Oriented Programming (OOP) in Java?
Q. What is a nested query in SQL, and how can it be combined with joins?
Q. Write code demonstrating exception handling.
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Societe Generale Global Solution Centre Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 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

