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

Commit4a0f6aa

Browse files
authored
Create 2028-find-missing-observations.kt
1 parent2018e17 commit4a0f6aa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classSolution {
2+
funmissingRolls(rolls:IntArray,mean:Int,_n:Int):IntArray {
3+
val m= rolls.size
4+
var n=_n
5+
var nTotal= (mean* (n+ m))- (rolls.sum()?:0)
6+
7+
if (nTotal< n|| nTotal> n*6)
8+
returnIntArray (0)
9+
10+
var res=LinkedList<Int>()
11+
while (nTotal>0) {
12+
val dice= minOf(nTotal- n+1,6)
13+
res.add(dice)
14+
nTotal-= dice
15+
n--
16+
}
17+
18+
return res.toIntArray()
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp