일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 가상면접으로대규모시스템
- Git commit 합치기
- gitsquash
- git commit merge
- file not found Error
- 헤드퍼스트전략패턴
- formik react-query submitting not working
- 리팩터링2판테스트
- react
- 디자인패턴
- 가상면접2장
- 시스템설계면접예시
- 가상면접3장
- 시스템설계면접
- 리팩토링2판4장
- git commit 협업
- FirebaseAnalytics
- 테스트코드책
- s3이미지다운로드됨
- formik submitting not working
- 전략패턴
- 시스템설계
- 시스템설계면접팁
- 시스템설계방법
- git squash
- cypressBDD
- awss3
- 리액트구글애널리틱스
- react-ga
- cypress React
- Today
- Total
목록코딩테스트 (16)
mingg IT
https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/ Maximize Sum Of Array After K Negations - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com priorityQueue 를 사용하면 쉽게 풀 수 있다. 처음엔 Array를 계속 정렬했는데 그럴 필요가 없음. class Solution { public int largestSumAfterKNegations(int[..
https://app.codility.com/c/run/trainingSEY3MV-T6R/ Codility Your browser is not supported You should use a supported browser. Read more app.codility.com 문제는 쉬운데 이를 어찌 효율적으로 짤것인가.. 당연히 2중 포문 돌리는 순간 시간초과로 난리가 났다. Map을 이용해서 0 0 1 1 2 1 3 2 4 3 으로 해당 인덱스까지 나온 1의 갯수를 구해주었다. 마지막 조건문이 P < Q 이기 때문에 (2,1)인경우를 빼주기 위해서 총 count된 1의 갯수에서 내가 거쳐왔던 이전의 1의 갯수를 빼준다. (말로 하니깐 이상한데 이런방식으로 했다. ) public class PassingC..
우선 그리디를 이용해서 풀어야 하는데 테스트 케이스는 전부 맞았으나 자꾸 시간초과가 났다. 처음 실패한 코드를 알아보자. 시간초과난 코드 import java.util.*; class Solution { public int solution(int[] people, int limit) { int answer = 0; ArrayList list = new ArrayList(); for(int i = 0; i < people.length; i++) { list.add(people[i]); } Collections.sort(list, Collections.reverseOrder()); while(!list.isEmpty()) { int top = list.remove(0); int diff = limit - t..
방법 1 Arrays.sort 내에서 compare 메서드 override compareTo 함수는 int의 경우 비교값 a, b가 있을 때 a > b 일 경우 result = 1 a = b 일 경우 result = 0 a < b 일 경우 result = -1 import java.util.*; class Solution { public int compareNumber (String o1, String head) { String num = o1.substring(head.length()); String newStr = ""; // TAIL을 제외한 방법 for(int i = 0; i < num.length(); i++) { if(Character.isDigit(num.charAt(i))) { newStr..
String temp = Integer.toString(10, n) n 이 10일 경우 10을 10진수로 변환, n 이 3일 경우 10을 3진수로 변환, n이 2일 경우 10을 2진수로 변환해주는 매우 유용한놈임
set.stream().mapToInt(Integer::intValue).toArray(); 람다식으로 한줄로 가능
str = [{abcd}, {a}, {ab}, {abc}] 일 경우 Arrays.sort(str, Comparator.comparing(String::length)); str = [{a}, {ab}, {abc}, {abcd}] 만약 내림차순으로 하고싶다면 Arrays.sort(str, Comparator.comparing(String::length)).reverse; str=[{abcd}, {abc}, {ab}, {a}]
보호되어 있는 글입니다.