title-img


Java BigInteger

In this problem, you have to add and multiply huge numbers! These numbers are so big that you can't contain them in any ordinary data types like a long integer. Use the power of Java's BigInteger class and solve this problem. Input Format There will be two lines containing two numbers, a and b. Constraints a and bare non-negative integers and can have maximum 200 digits. Output Format Output two lines. The first line should contain a+b, and the second line should contain a*

View Solution →

Java 1D Array

An array is a simple data structure used to store a collection of data in a contiguous block of memory. Each element in the collection is accessed using an index, and the elements are easy to find because they're stored sequentially in memory. Because the collection of elements in an array is stored as a big block of data, we typically use arrays when we know exactly how many pieces of data we're going to have. For example, you might use an array to store a list of student ID numbers, or the na

View Solution →

Java 2D Array

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 For example, if we create an hourglass using the number 1 within an array full of zeros, it may look like this: 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 Th

View Solution →

Java Subarray

We define the following: A subarray of an n-element array is an array composed from a contiguous block of the original array's elements. For example, if array=[1,2,3], then the subarrays are [1], [2], [3], [1,2], [2,3], and [1,2,3]. Something like [1,3] would not be a subarray as it's not a contiguous subsection of the original array. The sum of an array is the total sum of its elements. An array's sum is negative if the total sum of its elements is negative. An array's su

View Solution →

Java Arraylist

Sometimes it's better to use dynamic size arrays. Java's Arraylist can provide you this feature. Try to solve this problem using Arraylist. You are given n lines. In each line there are zero or more integers. You need to answer a few queries where you need to tell the number located in yth position of xth line. Take your input from System.in. Input Format The first line has an integer n. In each of the next n lines there will be an integer d denoting number of integers on that line and

View Solution →