본문 바로가기

전체 글236

[LeetCode][Kotlin] 930. Binary Subarrays With Sum 930. Binary Subarrays With SumGiven a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. A subarray is a contiguous part of the array.이진 배열 nums와 정수 goal이 주어지면, sum goal을 사용하여 비어 있지 않은 부분 배열의 개수를 반환합니다. 부분 배열은 배열의 연속된 부분입니다. Example 1:Input: nums = [1,0,1,0,1], goal = 2Output: 4Explanation: The 4 subarrays are bolded and underlined below:[1,0,1,0,1][.. 2024. 11. 15.
[LeetCod][Kotlin] 948. Bag of Tokens 948. Bag of TokensYou start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] denotes the value of tokeni. Your goal is to maximize the total score by strategically playing these tokens. In one move, you can play an unplayed token in one of the two ways (but not both for the same token):Face-up: If your current power.. 2024. 11. 14.
[LeetCode][Kotlin] 1838. Frequency of the Most Frequent Element 1838. Frequency of the Most Frequent ElementThe frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations.요소의 빈도는 배열에서 발생하는 횟수입니다. 정수 배열 nums와 정수 .. 2024. 11. 13.
[Android] 이미지 최적화(로드 개선) 해상도화면 또는 인쇄 등에서 이미지의 정밀도를 나타내는 지표이미지를 표현하는 데 몇 개의 픽셀 또는 도트로 나타냈는지 그 정도를 나타내는 말이다.즉, 해상도가 높다는 말은 1인치 당 찍게 되는 점의 수가 많기 때문에 선명하다는 것이다.점의 개수가 많아진다는 것은 메모리가 더 필요하고 처리 과정이 느려질 수 있다는 것이기 때문에, 적절한 해상도를 사용해야 한다. 문제점이미지는 일반적인 애플리케이션 UI 에 비해 크기가 크다.더 높은 해상도의 이미지는 특별한 이점 없이 메모리를 더 많이 차지하며 즉시 추가로 확장해야 하는 부가적인 성능 오버헤드가 발생한다.예시) 시스템 갤러리 애플리케이션은 Android 기기의 카메라를 사용하여 촬영한 사진을 표시하는데 일반적으로 이러한 사진은 기기의 화면 밀도보다 해상도가.. 2024. 11. 12.
[Android] Image Loader Library Android Memory안드로이드는 앱 내에서 사용할 수 있는 힙 메모리가 정해져 있기 때문에 이미지 로더 라이브러리를 사용하지 않은 상태에서 많은 이미지를 사용하거나 고해상도 이미지를 이미지뷰에 로드해야 하는 경우 메모리 부족으로 OOM(Out Of Memory)이 발생하게 된다.즉, 안드로이드 애플리케이션은 프로세스당 메모리 사용량에 제한이 있다. Honeycomb 미만Dalvik heap 영역 : Java 객체를 저장하는 메모리External 영역 : Native heap 의 일종으로 네이티브의 비트맵 객체를 저장하는 메모리Dalvik heap 영역과 External 영역은 각각 프로세스당 메모리 한계까지 확장될 수 있다.Dalvik heap 영역과 External 영역의 Dalvik heap f.. 2024. 11. 11.
[Algorithm][Kotlin] LRU 알고리즘 캐시자주 사용하는 데이터나 값을 미리 복사해 놓는 임시 저장소로, 리소스에 대한 중복 요청을 막거나 바뀌지 않는 데이터를 새로 불러오는 비용을 줄이기 위해 사용된다. [CS] 캐시 (Cache)캐시 (Cache)자주 사용하는 데이터나 값을 미리 복사해 놓는 임시 장소저장 공간이 작고 비용이 비싼 대신 빠른 성능을 제공한다.아래와 같은 경우에 사용을 고려하면 좋다.접근 시간에 비해 원래dev-baik.tistory.comLRU(Least Recently Used) 알고리즘가장 오랫동안 사용되지 않은 데이터를 제거하여 새로운 데이터를 저장하는 방식으로, 메모리 사용량을 효율적으로 관리할 수 있도록 도와준다.최근에 사용되지 않은 데이터는 앞으로도 사용될 가능성이 낮기 때문에, 데이터에 대한 접근 시간을 기록하.. 2024. 11. 10.
[LeetCode][Kotlin] ⭐️ 658. Find K Closest Elements 658. Find K Closest ElementsGiven a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to x than an integer b if:|a - x| |a - x| == |b - x| and a 정렬된 정수 배열 arr, 두 정수 k와 x가 주어지면 배열에서 x에 가장 가까운 k개의 정수를 반환합니다. 결과도 오름차순으로 정렬해야 합니다. 정수 a는 다음의 경우 정수 b보다 x에 더 가깝습니다. - |a - x| - |a -.. 2024. 11. 9.