Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions java_codes/StringPalindrome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class StringPalindrome {
public static void main(String[] args) {
String str = "";
System.out.println(isPalindrome(str));

}
static boolean isPalindrome(String str){
int start = 0;
int end = str.length()-1;
if(str.length() == 0){
return true;
}
while(start<end){
if(str.charAt(start) == str.charAt(end)){
start++;
end--;
}else{
return false;
}
}
return true;
}
}
20 changes: 20 additions & 0 deletions java_codes/towerOfHanoi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.Scanner;

public class towerOfHanoi {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n= in.nextInt();
int t1id= in.nextInt();
int t2id= in.nextInt();
int t3id= in.nextInt();
toh(n,t1id,t2id,t3id);
}
static void toh(int n, int t1id , int t2id ,int t3id){
if(n == 0){
return;
}
toh(n-1 ,t1id, t3id, t2id);
System.out.println(n +"[" + t1id + " -> " + t2id + "]");
toh(n-1, t3id, t2id, t1id);
}
}