Skip to content

Commit

Permalink
add set question
Browse files Browse the repository at this point in the history
  • Loading branch information
debapriyo007 committed Aug 2, 2023
1 parent f5d75e5 commit dbdbb4b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Binary file added 18_Hashing/HashSet/prb1.class
Binary file not shown.
14 changes: 14 additions & 0 deletions 18_Hashing/HashSet/prb1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.*;

public class prb1 {
public static void main(String[] args) {
int arr[] = {4,3,2,5,6,7,3,4,2,1};
HashSet<Integer> set = new HashSet<>();

for(int i = 0;i<arr.length ;i++){
set.add(arr[i]);
}
System.out.println("ans = " + set.size());
//its take 0(n) time complexity..
}
}
Binary file added 18_Hashing/HashSet/tree.class
Binary file not shown.
19 changes: 19 additions & 0 deletions 18_Hashing/HashSet/tree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.*;

public class tree {
public static void main(String[] args) {
TreeSet<String> ts = new TreeSet<>();
ts.add("bottle");
ts.add("phone");
ts.add("sope");
ts.add("apple");
ts.add("mac");

for(String obj : ts){
System.out.println(obj);
//The output is printing in sorted order..
}


}
}

0 comments on commit dbdbb4b

Please sign in to comment.