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
/* | |
Solution to this problem https://www.geeksforgeeks.org/print-longest-common-substring/ extended version | |
time complexity O(m*n) | |
*/ | |
data class Str(val string: StringBuilder, | |
var startPosition: Int, | |
var nextPosition: Int = startPosition+1, | |
val id: String = UUID.randomUUID().toString() | |
) |
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
#based on this article http://jamie-wong.com/2014/08/19/metaballs-and-marching-squares/ | |
extends Node2D | |
class Blob: | |
var pos_x | |
var pos_y | |
var radius | |
var velocity |
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 CaesarCipher(str: String, num: Int): String { | |
val result = StringBuilder() | |
for(i in str.indices) { | |
if(str[i].toLowerCase() in 'a'..'z') { | |
val a = 'a'.toLong() | |
val A = 'A'.toLong() | |
val shift = (str[i] + num).toLong() | |
val letterLower = shift - a | |
val letterUpper = shift - A | |
val lower = ('z' + 1).toLong() - a |
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
/* | |
Java REST GET Simple | |
In the Java file, write a program to perform a GET request on the route: | |
https://coderbyte.com/api/challenges/json/rest-get-simple | |
and then print to the console the hobbies property in the following format: | |
ITEM1, ITEM2, ... |
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
/* | |
Challenge | |
Have the function SeatingStudents(arr) read the array of integers stored in arr which will be in the | |
following format: [K, r1, r2, r3, ...] where K represents the number of desks in a classroom, | |
and the rest of the integers in the array will be in sorted order and will represent the desks | |
that are already occupied. All of the desks will be arranged in 2 columns, | |
where desk #1 is at the top left, desk #2 is at the top right, desk #3 is below #1, desk #4 is below #2, etc. | |
Your program should return the number of ways 2 students can be seated next to each other. | |
This means 1 student is on the left and 1 student on the right, or 1 student is directly above or below the other student. | |
For example: if arr is [12, 2, 6, 7, 11] then this classrooms looks like the following diagram: |
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
/* | |
Using the Kotlin language, have the function BitmapHoles(strArr: Array<String>): String | |
take the array of strings stored in strArr, which will be a 2D matrix | |
of 0 and 1's, and determine how many holes, or contiguous regions of 0's, | |
exist in the matrix. A contiguous region is one where there is a | |
connected group of 0's going in one or more of four directions: up, | |
down, left, or right. For example: if strArr is | |
["10111", "10101", "11101", "11111"], then this looks like the following matrix: | |
1 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 maxDifference(arr: Array<Int>): Int { | |
var min: Pair<Int, Int> = Pair(0, 0) | |
var max: Pair<Int, Int> = Pair(0, 0) | |
var result = -1 | |
for(i in 0 until arr.size) { | |
when { | |
i == 0 -> { | |
min = Pair(i, arr[i]) |
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.mycompany.myapp.app; | |
import android.app.Application; | |
import android.content.Intent; | |
import com.google.android.gms.common.GooglePlayServicesUtil; | |
import com.google.android.gms.security.ProviderInstaller; | |
import com.google.android.gms.security.ProviderInstaller.ProviderInstallListener; | |
public class MainApplication extends Application { |
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
val String.prefixSumOfGenoms: Array<IntArray> | |
get() { | |
val genoms = Array(3) { | |
IntArray(length+1) | |
} | |
for(i in 0 until length) { | |
var (a, c, g) = arrayOf<Short>(0, 0, 0) | |
when(this[i]) { | |
'A' -> {a = 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
import java.io.* | |
import java.math.* | |
import java.text.* | |
import java.util.* | |
import java.util.regex.* | |
val mod = 1000000007 | |
fun maxbit(value: Int): Int = if(value <= 1) value else maxbit(value shr 1) shl 1 |
NewerOlder