Skip to content

Commit

Permalink
370-Week 08
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangRen2017 committed Dec 8, 2019
1 parent b443c88 commit 66b1daf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Week 08/id_370/Leetcode_205_370.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public boolean isIsomorphic(String s, String t) {
char[] ch1 = s.toCharArray();
char[] ch2 = t.toCharArray();
int len = s.length();
for (int i = 0; i < len; i++) {
if(s.indexOf(ch1[i]) != t.indexOf(ch2[i])){
return false;
}
}
return true;
}
}
13 changes: 13 additions & 0 deletions Week 08/id_370/Leetcode_8_370.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public boolean isIsomorphic(String s, String t) {
char[] ch1 = s.toCharArray();
char[] ch2 = t.toCharArray();
int len = s.length();
for (int i = 0; i < len; i++) {
if(s.indexOf(ch1[i]) != t.indexOf(ch2[i])){
return false;
}
}
return true;a
}
}
30 changes: 30 additions & 0 deletions Week 08/id_370/Leetcode_91_370.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Solution {
public int numDecodings(String s) {
if (s == null || s.length() == 0) {
return 0;
}
int len = s.length();

int help = 1;
int res = 0;
if (s.charAt(len - 1) != '0') {
res = 1;
}
for (int i = len - 2; i >= 0; i--) {
if (s.charAt(i) == '0') {
help = res;
res = 0;
continue;
}
if ((s.charAt(i) - '0') * 10 + (s.charAt(i + 1) - '0') <= 26) {
res += help;
//help用来存储res以前的值
help = res-help;
} else {
help = res;
}

}
return res;
}
}

0 comments on commit 66b1daf

Please sign in to comment.