---
# System prepended metadata

title: 'Collection:'
tags: [Java, ' collection']

---

---
tags: Java, collection, 
---
# Collection:


## :memo: Todo List


### :snowboarder: Arrays

https://www.w3schools.com/java/java_arrays.asp

### :snowboarder: ArrayList

https://www.w3schools.com/java/java_arraylist.asp

### :snowboarder: HashSet

https://www.w3schools.com/java/java_hashset.asp

### :snowboarder: java_hashmap

https://www.w3schools.com/java/java_hashmap.asp
### :snowboarder: Java String charAt() Method

https://www.w3schools.com/java/ref_string_charat.asp

### :snowboarder: Java String indexOf() Method

https://www.w3schools.com/java/ref_string_indexof.asp
# Exercise:

1. Write Java code to find a string of characters that contains only letters from: cdefghijlmnoqstuvxz

where hashing the string produces: 6933552791181934L

If the hash function is defined by the following pseudo-code:

```java=
class UnHash{

    public static void main (String[] args) {
        System.out.println(revHash(6933552791181934L));
        System.out.println(hash("justdoit")); //574318821802
    }

    public static String letters = "cdefghijlmnoqstuvxz";

    public static String revHash(long hash) {
        // write the code here
    }

    public static long hash(String s){
        long h = 7;
        for (int i = 0; i < s.length(); i++){
            h = h * 23 + letters.indexOf(s.charAt(i));
        }
        return h;
    }
}
```
For example, if we were trying to find the string where hashing the string produced 574318821802, the answer would be "justdoit".

2.  Remove Duplicates from Sorted Array


#### Example 1:

Input: nums = [1,1,2]
Output: 2, nums = [1,2,_]
Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.
It does not matter what you leave beyond the returned k (hence they are underscores).

#### Example 2:

Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5, nums = [0,1,2,3,4, _ , _ , _ , _ , _]
Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.
It does not matter what you leave beyond the returned k (hence they are underscores).