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
/* | |
* Copyright 2018 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 com.veeyikpong.utils | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.MotionEvent | |
import androidx.recyclerview.widget.RecyclerView | |
import kotlin.math.abs | |
class NestedHorizontalRecyclerView : RecyclerView { | |
private val Y_BUFFER = 10 |
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
sortArray(intArrayOf(5, 2, 3, 1, 5, 6)) | |
fun sortArray(nums: IntArray): IntArray { | |
mergeSort(nums, 0, nums.size - 1) | |
return nums | |
} | |
fun mergeSort(nums: IntArray, left: Int, right: Int) { | |
if (right <= left) return | |
val mid = (left + right) / 2 |
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
numIslands( | |
grid = arrayOf( | |
charArrayOf('1', '1', '1', '1', '0'), | |
charArrayOf('1', '1', '0', '1', '0'), | |
charArrayOf('1', '1', '0', '0', '0'), | |
charArrayOf('0', '0', '0', '0', '0') | |
) | |
) | |
numIslands( |
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
solveSudoku( | |
arrayOf( | |
charArrayOf('8', '.', '.', '.', '.', '.', '.', '.', '.'), | |
charArrayOf('.', '.', '3', '6', '.', '.', '.', '.', '.'), | |
charArrayOf('.', '7', '.', '.', '9', '.', '2', '.', '.'), | |
charArrayOf('.', '5', '.', '.', '.', '7', '.', '.', '.'), | |
charArrayOf('.', '.', '.', '.', '4', '5', '7', '.', '.'), | |
charArrayOf('.', '.', '.', '1', '.', '.', '.', '3', '.'), | |
charArrayOf('.', '.', '1', '.', '.', '.', '.', '6', '8'), | |
charArrayOf('.', '.', '8', '5', '.', '.', '.', '1', '.'), |