-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpalindromeandsubstring.java
63 lines (60 loc) · 1.6 KB
/
palindromeandsubstring.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package practice;
/**
*
* @author rakshitmalhotra
*/
import java.io.*;
import java.lang.*;
import java.util.*;
public class Practice {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Use of equals and == in strings
// String str="Hello";
// String str1=new String(str);
// System.out.println(str==str1);
// System.out.println(str.equals(str1));
//Use of compareTo() method
// Scanner sc= new Scanner(System.in);
// String str= sc.nextLine();
// String tocomp="Dhoni";
// if(str.equals(tocomp))
// {
// System.out.print("Thala");
// }
// else System.out.println("virat is the boss");
// }
// Scanner sc= new Scanner(System.in);
// String str=sc.nextLine();
// boolean flag=true;
// int length=str.length();
// for(int i=0;i<length;i++)
// {
// if(str.charAt(i)==str.charAt(length-i-1))
// {
// flag=true;
// }
// else flag=false;
// }
// if(flag==true)System.out.println("yes");
// else System.out.println("No,mm");
//
Scanner sc= new Scanner(System.in);
String str=sc.nextLine();
str=str.toLowerCase();
String str1=sc.nextLine();
if(str.contains(str1))
{
System.out.println(str.indexOf(str1));
}
else System.out.println(-1);
}
}