Created
October 9, 2015 23:54
-
-
Save ilyeshammadi/d7db6475bfcde38a89a4 to your computer and use it in GitHub Desktop.
et Voila the challenge is complited B|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Objects; | |
public class Main { | |
public static void main(String[] args) { | |
System.out.println(countCouple("abc", "axc")); | |
} | |
public static int countCouple(String firstWord, String secondWord) { | |
int count = 0; | |
for (int i = 0; i < (firstWord.length() - 1); i++) { | |
String firstCouple = String.valueOf(firstWord.charAt(i)) + String.valueOf(firstWord.charAt(i + 1)); | |
for (int j = 0; j < (secondWord.length() - 1); j++) { | |
String secondCouple = String.valueOf(secondWord.charAt(j)) + String.valueOf(secondWord.charAt(j + 1)); | |
if (Objects.equals(firstCouple, secondCouple)) { | |
count++; | |
} | |
} | |
} | |
return count; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment