문제 링크
1. 아이디어
$(x_1 \lor x_2) \land (x_3 \lor x_4)$ 식을 언어의 논리 연산자로 그대로 옮기면 되는 문제다. x1, x2 중 하나라도 참이면 앞쪽 조건이 참이 되고, x3, x4 중 하나라도 참이면 뒤쪽 조건이 참이 되며, 두 조건이 모두 참일 때만 전체 결과가 참이 된다.
2. 복잡도
3. 코드
풀이 [Java][C++][Python]
1
2
3
4
5
| class Solution {
public boolean solution(boolean x1, boolean x2, boolean x3, boolean x4) {
return (x1 || x2) && (x3 || x4);
}
}
|
1
2
3
4
5
6
| #include <bits/stdc++.h>
using namespace std;
bool solution(bool x1, bool x2, bool x3, bool x4) {
return (x1 || x2) && (x3 || x4);
}
|
1
2
| def solution(x1, x2, x3, x4):
return (x1 or x2) and (x3 or x4)
|