File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
public class HEncoder {
6
6
7
- public HashMap <Character , String > encoder = new HashMap <>();
8
- public HashMap <String , Character > decoder = new HashMap <>();
7
+ public HashMap <Character , String > encoder = new HashMap <>(); // in order to encode
8
+ public HashMap <String , Character > decoder = new HashMap <>(); // in order to decode
9
9
10
10
private static class Node {
11
11
@@ -81,14 +81,17 @@ private void traverse(Node node, String osf) {
81
81
82
82
}
83
83
84
+ // compression work done here
84
85
public String compress (String str ) {
85
86
String rv = "" ;
86
87
for (int i = 0 ; i < str .length (); ++i ) {
87
88
rv += encoder .get (str .charAt (i ));
88
89
}
89
90
return rv ;
90
91
}
92
+
91
93
94
+ //in order to decompress
92
95
public String decompress (String str ) {
93
96
String s = "" ;
94
97
String code = "" ;
You can’t perform that action at this time.
0 commit comments