Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
fishercoder1534 committed Jan 16, 2021
1 parent cb0df72 commit 5fc6310
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
25 changes: 11 additions & 14 deletions src/main/java/com/fishercoder/solutions/_809.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class _809 {
public static class Solution1 {
public int expressiveWords (String S, String[] words ) {
public int expressiveWords(String S, String[] words) {
int ans = 0;
for (String w : words) {
if (check(S, w)) {
Expand All @@ -11,7 +11,8 @@ public int expressiveWords (String S, String[] words ) {
}
return ans;
}
private boolean check (String S, String w) {

private boolean check(String S, String w) {
int i = 0;
int j = 0;
/* Logic is to check whether character at same index of S and w are same
Expand All @@ -24,37 +25,33 @@ private boolean check (String S, String w) {
while (i < S.length() && j < w.length()) {
char ch1 = S.charAt(i);
char ch2 = w.charAt(j);

int len1 = getLen(S, i);
int len2 = getLen(w, j);
if (ch1 == ch2) {
if (len1 == len2) {
i = i + len1;
j = j + len2;
}
else if (len1 >= 3 && len2 < len1) {
} else if (len1 >= 3 && len2 < len1) {
i = i + len1;
j = j + len2;
}
else {
} else {
return false;
}
}
else {
} else {
return false;
}
}
return i == S.length() && j == w.length();
}

private int getLen (String value, int i) {
private int getLen(String value, int i) {
i = i + 1;
int count = 1;
for(int j = i; j<value.length(); j++) {
if(value.charAt(j) == value.charAt(i-1)) {
for (int j = i; j < value.length(); j++) {
if (value.charAt(j) == value.charAt(i - 1)) {
count++;
}
else {
} else {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/fishercoder/_809Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void setup() {

@Test
public void test1() {
words = new String[] {"hello", "hi", "helo"};
words = new String[]{"hello", "hi", "helo"};
S = "heeellooo";
assertEquals(1, solution1.expressiveWords(S, words));
}
Expand Down

0 comments on commit 5fc6310

Please sign in to comment.