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
- Binary Search
- 파이썬
- 코테
- Method
- java
- 구현
- implement
- Matrix
- Binary Tree
- Number Theory
- Counting
- Math
- two pointers
- SQL
- sorting
- geometry
- Stack
- string
- 코딩테스트
- Tree
- 자바
- bit manipulation
- greedy
- hash table
- simulation
- Data Structure
- array
- Class
- database
- dynamic programming
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1913. Maximum Product Difference Between Two Pairs 본문
코딩테스트 풀이/JAVA
[LeetCode/Easy] 1913. Maximum Product Difference Between Two Pairs
무지맘 2023. 1. 7. 23:391. Input
1) 정수 배열 nums
2. Output
1) nums의 요소 중 서로 다른 위치에 있는 숫자 a, b, c, d를 골라 a*b – c*d를 계산했을 때 가장 큰 값을 반환
3. Constraint
1) 4 <= nums.length <= 10^4
2) 1 <= nums[i] <= 10^4
4. Example
Input: nums = [5,6,2,7,4] -> Output: 34
설명: 곱의 차가 가장 큰 것은 6*7 – 2*4 = 34이다.
5. Code
1) 첫 코드(2022/06/07)
import java.util.*;
Arrays.sort(nums);
return nums[nums.length-1]*nums[nums.length-2] - nums[0]*nums[1];
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1929. Concatenation of Array (0) | 2023.01.08 |
---|---|
[LeetCode/Easy] 1920. Build Array from Permutation (0) | 2023.01.07 |
[LeetCode/Easy] 1903. Largest Odd Number in String (0) | 2023.01.07 |
[LeetCode/Easy] 1897. Redistribute Characters to Make All Strings Equal (0) | 2023.01.07 |
[LeetCode/Easy] 1880. Check if Word Equals Summation of Two Words (0) | 2023.01.07 |