Skip to content

Commit

Permalink
Java Implementation of Day 7
Browse files Browse the repository at this point in the history
* day7

* day7

* day7 with date
  • Loading branch information
Spreeha authored and Razdeep committed Dec 31, 2018
1 parent ad287d2 commit b3d07cc
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
36 changes: 36 additions & 0 deletions day7/Java/Edit.java
@@ -0,0 +1,36 @@

package javaapplication3;
/**
* @date 28/12/18
* @author SPREEHA DUTTA
*/
import java.util.*;
public class Edit {
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
String s1,s2;int l,c=0;char b;int i;
System.out.println("Enter two strings ");
s1=sc.next();
s2=sc.next();

if(Math.abs(s1.length()-s2.length())<=1)
{
if(s1.length()<s2.length())
l=s1.length();
else
l=s2.length();
for(i=0;i<l;i++)
{
if(s1.charAt(i)==s2.charAt(i))
c++;
}
if((c==l)||((c+1)==l && (s1.length()==s2.length())))
System.out.println(s1+" and "+s2+" are one edit away");
else
System.out.println(s1+" and "+s2+" are not one edit away ");
}
else
System.out.println(s1+" and "+s2+" are not one edit away ");
}
}
41 changes: 41 additions & 0 deletions day7/README.md
Expand Up @@ -684,6 +684,47 @@ class OneEditAway {
}
```

## Java Implementation

### [Solution](./Java/Edit.java)

```java
/**
* @date 28/12/18
* @author SPREEHA DUTTA
*/
import java.util.*;
public class Edit {
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
String s1,s2;int l,c=0;char b;int i;
System.out.println("Enter two strings ");
s1=sc.next();
s2=sc.next();

if(Math.abs(s1.length()-s2.length())<=1)
{
if(s1.length()<s2.length())
l=s1.length();
else
l=s2.length();
for(i=0;i<l;i++)
{
if(s1.charAt(i)==s2.charAt(i))
c++;
}
if((c==l)||((c+1)==l && (s1.length()==s2.length())))
System.out.println(s1+" and "+s2+" are one edit away");
else
System.out.println(s1+" and "+s2+" are not one edit away ");
}
else
System.out.println(s1+" and "+s2+" are not one edit away ");
}
}
```

## Ruby Implementation

### [Solution](./Ruby/one_edit_away.rb)
Expand Down
1 change: 1 addition & 0 deletions day7/dailycodebase
Submodule dailycodebase added at d58c24

0 comments on commit b3d07cc

Please sign in to comment.