본문 바로가기

전체 글657

[intellij] google code 포매터 적용 구글 포매터 다운 링크 : https://github.com/google/styleguide Clone or download > Download ZIP 압축해제해서 필요한 것만 압축해제 해도 됩니다. 저는 Intellij 용 xml(intellij-java-google-style.xml)만 압축해제 해주었습니다. File > Settings > Editor > Code Style > Scheme 옆에 톱니바퀴 > Import Scheme > Intellij IDEA code style XML 압축해제한 xml 파일 선택합니다. 적용된 모습. Code > Reformat Code ( Alt + F8 ) : 포매터 적용. 파일 저장 시 자동 포매팅 적용 방법. 매크로를 등록한다. Edit > Macros >.. 2020. 7. 11.
[leetcode][430] Flatten a Multilevel Doubly Linked List 문제 : https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/ doubly linked list 가 주어진다. 하나의 노드는 next, previous, child 포인터를 가지고 있다. 이를 prev, next만을 가진 linked list로 바꿔라. child와 next 포인터를 가지고 있다면 child 노드를 next 노드로 잇고 child 노드와 연결된 모든 노드들이 linked list로 만들어졌을 때 그 뒤에 next노드를 다시 이어나간다. dfs로 head 노드에서 child노드가 있다면 child 노드를 잇고 다음 next노드를 잇는 식으로 재귀함수를 만들어서 푼다. 이를 위해 최근 탐색했던 노드 포인터 before와.. 2020. 7. 10.
[leetcode][15] 3Sum 문제 : https://leetcode.com/problems/3sum/ nums 배열이 주어졌을 때 3개의 수 a,b,c를 nums 배열에서 고를 때 a, b, c의 합이 0이 되는 조합의 수를 구해라. https://withhamit.tistory.com/408 [BOJ][2143] 두 배열의 합 문제 : https://www.acmicpc.net/problem/2143 투 포인터(Two-Pointer)를 이용하여 풀었습니다. 배열 당 모든 부배열을 만드는 시간 복잡도는 O(n2)인데 n의 크기가 (1 2020. 7. 8.
[BOJ][2143] 두 배열의 합 문제 : https://www.acmicpc.net/problem/2143 투 포인터(Two-Pointer)를 이용하여 풀었습니다. 배열 당 모든 부배열을 만드는 시간 복잡도는 O(n2)인데 n의 크기가 (1T) 이므로 R--해줍니다. (L=1 / R=6) 1+5 = 6 (>T) 이므로 R--해줍니다. (L=1 / R=5) 1+4 = 5(==T) 이므로 subA에서 1의 개수 x subB에서 4의 개수를 구하면 2x1 = 2가 됩니다. 곱하는 이유는 부 배열 쌍의 개수를 구하는 것이기 때문입니다. 해당 수를 정답에 더하고 L++, R-- 해줍니다. (L = 1, 2 / R = 4) 2+3 = 5 (==T) 이므로 subA에서 2의 개수(1) x subB에서 3의 개수(1)의 값을 정답에 더하고 L++, .. 2020. 7. 8.
[Spring] GatewayFilterFactory add Order kotlin 으로 작성되었습니다. abstract class AbstractOrderedGatewayFilterFactory private constructor() : AbstractGatewayFilterFactory() { private var order: Int = 0 constructor(order: Int) : this() { this.order = order } override fun apply(config: Any?): GatewayFilter { return OrderedGatewayFilter(GatewayFilter { exchange, chain -> chain.filter(exchange) }, order) } } @Component class CustomGatewayFilterFa.. 2020. 7. 2.
[Spring] GatewayFilterFactory Unit Test kotlin 으로 작성되었습니다. @Component class CustomGatewayFilterFactory : AbstractGatewayFilterFactory() { override fun apply(config: Any?) = GatewayFilter { exchange: ServerWebExchange, chain: GatewayFilterChain -> var request = exchange.request val value = request.headers["My-Header"]?.firstOrNull() request = request.mutate() .headers { it.add("Test-Header", AbstractGatewayFilterFactory) } .build() cha.. 2020. 7. 2.