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 main.dataStructures.sorting | |
fun main(args: Array<String>) { | |
val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array | |
mergeSort(array) | |
for(i in array) println(i) | |
} | |
fun mergeSort(array : IntArray, helper:IntArray = IntArray(array.size), low:Int = 0, high : Int = array.size-1) { | |
if(low < high) { |
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 main.dataStructures.sorting | |
fun main(args: Array<String>) { | |
var numSwaps = 0 | |
var isSorted = false | |
val str = readLine()!! | |
val intList: ArrayList<Int> = ArrayList(str.split(" ").map { it.toInt() }) //1) read values and convert them to arraylist | |
var lastUnsorted = intList.size - 1 // 2) to keep the track of unsorted array |
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 main.dataStructures.sorting | |
fun main(args: Array<String>) { | |
val array = readLine()!!.split(" ").map { it.toInt() }.toIntArray() // 1) Read the input and split into array | |
quickSort(array, 0, array.size-1) | |
for(i in array) println(i) | |
} | |
fun quickSort(array: IntArray, left: Int, right: Int) { | |
val index = partition (array, left, right) |
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
import java.util.Date | |
data class News( | |
val id:Int=0, | |
val news_title:String?=null, | |
var news_detail: String? = null, | |
var news_image_url: String? = null, | |
var news_url: String? = null, | |
var news_source: String? = null, | |
var pub_date: Date? = null | |
) |
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 main.interview.hacklandelection | |
import com.sun.xml.internal.fastinfoset.util.StringArray | |
import java.util.* | |
fun main() { | |
val list = StringArray() | |
var iter = readLine()!!.toInt() | |
while(iter-- > 0) { | |
list.add(readLine()!!) |
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 main.algorithms.searching | |
fun main(args: Array<String>) { | |
val input = readLine()!!.trim().split(" ").map { it -> it.toInt() }.toIntArray() // to read an array (from user input) | |
val eleToSearch = readLine()!!.trim().toInt() // to read the element to be searched (from user input) | |
val pos = binarySearchRecursive(input, eleToSearch, 0, input.size -1) | |
if(pos >= 0 ) { | |
println(pos) // to print position at last | |
} else { | |
println("Position not found") |
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
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: 1 | |
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: 2 | |
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: 3 | |
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: 4 | |
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: 5 | |
2019-01-16 07:35:17.108 7865-7865/com.coderefer.rxandroidexamples D/CreateOperatorActivity: onComplete |
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.coderefer.rxandroidexamples.intro.operators.create | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.coderefer.rxandroidexamples.R | |
import io.reactivex.Observable | |
import io.reactivex.Observer | |
import io.reactivex.disposables.Disposable |
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.coderefer.rxandroidexamples.intro.operators.create | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.coderefer.rxandroidexamples.R | |
import io.reactivex.Observable | |
import io.reactivex.disposables.Disposable | |
private const val TAG = "DeferOperatorActivity" |
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.coderefer.rxandroidexamples.intro.operators.create | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.coderefer.rxandroidexamples.R | |
import io.reactivex.Observable | |
import io.reactivex.disposables.Disposable | |
private const val TAG = "FromOperatorActivity" |