Skip to content

Commit

Permalink
add peach12389(neha bindal) as contributor :) (#209)
Browse files Browse the repository at this point in the history
* add peach12389(neha bindal) as contributor :)

* Update README.md

* Update README.md

* Update and rename day22.java to day2_neha.java
  • Loading branch information
peach12389 authored and MadhavBahl committed Jan 29, 2019
1 parent d00d4ee commit 568d1f7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
38 changes: 38 additions & 0 deletions Day2/Java/day2_neha.java
@@ -0,0 +1,38 @@
/*
* 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 day22;

/**
* @date 29/01/2019
* @author nehabindal
*/
import java.util.*;
public class day22 {
public static void main(String[] args)
{
System.out.println("Input a string to check it it's a pallindrome or not");
Scanner sc = new Scanner(System.in);
String st = sc.nextLine();
int l = st.length();
int flag=0;
for(int i=0;i<l/2;i++)
{
if(st.charAt(i)!=st.charAt(l-1-i))
{
flag=1;
}
}
if(flag==1)
{
System.out.println("Not a pallindrome");
}
else{
System.out.println("Yay a pallindorme");
}

}

}
39 changes: 37 additions & 2 deletions Day2/README.md
Expand Up @@ -289,7 +289,7 @@ int main() {
reverse(s1.begin(), s1.end());
cout<<"The reversed string is: "<<s1<<endl;

// to check if the string is a palindrome, we need to check if it is equal to its reverse.
// to check if the string is a palindrome, we need to check if it is equal to its reverse.

if(s.compare(s1) == 0) cout<<"The string is a palindrome"<<endl;
else cout<<"The string is not a palindrome\n";
Expand Down Expand Up @@ -611,6 +611,41 @@ public class Palindrome2 {
}
}
```
### [Solution 3](./Java/day2_neha.java)

```java
/**
* @date 29th jan 2019
* @author nehabindal
*/
import java.util.*;
public class day22 {
public static void main(String[] args)
{
System.out.println("Input a string to check it it's a pallindrome or not");
Scanner sc = new Scanner(System.in);
String st = sc.nextLine();
int l = st.length();
int flag=0;
for(int i=0;i<l/2;i++)
{
if(st.charAt(i)!=st.charAt(l-1-i))
{
flag=1;
}
}
if(flag==1)
{
System.out.println("Not a pallindrome");
}
else{
System.out.println("Yay a pallindorme");
}

}

}
```

## C++ Implementation

Expand Down Expand Up @@ -776,4 +811,4 @@ end

The beauty of programming lies in the fact that there is never a single solution to any problem.

In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :)
In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :)

0 comments on commit 568d1f7

Please sign in to comment.