kavitha
BAN USER- 0of 0 votes
AnswersYou have a database table Emp with data as follows:
- kavitha in United States
EmpId FirstName LastName
1 Bob Lync
2 Sarah John
3 Bob Lync
4 John Doe
5 Stanly Jeff
6 Sarah John
With a single sql query, how will you cleanup the database (eliminate redundant data from above table)| Report Duplicate | Flag | PURGE
Adobe Software Engineer in Test Database - 0of 0 votes
AnswersWhich data structure will you use for creating a real world dictionary?
- kavitha in United States| Report Duplicate | Flag | PURGE
Adobe Software Engineer in Test Data Structures Java
How about this?
Sort the two strings and then find whether the 2nd contains the first as substring.
package com.techsavvykavi;
import java.util.Arrays;
public class Anagram {
/**
* @param args
*/
public static void main(String[] args) {
String a = "xyz";
String b = "afdgzyxksldfm";
boolean match = false;
char[] pattern = a.toCharArray();
char[] stringToMatch = b.toCharArray();
Arrays.sort(pattern);
Arrays.sort(stringToMatch);
StringBuilder sortedStringToMatch = new StringBuilder();
sortedStringToMatch.append(stringToMatch);
if ( sortedStringToMatch.indexOf(new String (pattern) ) == -1 )
match = false;
else
match = true;
System.out.println( match );
}
}
run the following program and see output :) It prints out current thread name as main when you call t1.run(); and t2.run() explicitely in main
package threadpool;
public class ExtendThread extends Thread {
public void run(){
System.out.println("Thread running = " + Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Thread t1 = new ExtendThread();
Thread t2 = new ExtendThread();
t1.start();
t2.start();
t1.run();
t2.run();
}
}
linear search with for loop breaking at condition a[ i +1 ] < a[ i ] => a[ i ] is the largest. It is already given that the array contains elements in increasing order till some point and then decreasing order. So, I don't think you even have to move till the end of the array during first iteration :)
- kavitha March 20, 2014
this actually works for positive numbers. negative numbers's 1s can be cumbersome to calculate though..
- kavitha March 30, 2014