Professional Documents
Culture Documents
21BCS10193_Arjun_kumar_ Day 8
21BCS10193_Arjun_kumar_ Day 8
1. Aim:
I) Sorting is useful as the first step in many different tasks. The most
common task is to make finding things easier, but there are other uses
as well. In this case, it will make it easier to determine which pair or
pairs of elements have the smallest absolute difference between them.
I) import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
Output:
Output:
III) class Solution {
public String longestCommonPrefix(String[] strs)
{ if (strs == null || strs.length == 0) {
return "";
}
return prefix;
}
}
Output:
IV) class Solution {
public boolean containsNearbyDuplicate(int[] nums, int k) {
// create a set to store unique elements
Set<Integer> set = new HashSet<>();
Output:
V) import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
Sum(arr);
Output:
4. Learning Outcomes :