Skip to main content

Posts

Showing posts with the label raees

Java 8 Coding challenge: Raees's Liquor Tank

Raees wants to build a new tank to hide his illegal liquor . He comes up with some designs . Now he asks you to find out maximum units of liquor he can fill in the tank. You are given  N  elements , corresponding to heights of walls . See the figure for input 0 ,8 ,0 ,4 ,0 ,3 ,0 ,5 ,0 ,3 ,0 ,1 ,0. Maximum amount of liquor that can be filled is 5 + 1 + 5 + 2 + 5 + 3 + 1 = 22. Eg : For input 4 ,2 ,4 ,3 Output will be 2 . INPUT First line of input contains a single integer  N . Second line of input contains  N  non-negative integers (  A0  ---  A(n-1)  ). OUTPUT Single integer , answer to the Raees's question. CONSTRAINTS 1 <=  N  <= 1000 1 <=  Ai  <= 1000 SAMPLE INPUT 13 0 8 0 4 0 3 0 5 0 3 0 1 0 SAMPLE OUTPUT 22  Code: import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Q1 {...

Java 8 Coding challenge: Raees's Liquor Tank

Raees wants to build a new tank to hide his illegal liquor . He comes up with some designs . Now he asks you to find out maximum units of liquor he can fill in the tank. You are given N elements , corresponding to heights of walls . See the figure for input 0 ,8 ,0 ,4 ,0 ,3 ,0 ,5 ,0 ,3 ,0 ,1 ,0. Maximum amount of liquor that can be filled is 5 + 1 + 5 + 2 + 5 + 3 + 1 = 22. Eg : For input 4 ,2 ,4 ,3 Output will be 2 . INPUT First line of input contains a single integer N . Second line of input contains N non-negative integers ( A0 --- A(n-1) ). OUTPUT Single integer , answer to the Raees's question. CONSTRAINTS 1 <= N <= 1000 1 <= Ai <= 1000 SAMPLE INPUT 13 0 8 0 4 0 3 0 5 0 3 0 1 0 SAMPLE OUTPUT 22  Code: import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Q1 { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; priv...