์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- filternot
- ๋ค์๋ด
- array๋ list
- ์ทจ์ค๊ธฐ๋ก
- recyclerview
- ์ฝ๋ฉํ ์คํธ
- ์ฝํ๋ฆฐ
- iPortfolio
- foldindexed
- ๋ค์ ์ ๋ฆฌํด์ผํจ
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ_2์ฃผ์ฐจ
- Filter
- ๋ค์์ ๋ฆฌํ๊ธฐ
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ_1์ฃผ์ฐจ
- ์๊ณ ๋ฆฌ์ฆ ์ธ์ฆ
- Today
- Total
๋ชฉ๋ก๋ค์๋ด (5)
Moments of growth
[๋ด ์ฝ๋] class Solution { fun solution(numbers: IntArray): Int = 45 - numbers.sum() } [๋ค๋ฅธ ์ฌ๋ ํ์ด] class Solution { fun solution(numbers: IntArray): Int = (0..9).filterNot(numbers::contains).sum() } (0..9) ์ด๊ฒ ๋ฆฌ์คํธ์ธ๊ฐ? (0..9).filterNot(numbers::contains)? ์ด ๋ถ๋ถ ๋ชจ๋ฅด๊ฒ ์ List ์์์ ํํฐ ์ฌ์ฉ Filter dinnerList.filter { it.startsWith("P") } // [Pizza, Pasta] ๋จผ์ ๊ฐ์ฅ ๊ธฐ์ด๊ฐ ๋๋ filter์ด๋ค. Boolean ๊ฐ์ ๋ฐ๋ผ ํํฐ๋ง์ ํ ์ง ์ ํ ์ง ๊ฒฐ์ ํ๋ค. ์์..
[๋ด ์ฝ๋] class Solution { fun solution(absolutes: IntArray, signs: BooleanArray): Int { var answer: Int = 0 for(i in 0 until signs.size){ if(signs[i] == true){ answer += absolutes[i] }else answer -= absolutes[i] } return answer } } [๋ค๋ฅธ ์ฌ๋ ํ์ด] class Solution { fun solution(absolutes: IntArray, signs: BooleanArray) = absolutes.foldIndexed(0) { idx, acc, num -> acc + if (signs[idx]) num else -num } }
[๋ด ์ฝ๋] class Solution { fun solution(n: Int): String { var ans = "" for(i in 0 until n){ if(i%2==0) ans+="์" else ans+="๋ฐ" } return ans } } [๋ค๋ฅธ ์ฌ๋ ํ์ด] class Solution { fun solution(n: Int): String = String(CharArray(n,{i-> if(i%2==0) '์' else '๋ฐ'})) } ์ด๋ฐ ์๊ฐ์ ์ด์ผ ํด๋ด์ง? ๊ทธ๋ฅ ๋ญ๊ฐ ์์ ๋ i๋ ๊ทธ๋ฅ 0๋ถํฐ ์์ํ๋ int๊ฐ์ธ๊ฐ ๋ณด๋ค. CharArray(Int, Char) ๋ฅผ ์๋ก ์์ฑํ ๊ฒ์ด๋ค. ๊ทธ ์ ์ ์ด๋ฐ ๋น์ทํ ๊ฑฐ ๋ชจ์์ ์ ๋ฆฌํ๊ธฐ class Solution { fun solution(n: Int..
[๋ด ์ฝ๋] class Solution { fun solution(x: Int, n: Int): LongArray { var answer = longArrayOf() for(i in 1..n){ answer += (x.toLong()*i) } return answer } } [๋ค๋ฅธ ์ฌ๋ ํ์ด] class Solution { fun solution(x: Int, n: Int): LongArray = LongArray(n) { x.toLong() * (it + 1) } } var a = IntArray(2){ it } a๋ [0,1]
[๋ด ์ฝ๋] class Solution { fun solution(n: Long): IntArray { var answer = intArrayOf() var input = n var i = 0 while(input>0){ answer += (input % 10).toInt() input /= 10 i++ } return answer } } println("54321".map{it.toString().toInt()}) -> [5,4,3,2,1] (intํ) println("54321".map{it.toInt()}) -> [54,53,52,51,50,49] (์ ๊ทธ๋ฐ์ง๋ ๋ชจ๋ฅด๊ฒ ์) println("54321".map{it}) -> [5,4,3,2,1] (์ด๊ฑด characterํ) [๋ค๋ฅธ ์ฌ๋ ์ฝ๋] clas..