Naveen
BAN USERpublic class Example
{
public static void main(String[] args) throws InterruptedException
{
final Object o = new Object();
Thread t1 = new Thread(new Runnable()
{
@Override
public void run()
{
synchronized (o)
{
System.out.println("A1");
try
{
o.wait();
} catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println("A2");
o.notify();
}
}
});
Thread t2 = new Thread(new Runnable()
{
@Override
public void run()
{
try
{
Thread.sleep(100);
} catch (InterruptedException e)
{
e.printStackTrace();
}
synchronized (o)
{
System.out.println("B1");
o.notify();
try
{
o.wait();
} catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println("B2");
}
}
});
t1.start();
t2.start();
t1.join();
t2.join();
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().toString());
for (int i = T; --i >= 0;) {
String S = br.readLine();
if (S.length() < 2) {
System.out.println(S.length());
} else {
process(S);
}
}
}
private static void process(String S) {
for (int i = 0; i < S.length() - 1; i++) {
String temp = S.substring(i, i + 2);
if (temp.contains("ab") || temp.contains("ba")) {
S = S.replaceFirst(temp, "c");
i = -1;
} else if (temp.contains("ac") || temp.contains("ca")) {
S = S.replaceFirst(temp, "b");
i = -1;
} else if (temp.contains("bc") || temp.contains("cb")) {
S = S.replaceFirst(temp, "a");
i = -1;
}
}
System.out.println(S.length());
}
}
var a = 'I am good';
- Naveen March 31, 2015var b = a.split(' ').reverse().join(' ');
console.log(b)