Skip to content

Instantly share code, notes, and snippets.

View vamsitallapudi's full-sized avatar
🚩
Be better than yesterday

Vamsi Tallapudi vamsitallapudi

🚩
Be better than yesterday
View GitHub Profile
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) {
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
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)
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
)
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()!!)
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")
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
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
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"
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"