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 combineFlags(flagOne: Int, flagTwo: Int): Int { | |
return flagOne or flagTwo | |
} |
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 checkIfServerIsUnhealthy( | |
errorRates: DoubleArray, | |
time: Int, | |
timeRange: Int, | |
minimumErrorThreshold: Double | |
): Boolean { | |
if (timeRange > errorRates.size) throw IllegalArgumentException() | |
var left = time - timeRange + 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
data class Document( | |
val data: Byte[] | |
} | |
interface ExportDocument { | |
fun export(document: Document) | |
} | |
class PngExportDocument : ExportDocument { | |
override fun export(document: Document) = TODO("Export as Png") |
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 callback(data: Data) { | |
// Do something. | |
} | |
dataRepository.getData(::callback) |
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 com.test.Model | |
typealias com.test.dtos.Model = ModelDto |
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
interface DataCallback { | |
fun receive(data: Data) | |
} | |
val callback = object : DataCallback { | |
fun receive(data: Data) { | |
// Do something. | |
} | |
} | |
dataRepositroy.getData(callback) |
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 callback: (Data) -> () = { data -> | |
// Do something. | |
} | |
dataRepository.getData(callback) |
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
.gradle | |
/local.properties | |
/.idea/workspace.xml | |
/.idea/libraries | |
.DS_Store | |
/build |
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
Sort the input array into numerical order | |
result = result of the last three elements in the array | |
if the smallest two numbers are greater than 0 and the first element is 0 | |
altResult is result of the two smallest values and the largest value | |
if altResult > result | |
return altResult | |
endIf | |
endIf | |
return result |
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.Arrays; | |
public class Solution { | |
public int solution(int[] A) { | |
Arrays.sort(A); | |
int l = A.length; | |
int result = A[l - 1] * A[l - 2] * A[l - 3]; | |
if(A[0] * A[1] > 0 && A[0] < 0) { | |
int altResult = A[0] * A[1] * A[l - 1]; |
NewerOlder