GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com

// https://www.hackerrank.com/challenges/java-list/problem import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class JavaList { private static final Scanner SCANNER = new Scanner(System.in); public static void main(String[] args) { int length = SCANNER.nextInt(); List list = new ArrayList<>(); for (int index = 0 ; index < length ; index++) { list.add(SCANNER.nextInt()); } int queries = SCANNER.nextInt(); runQueries(queries, list); print(list); } private static void print(List list) { for (int element : list) { System.out.print(element + " "); } } private static void runQueries(int queries, List list) { while (queries-- > 0) { String action = SCANNER.next(); if (action.equals("Insert")) { int index = SCANNER.nextInt(); int value = SCANNER.nextInt(); list.add(index, value); } else { // "Delete" int index = SCANNER.nextInt(); list.remove(index); } } } }
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.