write a method in JAVA
Find duplicates in a list using O(n) runtime
boolean containsDuplicate(String[] a)
import java.util.Scanner;
class Duplicates
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int n;
System.out.println("Enter Size of Strings :");
n=s.nextInt();
String str[]=new String[n];
System.out.println("Enter Strings");
for(int i=0;i<n;i++)
{
str[i]=s.next();
}
if(containsDuplicate(str))
{
System.out.println("Strings contain Duplicates");
}
else
{
System.out.println("Strings does not contain Duplicates");
}
}
static boolean containsDuplicate(String str[])
{
for(int i=0;i<str.length;i++)
{
for(int j=i+1;j<str.length;j++)
{
if(str[i].equals(str[j]))
{
return true;
}
}
}
return false;
}
}

write a method in JAVA Find duplicates in a list using O(n) runtime boolean containsDuplicate(String[] a)
Write a method List duplicates(List-Doubles input) that returns a List af all duplicates in the input List. You may assume thai each elemert occurs either once or twicc. The expected runtime nust be Oo) whece n is the number a elements (even if the input is a Linkodl ist, the runtime should still he n) ino credit for slower runtimes, so you cancsot sort the input). (12 point) Examples: input 13, 4,4 retum [4 input 13.7, 4, 7,3] rctum 17,...
Write a method List-Double> duplicates(List<Double> input) that returns a List of all duplicates in the input List. You may assume occurs either once or twice. The expected runtime must be O(n) where n is elements (no credit for slower runtimes, so you cannot sort the input).(0 Examples: input = [3,4,4] input [3, 7,4, 7,3] return [7, 3] that each element the number of points) return [4] List Double duplicates(List<Double input)(
Write a method boolean perfectSquare(int n) that returns true if n is a perfect square. You may not use Math.sqrt and the runtime must be O(logn). Using this hint: Binary search to try to find a number whose square is n. Initialize low = 0 and high = n. Note that mid*mid may overflow, so you can avoid this by using a long.
[Tests problem solving and a little bit of Java language] Write a Java method removeDuplicates that removes all duplicates in a given list. Assume the following: a. The method accepts an object of type List b. The return type of the method is void c. Duplicates are determined using the equals() method (rather than by the == operator) Your implementation of removeDuplicates should handle, in an appropriate way, the case in which a null List is passed in to the...
**JAVA** Write a binary search method for a String array that might contain nulls. Your method should not crash or throw a runtime exception. See the driver program for examples. The method header is: public static int binarySearchWithNulls(String[] words, String target) must be recursive.
In java please
Write an efficient method that takes a string txt and an integer M as arguments and returns the position of the first occurrence of M consecutive blanks in the string. If there is no such occurrence it should return the length of txt (txt.length). Give a runtime analysis of the method. 4.
In java Write and test a method that finds the longest string(s) in a list of strings. If there is more than one string with the maximum length, ALL of them should be returned, in some appropriate data-structure.
Using Java, Write a method , getFirstLine, that is passed a String argument and that returns the first line. (Recall that lines are terminated with the "\n" character .) Assume that the argument contains at least one complete, newline-terminated line.
IN JAVA. Implement a method, public static boolean isPalindrome(String) to determine whether the specified String is a palindrome or not. A palindrome is a phrase that reads the same forwardand backward; not including punctuation, spaces, or letter case. Some example palindromes include: Just the method please..