Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f21931

Browse files
authored
Improved task 2902
1 parent728e000 commit0f21931

File tree

1 file changed

+2
-7
lines changed
  • src/main/java/g2901_3000/s2902_count_of_sub_multisets_with_bounded_sum

1 file changed

+2
-7
lines changed

‎src/main/java/g2901_3000/s2902_count_of_sub_multisets_with_bounded_sum/Solution.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
importjava.util.List;
1010

1111
publicclassSolution {
12-
1312
privatestaticfinalintMOD = (int)1e9 +7;
14-
1513
privateHashMap<Integer,Integer>map;
16-
1714
privateint[][]dp;
1815

19-
privateintsolve(ArrayList<Integer>al,intl,intr,intindex,intsum) {
16+
privateintsolve(List<Integer>al,intl,intr,intindex,intsum) {
2017
if (sum >r) {
2118
return0;
2219
}
@@ -29,7 +26,6 @@ private int solve(ArrayList<Integer> al, int l, int r, int index, int sum) {
2926
}
3027
intcur =al.get(index);
3128
intcount =map.get(cur);
32-
3329
for (inti =0;i <=count;i++) {
3430
intcurSum =sum +cur *i;
3531
if (curSum >r) {
@@ -47,7 +43,7 @@ private int solve(ArrayList<Integer> al, int l, int r, int index, int sum) {
4743

4844
publicintcountSubMultisets(List<Integer>nums,intl,intr) {
4945
map =newHashMap<>();
50-
ArrayList<Integer>al =newArrayList<>();
46+
List<Integer>al =newArrayList<>();
5147
for (intcur :nums) {
5248
intcount =map.getOrDefault(cur,0) +1;
5349
map.put(cur,count);
@@ -57,7 +53,6 @@ public int countSubMultisets(List<Integer> nums, int l, int r) {
5753
}
5854
intn =al.size();
5955
dp =newint[n][r +1];
60-
6156
for (inti =0;i <dp.length;i++) {
6257
for (intj =0;j <dp[0].length;j++) {
6358
dp[i][j] = -1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp