FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

auto commit · suckthegithub/Interview-Notebook@d67f608 · GitHub

Repository navigation

Commit d67f608

Browse files
committed
auto commit
1 parent ff2fce9 commit d67f608

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎notes/剑指 offer 题解.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,25 +2272,25 @@ public ArrayList<Integer> FindNumbersWithSum(int[] array, int sum) {
22722272
```java
22732273
public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
22742274
ArrayList<ArrayList<Integer>> ret = new ArrayList<>();
2275-
int start = 1, end = 2;
2275+
int first = 1, last = 2;
22762276
int curSum = 3;
2277-
while (start <= sum / 2 && end < sum) {
2277+
while (first <= sum / 2 && last < sum) {
22782278
if (curSum > sum) {
2279-
curSum -= start;
2280-
start++;
2279+
curSum -= first;
2280+
first++;
22812281
} else if (curSum < sum) {
2282-
end++;
2283-
curSum += end;
2282+
last++;
2283+
curSum += last;
22842284
} else {
22852285
ArrayList<Integer> list = new ArrayList<>();
2286-
for (int i = start; i <= end; i++) {
2286+
for (int i = first; i <= last; i++) {
22872287
list.add(i);
22882288
}
22892289
ret.add(list);
2290-
curSum -= start;
2291-
start++;
2292-
end++;
2293-
curSum += end;
2290+
curSum -= first;
2291+
first++;
2292+
last++;
2293+
curSum += last;
22942294
}
22952295
}
22962296
return ret;
@@ -2447,7 +2447,7 @@ public double countProbability(int n, int s) {
24472447
flag = 1 - flag;
24482448
}
24492449
int totalNum = (int) Math.pow(6, n);
2450-
return (double) dp[n - 1][s - 1] / totalNum;
2450+
return (double) dp[flag][s - 1] / totalNum;
24512451
}
24522452
```
24532453

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL