-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5d75e5
commit dbdbb4b
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.. | ||
} | ||
|
||
|
||
} | ||
} |