-
1/12기록 - 프로그래머스 문제풀이 #2Algorithm 2022. 1. 12. 10:26728x90
생각보다 없는 숫자 더하기 문제가 너무 간단해서 한 문제를 더 풀어보았다.
내적 문제이다. 미분적분학과벡터해석을 공부했기 때문인지 내적은 너무 익숙해서 문제를 보고 바로 이해해 버렸다.
a와 b 배열의 인덱스끼리 곱해주면 되니 for문을 써주면 될 것 같았다.
처음에는 이중 for문을 썼더니 답이 다르길래 응??? 했지만, 바로 왜 이중 for문을 쓰면 안되는지 깨달아버렸다. 이중 for문을 쓰게 되면 i가 0일때 0~b.length-1 까지의 인덱스를 다 조사하고, 또 i가 1일때 0~b.length-1 까지의 인덱스를 다 조사한다. 그래서 단순 for문 안에서 a,b 배열의 0인덱스끼리, 1인덱스끼리 이런식으로 곱해주면 되는 거였다.
가뿐하게 통과!!!!!!!!
728x90'Algorithm' 카테고리의 다른 글
1/13기록 - 백준 2309 (0) 2022.01.13 1/12기록 - 프로그래머스 문제풀이 #3 (0) 2022.01.12 1/12기록 - 프로그래머스 문제풀이 #1 (0) 2022.01.12 1/11기록 - 백준 2846 (0) 2022.01.11 1/10기록 - 백준 1009 (0) 2022.01.10