Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- Method
- Stack
- 자바
- Binary Search
- Data Structure
- simulation
- 구현
- Class
- Binary Tree
- Tree
- sorting
- bit manipulation
- SQL
- 코딩테스트
- implement
- geometry
- java
- Matrix
- two pointers
- array
- Math
- dynamic programming
- Counting
- hash table
- 파이썬
- string
- database
- Number Theory
- 코테
- greedy
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.1] 내적 본문
1. Input
1) 정수 배열 a
2) 정수 배열 b
2. Output
1) a와 b의 내적 결과
2) 내적은 a[0]*b[0] + a[1]*b[1] + ... + a[n-1]*b[n-1] (n은 a, b의 길이)
3. Constraint
1) a와 b의 길이는 같다.
2) a, b의 길이는 1 이상 1,000 이하
3) a, b의 모든 수는 -1,000 이상 1,000 이하
4. Example
Input: a={1,0,1}, b={-1,0,1} -> Output: 0
설명: 1*(-1) + 0*0 + 1*1 = 0
5. Code
1) 첫 코드(2022/??)
int answer = 0;
for(int i=0 ; i<a.length ; i++)
answer += a[i]*b[i];
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.1] 두 개 뽑아서 더하기 (0) | 2022.11.17 |
---|---|
[프로그래머스/Lv.1] 3진법 뒤집기 (0) | 2022.11.17 |
[프로그래머스/Lv.1] 신규 아이디 추천 (0) | 2022.11.15 |
[프로그래머스/Lv.1] 음양 더하기 (0) | 2022.11.15 |
[프로그래머스/Lv.1] 로또의 최고 순위와 최저 순위 (0) | 2022.11.15 |