분류 전체보기 613

[그래프] LCA1

백준 11437 LCAhttps://www.acmicpc.net/problem/11437 1번은 DP안써도 풀림. public class Main { static int N; //노드개수 static int M; //공통조상을 알고싶은 쌍의 수 static List[] map; static boolean[] visited; static int[] depth; static int[] parent; public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; N = Integer.parseInt(br...

죽지 않는 서비스

Immortal Serviceforgraound Service를 이용하면 안죽는다. 그대신 노티피케이션에 항상 나타나 있어야 한다. Foreground Service를 통해 죽지 않는 서비스 만들기 startForeground(int id, Notification notification) 뚜둥.. 단지 저 메소드를 앞에서 만든 ScreenService의 onStartCommand()안의 어딘가에 넣어주면 됩니다. 넘.. 간단 합니다 ;; 여기서 int id 는 Notification의 id를 의미하며 Notification notification 는 서비스가 foreground로 실행되는 동안 나타날 Notification입니다. Notification을 띄우는 방법에 대해서는 다음에 알아보기로 하고~ ..

First-class citizen (1급객체)

First Class Citizen(1급 객체)https://medium.com/@lazysoul/functional-programming-%EC%97%90%EC%84%9C-1%EA%B8%89-%EA%B0%9D%EC%B2%B4%EB%9E%80-ba1aeb048059 1급객체의 조건 3가지 변수나 데이타에 할당 할 수 있어야 한다. 객체의 인자로 넘길 수 있어야 한다. 객체의 리턴값으로 리턴 할수 있어야 한다. 1.변수나 데이터에 할당할 수 있어야 한다object Main { @JvmStatic fun main(args: Array) { val a = test } val test: () -> Unit = { println("kotlin") } } 2.객체의 인자로 넘길 수 있어야 한다object Main ..

Android/Kotlin 2019.02.01

Higher-order-function(고차함수)

Higher-order-function(고차함수)https://medium.com/@lazysoul/high-order-function-%EA%B3%A0%EC%B0%A8%ED%95%A8%EC%88%98-22b147d0c4a5 함수를 인자로 받거나, 함수를 반환하는 함수이 조건이 성립하기 위해서는 기본적으로 함수가 FirstClassCitizen이어야 함object Main { @JvmStatic fun main(args: Array) { println(simpleHigherOrderFunction({ x, y -> x + y }, 10, 20)) //30 println(simpleHigherOrderFunction(sumInts, 10, 20)) //30 println(simpleHigherOrderFu..

Android/Kotlin 2019.02.01

End of input at line 1 column 1 path $

End of input at line 1 column 1 path $ retrofit에서 response값이 비어있을 때(Length=0) 발생다음의 코드를 추가한다 Java코드 해결책https://medium.com/@kenkyee/retrofit2-doesnt-handle-empty-content-responses-bef2b33ee8ea Kotlin코드http://kotlinandroidtutorials.com/retrofit-best-practices/ /** * 비어있는(length=0)인 Response를 받았을 경우 처리 */ class NullOnEmptyConverterFactory : Converter.Factory() { override fun responseBodyConverter(t..