We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 69f3060 commit e1721bbCopy full SHA for e1721bb
Compression/src/HEncoder.java
@@ -4,8 +4,8 @@
4
5
public class HEncoder {
6
7
- public HashMap<Character, String> encoder = new HashMap<>();
8
- public HashMap<String, Character> decoder = new HashMap<>();
+ public HashMap<Character, String> encoder = new HashMap<>(); // in order to encode
+ public HashMap<String, Character> decoder = new HashMap<>(); // in order to decode
9
10
private static class Node {
11
@@ -81,14 +81,17 @@ private void traverse(Node node, String osf) {
81
82
}
83
84
+ // compression work done here
85
public String compress(String str) {
86
String rv = "";
87
for (int i = 0; i < str.length(); ++i) {
88
rv += encoder.get(str.charAt(i));
89
90
return rv;
91
92
+
93
94
+ //in order to decompress
95
public String decompress(String str) {
96
String s = "";
97
String code = "";
0 commit comments