title-img


Java 1D Array (Part 2)

Let's play a game on an array! You're standing at index 0 of an n-element array named game. From some index i (where 0<=i<n), you can perform one of the following moves: Move Backward: If cell i-1 exists and contains a 0, you can walk back to cell i-1. Move Forward: If cell i+1 contains a zero, you can walk to cell i+1. If cell i+leap contains a zero, you can jump to cell i+leap. If you're standing in cell n-1 or the value of i+leap>=n, you can walk or jump off

View Solution →

Java List

For this problem, we have 2 types of queries you can perform on a List: 1.Insert y at index x: Insert x y 2.Delete the element at index x: Delete x Given a list, L, of N integers, perform Q queries on the list. Once all queries are completed, print the modified list as a single line of space-separated integers. Input Format The first line contains an integer, N(the initial number of elements in L). The second line contains N space-separated integers descri

View Solution →

Java Map

You are given a phone book that consists of people's names and their phone number. After that you will be given some person's name as query. For each query, print the phone number of that person. Input Format The first line will have an integer n denoting the number of entries in the phone book. Each entry consists of two lines: a name and the corresponding phone number. After these, there will be some queries. Each query will contain a person's name. Read the queries until end-of-file.

View Solution →

Java Stack

In computer science, a stack or LIFO (last in, first out) is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added.(Wikipedia) A string containing only parentheses is balanced if the following is true: 1. if it is an empty string 2. if A and B are correct, AB is correct, 3. if A is correct, (A) and {A} and [A] are also correct. Examples of some correct

View Solution →

Java Hashset

In computer science, a set is an abstract data type that can store certain values, without any particular order, and no repeated values(Wikipedia). {1,2,3} is an example of a set, but {1,2,3} is not a set. Today you will learn how to use sets in java by solving this problem. You are given n pairs of strings. Two pairs (a,b) and (c,d) are identical if a=c and b=d. That also implies (a,b) is not same as(b,a) . After taking each pair as input, you need to print number of unique pairs you currentl

View Solution →