๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

TIL, WIL/TIL๐Ÿ“˜

05. 18 TIL

728x90

- ์ฝ”๋”ฉ ๊ธฐ์ดˆ ํŠธ๋ ˆ์ด๋‹ ํ’€์ด

~ parseInt vs valueOf ์ฐจ์ด

~ System ํด๋ž˜์Šค์˜ arraycopy ๋ฉ”์„œ๋“œ : ๋ฐฐ์—ด์—์„œ ๋ฐฐ์—ด๋กœ ๊ฐ’์„ ๋ณต์‚ฌํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์„œ๋“œ

+ Arrays.copyOfRange, copyOf

~ ์ •์ˆ˜ i๋ถ€ํ„ฐ n๊นŒ์ง€ ๊ฐ’์„ ๋‹ด์„ ๋•Œ ์“ธ ์ˆ˜ ์žˆ๋Š” IntStream.rangeClosed(i,n)

- lv 0 ํ’€๊ธฐ : ํŒฉํ† ๋ฆฌ์–ผ

class Solution {
  public int solution(int n) {
    int i = 1;
    int factorial = 1;
    while(factorial <= n) {
      i++;
      factorial *= i;
    }
    return i - 1;
  }
}

- lv 1 : ์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜

~ map์˜ ๊ฐ’์„ ์ถœ๋ ฅํ•  ๋•Œ : ํ‚ค์™€ ๊ฐ’์„ ์ „๋ถ€ ์ถœ๋ ฅํ•  ๊ฒฝ์šฐ entrySet(), ํ‚ค๋ฅผ ์ถœ๋ ฅํ•˜๋ ค๋ฉด keySet() ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์ž

~ map์˜ getOrDefault ๋ฉ”์„œ๋“œ

https://junghn.tistory.com/entry/JAVA-Map-getOrDefault-%EC%9D%B4%EB%9E%80-%EC%82%AC%EC%9A%A9%EB%B2%95-%EB%B0%8F-%EC%98%88%EC%A0%9C

 

[JAVA] Map - getOrDefault ์ด๋ž€? ์‚ฌ์šฉ๋ฒ• ๋ฐ ์˜ˆ์ œ

getOrDefault - ์ฐพ๋Š” ํ‚ค๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด ์ฐพ๋Š” ํ‚ค์˜ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์—†๋‹ค๋ฉด ๊ธฐ๋ณธ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ ๋ฐฉ๋ฒ• getOrDefault(Object key, V DefaultValue) ๋งค๊ฐœ ๋ณ€์ˆ˜ : ์ด ๋ฉ”์„œ๋“œ๋Š” ๋‘ ๊ฐœ์˜ ๋งค๊ฐœ ๋ณ€์ˆ˜๋ฅผ ํ—ˆ์šฉํ•ฉ๋‹ˆ

junghn.tistory.com

 

728x90

'TIL, WIL > TIL๐Ÿ“˜' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

06. 04 TIL  (0) 2023.06.05
05. 31 TIL  (0) 2023.05.31
05. 17 TIL  (0) 2023.05.17
05. 02 TIL : RestDocs ์ ์šฉ ์‹ค์Šต  (0) 2023.05.02
04. 28 TIL  (0) 2023.04.28