Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language Java . 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 Java 2D Array -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.
Introduction To Java
JAVA was developed by James Gosling at Sun Microsystems Inc in the year 1991, later acquired by Oracle Corporation. It is a simple programming language. Java makes writing, compiling, and debugging programming easy. It helps to create reusable code and modular programs.
Java is a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible. A general-purpose programming language made for developers to write once run anywhere that is compiled Java code can run on all platforms that support Java. Java applications are compiled to byte code that can run on any Java Virtual Machine. The syntax of Java is similar to c/c++.
Link for the Problem – Java 2D Array – Hacker Rank Solution
Java 2D Array – Hacker Rank Solution
Problem :
You are given a 6 * 6 2D array. An hourglass in an array is a portion shaped like this:
a b c d e f g
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
Actually, there are many hourglasses in the array above. The three leftmost hourglasses are the following:
1 1 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 1 0 0
The sum of an hourglass is the sum of all the numbers within it. The sum for the hourglasses above are 7, 4, and 2, respectively.
In this problem you have to print the largest sum among all the hourglasses in the array.
Input Format
There will be exactly lines, each containing integers seperated by spaces. Each integer will be between and inclusive.
Output Format
Print the answer to this problem on a single line.
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
The hourglass which has the largest sum is:
2 4 4 2 1 2 4
Java 2D Array – Hacker Rank Solution
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int arr[][] = new int[6][6]; for(int arr_i=0; arr_i < 6; arr_i++){ for(int arr_j=0; arr_j < 6; arr_j++){ arr[arr_i][arr_j] = in.nextInt(); } } Sum(arr); } private static void Sum(int arr[][]){ //ROw int sum=-1000; for(int i =0 ; i<4;i++){ for(int x =0 ; x<4; x++){ int top = arr[i][x]+arr[i][x+1]+arr[i][x+2]; int middle = arr[i+1][x+1]; int bottom = arr[i+2][x]+arr[i+2][x+1]+arr[i+2][x+2]; if(top+middle+bottom>sum){sum=top+middle+bottom;} } } System.out.println(sum); } }
Good day! Do you know if they make any plugins to safeguard against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?
I just could not go away your web site before suggesting that I really enjoyed the usual information an individual provide for your visitors? Is gonna be back incessantly to check up on new posts.
I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…
Thanks a lot for sharing this with all of us you really know what you are talking about! Bookmarked. Kindly also visit my website =). We could have a link exchange contract between us!
Lovely just what I was looking for.Thanks to the author for taking his clock time on this one.
I’m not sure where you are getting your information, but great topic. I needs to spend some time learning much more or understanding more. Thanks for great info I was looking for this info for my mission.
I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but definitely you’re going to a famous blogger if you are not already 😉 Cheers!
so much wonderful information on here, : D.
Enjoyed studying this, very good stuff, thanks. “Management is nothing more than motivating other people.” by Lee Iacocca.
I like what you guys are up also. Such intelligent work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my web site 🙂
It’s in reality a great and useful piece of information. I am glad that you simply shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
Hi there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!
Thanks for sharing superb informations. Your site is very cool. I am impressed by the details that you’ve on this site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles. You, my pal, ROCK! I found just the information I already searched all over the place and simply couldn’t come across. What a perfect web site.
Hello.This post was extremely motivating, particularly because I was searching for thoughts on this subject last couple of days.
Have you ever thought about including a little bit more than just your articles? I mean, what you say is fundamental and all. But think about if you added some great images or video clips to give your posts more, “pop”! Your content is excellent but with pics and video clips, this site could definitely be one of the most beneficial in its field. Wonderful blog!
Hi there very cool website!! Guy .. Excellent .. Amazing .. I will bookmark your web site and take the feeds additionally…I’m glad to find a lot of useful info right here in the publish, we want develop extra strategies on this regard, thank you for sharing. . . . . .
F*ckin’ remarkable issues here. I’m very satisfied to look your post. Thanks a lot and i’m having a look ahead to contact you. Will you kindly drop me a e-mail?
Great write-up, I am normal visitor of one¦s website, maintain up the nice operate, and It is going to be a regular visitor for a lengthy time.
Would you be fascinated by exchanging links?
It’s in point of fact a great and helpful piece of info. I am happy that you just shared this helpful info with us. Please stay us up to date like this. Thank you for sharing.
I cherished as much as you will receive carried out proper here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an edginess over that you want be turning in the following. unwell no doubt come further previously again since precisely the same nearly very often inside of case you shield this hike.
Just wish to say your article is as astonishing. The clarity on your publish is simply spectacular and that i could assume you are a professional in this subject. Well with your permission allow me to clutch your feed to keep updated with imminent post. Thanks one million and please continue the rewarding work.
cialis pharmacy cialis 20mg sale causes of erectile dysfunction
Hi my family member! I wish to say that this post is awesome, nice written and include approximately all important infos. I would like to look extra posts like this .
I dugg some of you post as I thought they were handy very beneficial
buy generic cefadroxil 250mg buy cheap propecia finasteride cost
order fluconazole 200mg sale ampicillin 250mg sale ciprofloxacin 500mg brand
very good publish, i certainly love this web site, keep on it
mebendazole buy online buy cheap generic mebendazole tadalis online order
flagyl 200mg ca buy sulfamethoxazole for sale cephalexin cheap
order cleocin 150mg sale cleocin drug buy erection pills
nolvadex 20mg tablet order ceftin 250mg online cheap brand ceftin 500mg
careprost pills buy robaxin 500mg generic trazodone 100mg pill
buy sildenafil 50mg generic order sildenafil online sildenafil 100mg
order accutane 10mg buy isotretinoin 20mg online cheap buy zithromax 250mg for sale
cost azithromycin oral neurontin 800mg neurontin 600mg pill
generic lasix 40mg order albuterol purchase albuterol without prescription
buy vardenafil 10mg pills buy generic plaquenil plaquenil generic
I truly appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thx again
buy altace cheap altace 10mg uk where can i buy etoricoxib
vardenafil 20mg us buy generic tizanidine buy hydroxychloroquine 200mg generic
mesalamine 400mg cost buy irbesartan without prescription purchase avapro without prescription
order olmesartan 20mg without prescription buy cheap verapamil buy depakote pills
coreg 25mg tablet buy chloroquine no prescription buy chloroquine tablets
An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!
diamox order order imdur 20mg imuran 25mg canada
hi!,I like your writing very a lot! proportion we keep up a correspondence more about your post on AOL? I require an expert on this space to solve my problem. Maybe that is you! Looking forward to look you.
order digoxin 250 mg generic order lanoxin 250 mg pills molnupiravir 200mg ca
order naproxen for sale buy generic omnicef for sale prevacid 30mg over the counter
order baricitinib 4mg order olumiant 4mg for sale order atorvastatin 80mg pill