Skip to content

Instantly share code, notes, and snippets.

@goodwinnk
goodwinnk / Some.java
Created June 12, 2019 14:54
Interview
public class Some {
int foo(String a, String b) {
if (a.length() > b.length()) return -1;
for (int i = 0; i < b.length(); i++) {
boolean flag = true;
for (int j = 0; j < a.length(); j++) {
if (a.charAt(j) != b.charAt(i + j)) {
flag = false;
break;
public class Rec {
public static int rec(int[] some, int count) {
if (count == 0) return 0;
return Math.max(some[0], rec(some, count - 1)) + 1;
}
public static void main(String[] args) {
run(Integer.parseInt(args[0]));
}
@goodwinnk
goodwinnk / DataClassCoverageCaller.kt
Created February 27, 2018 11:00
Call generated methods in Kotlin data classes with reflection. DataClassCoverageCaller can be used to quickly workaround bad coverage percent for data classes.
package coverage
import org.junit.Test
import kotlin.reflect.KCallable
import kotlin.reflect.full.instanceParameter
import kotlin.reflect.full.valueParameters
data class OneLineDC(val a: Int, val b: String, val c: Any = 12)
class SampleTest {