forked from Nidhi-Sharma9419/Elite-Questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallsubsequence.java
More file actions
28 lines (24 loc) · 777 Bytes
/
allsubsequence.java
File metadata and controls
28 lines (24 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Subsequence;
import java.util.Stack;
import java.util.HashMap;
import java.util.Map;
public class allsubsequence {
// Declare a global list
//Y
public static void main(String[] args) {
int arr[] = {2, 3, 4, 6, 1, 3, 4, 9};
//int ans[] = nextGreater(arr);
HashMap<Integer, Integer> map = new HashMap<>();
for(int i =0 ; i< arr.length; i++){
if(map.containsKey(arr[i])){
map.put(arr[i],map.get(arr[i])+1);
}
else{
map.put(arr[i], 1);
}
}
for (Map.Entry<Integer, Integer> e : map.entrySet())
System.out.println("Key: " + e.getKey()
+ " Value: " + e.getValue());
}
}