본문 바로가기

전체 글234

[LeetCode][Kotlin] 424. Longest Repeating Character Replacement 424. Longest Repeating Character ReplacementYou are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest substring containing the same letter you can get after performing the above operations.문자열 s와 정수 k가 주어집니다. 문자열의 모든 문자를 선택하여 다른 대문자 .. 2024. 10. 30.
[LeetCode][Kotlin] 1888. Minimum Number of Flips to Make the Binary String Alternating 1888. Minimum Number of Flips to Make the Binary String AlternatingYou are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:Type-1: Remove the character at the start of the string s and append it to the end of the string.Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa.Return the m.. 2024. 10. 29.
[Compose] hiltViewModel()과 viewModel() 차이 https://medium.com/kenneth-android/compose-hiltviewmodel-%EA%B3%BC-viewmodel-%EC%B0%A8%EC%9D%B4-6d5412efcb19 [Compose] hiltViewModel()과 viewModel() 차이들어가며medium.com 2024. 10. 28.
[Android] 직렬화(Serialization, Parcelable), 역직렬화(Deserialization) Serialization(직렬화)객체를 외부의 시스템에서도 사용할 수 있도록 객체의 데이터를 *바이트 스트림(연속적인 바이트) 형태로 변환하는 기술바이트 스트림 : 스트림은 클라이언트나 서버 간에 출발지 목적지로 입출력하기 위한 데이터가 흐르는 통로를 말한다. 자바는 스트림의 기본 단위를 바이트로 두고 있기 때문에, 네트워크나 데이터베이스로 전송하기 위해 최소 단위인 바이트 스트림으로 변환하여 처리한다.JVM 의 메모리(힙 or 스택)에 상주되어 있는 객체 데이터를 바이트 형태로 변환하는 기술바이트 형태로 변환 후, 데이터베이스나 파일과 같은 외부 저장소에 저장해두고, 다른 컴퓨터에서 이 파일을 가져와 역직렬화를 통해 객체로 변환하여 JVM 메모리에 적재하는 것직렬화를 응용한다면 휘발성이 있는 캐싱 데이.. 2024. 10. 27.
[LeetCode][Kotlin] 219. Contains Duplicate II 219. Contains Duplicate IIGiven an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) 정수 배열 nums와 정수 k가 주어졌을 때, 배열에 두 개의 서로 다른 인덱스 i와 j가 있고 nums[i] == nums[j]이고 abs(i - j)  Example 1:Input: nums = [1,2,3,1], k = 3Output: true Example 2:Input: nums = [1,0,1,1], k = 1Output: true Example 3:Input: nums .. 2024. 10. 23.
[Android] Strong, Soft, Weak, Phantom Reference 메모리 관리안드로이드 디바이스는 제한된 메모리 자원을 가지고 있기 때문에 *메모리 누수가 발생하면 앱의 성능이 저하되고, 심각한 경우 앱이 강제 종료될 수 있기 때문에 메모리 관리는 중요하다.메모리 누수(Memory Leak) : 프로그램이 동적으로 할당한 메모리 영역 중 일부를 더 이상 사용하지 않음에도 불구하고 해제하지 않아, 사용할 수 있는 메모리가 점점 줄어드는 현상앱이 종료될 때 참조하고 있는 객체가 남아있어 메모리 누수가 발생할 수 있기 때문에, 애플리케이션 컨텍스트를 멤버 변수로 사용하지 않는 것이 좋다.Weak Reference 는 객체가 더 이상 사용되지 않을 때 GC 가 해당 객체를 수거할 수 있기 때문에, Weak Reference 를 적절히 활용하는 것이 중요하다.GC(Carbase.. 2024. 10. 21.
[LeetCode][Kotlin] 42. Trapping Rain Water 42. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.너비가 1인 고도 지도를 나타내는 음이 아닌 정수 n개가 주어졌을 때, 비가 내린 후에 얼마나 많은 물을 가둘 수 있는지 계산하세요. Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1.. 2024. 10. 21.