Skip to content

Latest commit

 

History

History
92 lines (52 loc) · 2.52 KB

File metadata and controls

92 lines (52 loc) · 2.52 KB

Java HackerRank

Difficulty Max Score Success Ratio
Easy 10 97.70%

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 [SVG image] 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 [SVG image] position of [SVG image] line.

Take your input from System.in.

Input Format

The first line has an integer [SVG image] . In each of the next [SVG image] lines there will be an integer [SVG image] denoting number of integers on that line and then there will be [SVG image] space-separated integers. In the next line there will be an integer [SVG image] denoting number of queries. Each query will consist of two integers [SVG image] and [SVG image] .

Constraints

  • [SVG image]
  • [SVG image]
  • [SVG image]
  • [SVG image]

Each number will fit in signed integer.

Total number of integers in [SVG image] lines will not cross [SVG image] .

Output Format

In each line, output the number located in [SVG image] position of [SVG image] line. If there is no such position, just print "ERROR!"

Sample Input

5
5 41 77 74 22 44
1 12
4 37 34 36 52
0
3 20 22 33
5
1 3
3 4
3 1
4 3
5 5

Sample Output

74
52
37
ERROR!
ERROR!

Explanation

The diagram below explains the queries:

image

💡 Hints

➡️ Approach

✅ Detailed Solution

View Solution : Java Arraylist

Submissions Leaderboard Discussions Editorial
📝 My Submission 🏆 Track our position 🤔 Help from Community ✍️ Editorial