This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RxOperatorTest { | |
private val compositeDisposable = CompositeDisposable() | |
private val testScheduler = TestScheduler() | |
@BeforeEach | |
fun init() { | |
RxJavaPlugins.setComputationSchedulerHandler { testScheduler } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DynamicProgramming { | |
static int[][] map = { | |
{1, 1, 1, 1, 1}, | |
{1, 1, 0, 0, 1}, | |
{1, 1, 1, 1, 1}, | |
{1, 1, 1, 0, 1}, | |
{0, 0, 1, 1, 1} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun solution(a: Int, b: Int): String { | |
val months = listOf(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30) | |
val dayName = listOf("THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED") | |
val day = months.subList(0, a).fold(0) { acc, number -> acc + number } + b | |
return dayName[day % 7] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val list = listOf(1, 2, 3, 4, 5, 6, 7, 8) | |
// 1, 2, 6, 3, 4, 5, 7, 8 | |
val results= leftRotate(2, 6, list.toMutableList()) | |
results.forEach { | |
println(it) | |
} | |
} | |
fun rightRotate(start: Int, end: Int, list: MutableList<Int>): List<Int> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val queue = Queue() | |
queue.insert(1) | |
queue.insert(2) | |
queue.insert(3) | |
queue.insert(4) | |
queue.insert(5) | |
queue.insert(6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val linkedList = LinkedList() | |
linkedList.addNodeAtLast(444) | |
linkedList.addNodeAtLast(555) | |
linkedList.addNodeAtFront(333) | |
linkedList.addNodeAtFront(222) | |
linkedList.addNodeAtFront(111) | |
linkedList.addNodeAtLast(666) | |
linkedList.addNodeAtLast(777) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println(fibonacci(80)) | |
} | |
const val LIMIT = 1000 | |
val mem = Array(LIMIT) {0L} | |
/** | |
* memoization | |
* n >= 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println(factorialTailRec(12, 1)) | |
} | |
fun factorialTailRec(number: Int, accumulator: Int ): Int { | |
return if (number == 0) { | |
accumulator | |
} else { | |
factorialTailRec(number - 1, number * accumulator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
coin() | |
} | |
fun coin() { | |
val bills = arrayOf(1, 2, 5, 10, 20 ,50) | |
var count = 0 | |
val money = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println(binomial(60, 15)) // 60 개중 15개를 뽑는 방법 | |
} | |
const val n = 60 | |
const val r = 15 | |
val matrix = Array(n) { Array(r) { 0 } } | |
/** |
NewerOlder