본문 바로가기

IT

[코딜리티] - Lesson 5. GenomicRangeQuery 안녕하세요 남갯입니다. public int[] solution(String S, int[] P, int[] Q) { // write your code in Java SE 8 int[] result = new int[P.length]; char[] s = S.toCharArray(); for(char a : s){ } S.replaceAll("A", "1"); S.replaceAll("C", "2"); S.replaceAll("G", "3"); S.replaceAll("T", "4"); int length = S.length(); int number = Integer.valueOf(S); for (int i = 0; i < P.length; i++) { result[i] = (int) ((number % ..
[코딜리티] - Lesson 5. PassingCars 안녕하세요 남갯입니다. public class PassingCars { public int solution(int[] A) { // write your code in Java SE 8 int max = 1000000000; int oneCount = 0; int result = 0; for (int a : A) { if (a == 1) { oneCount++; } } //01011 for (int i : A) { if (i == 0) { result += oneCount; if (result > max) { return -1; } } else if (i == 1) { oneCount--; } } return result; } } 1의 갯수를 구한뒤 0의 순서부터 1의 갯수를 줄줄이 뺀 갯수의 전체 합을 ..
[코딜리티] - Lesson 4. MissingInteger 안녕하세요 남갯입니다. public int solution(int[] A) { // write your code in Java SE 8 int result = 1; Map map = new HashMap(); for (int a : A) { if (a > 0) map.put(a, true); } for(int i = 0; i < map.keySet().size(); i++){ if(!map.containsKey(result)){ return result; } result ++; } return result; } https://app.codility.com/demo/results/trainingV3PH42-992/
[코딜리티] - Lesson 4. MaxCounters 안녕하세요 남갯입니다. public static int[] solution(int N, int[] A) { // write your code in Java SE 8 int[] result = new int[N]; int lastMaxValueIdx = -1; int maxValue = 0; int maxTempValue = 0; int idx = 0; for (int a : A) { if (a > N) { lastMaxValueIdx = idx; maxValue = maxTempValue; } else { if (result[a - 1] < maxValue) { result[a - 1] = maxValue + 1; } else { result[a - 1]++; } maxTempValue = Math.ma..
[코딜리티] - Lesson 4. FrogRiverOne 안녕하세요 남갯입니다. public class FrogRiverOne { public static int solution(int X, int[] A) { int sum = ((X) * (X + 1)) / 2; int result = -1; Map map = new HashMap(); if(A.length == 0){ return -1; } int i = 0; for (int a : A) { if (!map.containsKey(a)) { map.put(a, true); sum -= a; } if (sum == 0) { return i; } i++; } return result; } } https://app.codility.com/demo/results/trainingZYBBSY-F3V/
[Android] App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter 에러 해결방법 안녕하세요 YTS 입니다. 요즘 Android를 개발하면서 Manifest에 App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter 이라는 에러를 보실수 있을텐데요!자세한 에러내용은 아래와 같습니다. App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details.Inspection info:Adds URLs to get your app into the Goog..
[Kotlin] 코틀린 확장 함수 (Kotlin extension functions) 예제 및 정리 안녕하세요 YTS 입니다. 오늘은 코틀린에 확장 함수 (Kotlin extension functions)! 에 대해 알아보려고합니다. 당연히! 이 글을 쓴다는거 자체가 확장함수를 지원한다는 얘기겠죠? 우선 전체적으로 공개하는 확장 함수부터 알아볼까요? 1.Kotlin 파일을 생성합니다! class 파일이 아닌 코틀린 파일로 생성해주세요! 저는 extenstion 이라는 패키지 밑에 파일을 생성했어요! 2. 확장 함수를 구현해주세요! package com.yts.healing.extension import android.content.Context import android.view.inputmethod.InputMethodManager import android.widget.Toast import and..
[코딜리티] - Lesson 3. TapeEquilibrium 안녕하세요 남갯입니다. public class TapeEquilibrium { public int solution(int[] A) { // write your code in Java SE 8 int start =0; int reverse = 0; int min = Integer.MAX_VALUE; for(int sum : A){ reverse += sum; } for(int i = 0; i < A.length-1; i++){ start += A[i]; reverse -= A[i]; if(Math.abs(start - reverse) < min) { min = Math.abs(start - reverse); } } return min; } }