Question
1. How do I return the number of items in the 2d array at passed idx and if the idx passed is invalid return 0
1. How do I return the number of items in the 2d array at passed idx and if the idx passed is invalid return 0 without hardcoding and using inbuilt libraries
For example: if idx = 0 we want the 1st subarray to return
if idx = 1 we want the 2nd sub array to return
and so on
public int Size(int idx) {
return 0;
}
2. How do you return the maximum value in a 2d array for the passed IDX within all sub arrays without hardcoding or using inbuilt libraries.
For example: if IDX equals 3, I need to return 2 like (arr[0][3], arr[1][3],...arr[arr.length-1][3]
if IDX equals 6, I need to return 6 like (arr[0][6], arr[1][6],...arr[arr.length-1][6]
If an item in the given index does not exist in a specific sub-array, I should ignore and continue with the remaining sub-arrays. If an item at the given index does not exist in any sub-array, I should return 0.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started