The collection framework is a set of interfaces, implementations and algorithms, that allow you to store, retrieve, manipulate, and communicate aggregate data.
An excellent guide to the CFW is Oracle's Tutorial
For any collection, the most important resource is the JavaDoc. This will tell you everything you need to know about the class, right from constructors, methods and implementation details.
List: https://docs.oracle.com/javase/7/docs/api/java/util/List.html
Queue: https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html
Set: http://docs.oracle.com/javase/7/docs/api/java/util/Set.html
-
You are given a long list of space separated words. There may be duplicates. Print the list of unique words, each one on a newline that appear in the previous list. It is not necessary to print them in the same order as they appeared in the list.
Input:is it crazy how saying sentences backwards creates backwards sentences saying how crazy it is
Output:
is it crazy how saying sentences backwards creates
-
Can you modify the above code to print the words out in alphabetical order?
-
Given two sorted lists of integers of size n and m, create a new list that contains all the integers in sorted order.
Input:3 5 1 4 9 2 7 8 12 16
Output:
1 2 4 7 8 9 12 16
-
You are given a list of n numbers in no particular order. For each number, print out the next highest number in the list. If there is no such number, print -1.
Input:8 1 4 2 3 6 5 9 4
Output:
4 6 3 6 9 9 -1 -1
Explanation:
- For 1, the next highest number in the list is 4.
- For 4 the next highest number in the list is 6.
- For 2 the next highest number in the list is 3.
- For 3, the next highest number inthe list is 6.
- For 6 and 5 the next highest number in the list is 9.
- For 9, there is no next highest number.
- For 4, there is no next highest number.
-
You are given a list of n chess moves. Each move is a string, and can be either:
- Any string, such as "c5", "Be6", "Nf3", etc.
- "undo".
- "print"
After each print command, print all the moves made till now in a space separated manner.
In case the move is "undo", undo the last move. Input:
7 c5 print Be6 Nf3 print undo print
Output:
c5 c5 Be6 Nf3 c5 Be6
- https://www.hackerrank.com/challenges/java-list
- https://www.hackerrank.com/challenges/java-stack
- https://www.hackerrank.com/challenges/java-hashset
- https://www.hackerrank.com/challenges/maximum-element (solve using a CFW class)
- https://www.hackerrank.com/challenges/simple-text-editor (solve using a CFW class)