diff --git a/PalindromeUsingRecursion.java b/PalindromeUsingRecursion.java new file mode 100644 index 0000000..ffb9ec7 --- /dev/null +++ b/PalindromeUsingRecursion.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class PalindromeUsingRecursion { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner sc=new Scanner(System.in); + System.out.println("Enter the input String :"); + String s=sc.nextLine(); + boolean res= isPalindrome(s,0,s.length()-1); + if(res) + System.out.println("given String is Palindrome"); + else + System.out.println("given String is not a Palindrome"); + + } + public static boolean isPalindrome(String s,int st,int lt) + { + if(s.charAt(st)!=s.charAt(lt)) + return false; + if(st>=lt) + return true; + return isPalindrome(s,st+1,lt-1); + } + +} diff --git a/README.md b/README.md index cb3d676..0fe2c59 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ It is very easy to contribute, you may follow these steps - 99.[RotateLinkedList](https://github.com/PrajaktaSathe/Java/blob/main/Programs/RotateLinkedList.java)-Program to demo rotating a linked list 100. [ReverseString](https://github.com/PrajaktaSathe/Java/blob/main/ReverseString.java) -Program to reverse a String using the java method substring. 101.[Overriding](https://github.com/PrajaktaSathe/Java/blob/main/Programs/Overriding.java)-Program to demo overriding in java +102. [https://github.com/Venkatesh898/JavaOS/blob/feat/PalindromeUsingrecursion/PalindromeUsingRecursion.java] Java program to check whether a given String is palindrome or not using recursion. # Contributors - ## A big thank you to all our contributors!!!