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
package ru.fbear.strings | |
class Brackets { | |
fun valid(bracketsString: String): Boolean { | |
var left = 0 | |
var right = 0 | |
for (sym in bracketsString) { | |
when (sym) { |
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
package ru.fbear.strings | |
class Strings { | |
fun shuflled(source: String, shuffled: String): Boolean { | |
val sourceCharMap: MutableMap<Char, Int> = mutableMapOf() | |
for (char in source) { | |
if (!sourceCharMap.containsKey(char)) sourceCharMap[char] = 1 | |
else sourceCharMap[char] = sourceCharMap[char]!! + 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
package ru.fbear.arithmetic | |
import kotlin.math.abs | |
class Find { | |
fun findNearNum(nums: List<Int>, givenNum: Int): Int { | |
var near = -1 | |
var minDiff = Int.MAX_VALUE | |
for (num in nums) { |
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
package ru.fbear.arithmetic | |
import kotlin.math.abs | |
fun main(args: Array<String>) { | |
println("Hello World!") | |
// Try adding program arguments at Run/Debug configuration | |
println("Program arguments: ${args.joinToString()}") | |
} |