본문 바로가기

전체 글231

[Kotlin][Iterable] chunked 이 컬렉션을 각각 주어진 크기를 초과하지 않는 목록의 목록으로 분할합니다. 결과 목록의 마지막 목록에는 지정된 크기보다 적은 수의 요소가 있을 수 있습니다.public fun Iterable.chunked(size: Int): List> { return windowed(size, size, partialWindows = true)}public fun CharSequence.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (CharSequence) -> R): List { checkWindowSizeStep(size, step) val thisSize = this.length val res.. 2024. 8. 29.
[Kotlin][String] startsWith / endsWith 이 문자 시퀀스가 ​​지정된 접두사로 시작하면 true 를 반환합니다.public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = false): Boolean { if (!ignoreCase && this is String && prefix is String) return this.startsWith(prefix) else return regionMatchesImpl(0, prefix, 0, prefix.length, ignoreCase)}print("HelloWorld".startsWith("Hello")) // trueprint("HelloWorld".startsWith("World").. 2024. 8. 29.
[CS] CPU, 주기억장치(ROM, RAM(SRAM, DRAM), 보조기억장치(HDD, SDD) 중앙 처리 장치 (Central Processing Unit, CPU)컴퓨터의 중앙에서 모든 데이터의 처리를 담당하는 장치, 컴퓨터의 두뇌컴퓨터의 속도는 CPU 의 성능이 가장 큰 영향을 미친다. 컴퓨터는 사용자의 명령을 입력받으면, CPU 가 이 명령을 해석하고, 처리(연산) 해서 출력 장치에서 결과를 출력하도록 한다.이렇게 하나의 부품에 해독, 연산, 제어 등 여러 가지 기능이 집약되어 있기 때문에 CPU 를 "마이크로프로세서"라고 부르기도 한다.프로그램의 명령을 수행하여 다양한 *입력 장치로부터 데이터를 받아서 *기억장치와 연계하여 처리한 후 *출력 장치로 보내는 모든 과정을 제어하고 연산하는 장치입력 장치 : 컴퓨터 등 시스템의 외부에서 데이터와 명령을 시스템으로 입력하는 장치로, 문자, 소리, .. 2024. 8. 28.
[LeetCode][Kotlin] 2002. Maximum Product of the Length of Two Palindromic Subsequences 2002. Maximum Product of the Length of Two Palindromic SubsequencesGiven a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index. Return the maximum possible product of the lengths of the two palindromic subsequences. A subsequence is a string that can.. 2024. 8. 28.
[LeetCode][Kotlin] 1963. Minimum Number of Swaps to Make the String Balanced 1963. Minimum Number of Swaps to Make the String BalancedYou are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.A string is called balanced if and only if:It is the empty string, orIt can be written as AB, where both A and B are balanced strings, orIt can be written as [C], where C is a balanced string.You may.. 2024. 8. 28.
[LeetCode][Kotlin] 1930. Unique Length-3 Palindromic Subsequences 1930. Unique Length-3 Palindromic SubsequencesGiven a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards and backwards. A subsequence of a string is a new string generated from the original strin.. 2024. 8. 28.
[Kotlin][String] substring startIndex 에서 시작하여 endIndex 바로 앞에서 끝나는 이 문자열의 하위 문자열을 반환합니다.public fun String.substring(range: IntRange): String = substring(range.start, range.endInclusive + 1)val s = "hello World"println(s.substring(1, 3)) // el substring - Kotlin Programming Language kotlinlang.org 2024. 8. 28.