Hello Programmers/Coders, Today we are going to share solutions of Programming problems of 30 Days Of Code, HackerRank. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Day 11: 2D Arrays in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use โCtrl+Fโ To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A โFindโ Option There. Use These Option to Get Any Random Questions Answer.
Link for the Problem – Day 11: 2D Arrays โ Hacker Rank Solution
Day 11: 2D Arrays โ Hacker Rank Solution
Problem:
Objective
Today, we are building on our knowledge of arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video.
Context
Given a 2D Array, :
1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
We define an hourglass in to be a subset of values with indices falling in this pattern in ‘s graphical representation:
a b c d e f g
There are hourglasses in , and an hourglass sum is the sum of an hourglass’ values.
Task
Calculate the hourglass sum for every hourglass in , then print the maximum hourglass sum.
Example
In the array shown above, the maximum hourglass sum is for the hourglass in the top left corner.
Input Format
There are lines of input, where each line contains space-separated integers that describe the 2D Array .
Constraints
Output Format
Print the maximum hourglass sum in .
Sample Input
1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 2 4 4 0 0 0 0 2 0 0 0 0 1 2 4 0
Sample Output
19
Explanation
contains the following hourglasses:
1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 2 0 2 4 2 4 4 4 4 0 1 1 1 1 1 0 1 0 0 0 0 0 0 2 4 4 0 0 0 0 0 2 0 2 0 2 0 0 0 0 2 0 2 4 2 4 4 4 4 0 0 0 2 0 0 0 1 0 1 2 1 2 4 2 4 0
The hourglass with the maximum sum () is:
2 4 4 2 1 2 4
Day 11: 2D Arrays โ Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class Day112DArrays { public static void main(String[] args) { Scanner in = new Scanner(System.in); int arr[][] = new int[6][6]; for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { arr[i][j] = in.nextInt(); } } in.close(); int sum = 0, maxSum = Integer.MIN_VALUE; for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { if ((i + 2) < 6 && (j + 2) < 6) { sum = arr[i][j] + arr[i][j + 1] + arr[i][j + 2] + arr[i + 1][j + 1] + arr[i + 2][j] + arr[i + 2][j + 1] + arr[i + 2][j + 2]; } if (sum > maxSum) { maxSum = sum; } } } System.out.println(maxSum); } }
tadalafil 40mg price cialis 40mg brand non prescription ed pills
duricef 250mg over the counter cheap cefadroxil 500mg brand proscar 1mg
oral estradiol purchase prazosin generic prazosin price
buy diflucan without a prescription fluconazole uk order cipro 500mg online cheap
buy cheap generic mebendazole buy mebendazole 100mg generic tadalis 20mg without prescription
metronidazole 400mg ca order generic cephalexin 125mg keflex 125mg generic
avanafil 200mg pills where to buy diclofenac without a prescription buy voltaren 100mg online cheap
buy indomethacin 75mg pills buy suprax 200mg online cheap suprax us
nolvadex 10mg tablet buy cheap generic ceftin buy ceftin sale
buy amoxicillin 500mg sale order arimidex 1 mg without prescription order biaxin 250mg online cheap
catapres 0.1 mg without prescription brand tiotropium bromide order tiotropium bromide
careprost for sale online buy trazodone 100mg pills desyrel ca
minocin sale buy minocin 100mg generic order actos 15mg online cheap
arava 20mg over the counter buy azulfidine 500mg generic sulfasalazine 500 mg sale
order accutane for sale amoxicillin where to buy cheap azithromycin 500mg
cialis us buy cialis 20mg without prescription generic cialis cost
ivermectin uk coronavirus how to buy ed pills prednisone 20mg cost
order lasix 40mg online cheap vibra-tabs over the counter albuterol 4mg cost
ramipril 10mg us buy ramipril for sale buy etoricoxib 60mg pills
vardenafil us hydroxychloroquine online order purchase plaquenil online
buy cheap generic temovate buy amiodarone 200mg generic cordarone 200mg
cost clobetasol temovate buy online buy generic cordarone over the counter
order carvedilol 6.25mg sale carvedilol tablet chloroquine canada
diamox usa azathioprine without prescription order imuran 50mg generic