Basic algorithms patterns to solve leetcode in Kotlin:
- Two Pointers
- Sliding Window
- Binary Search
- Divide and Conquer
- Breadth-first Search (BFS)
- Depth-first Search (DFS)
- Backtracking
- Dynamic Programming
- Priority Queue / Heap
Basic algorithms patterns to solve leetcode in Kotlin:
| ### Download and setup | |
| 1. Initially, download the Datomic Pro version on the official website: https://docs.datomic.com/pro/getting-started/get-datomic.html | |
| 2. Unzip the zip file and move the folder for your desired path, in this case, it will be on `$HOME/datomic` | |
| 3. Prepare the config file on `$HOME/datomic/config`, there are some examples on `$HOME/datomic/config/samples` | |
| 4. Add the aliases to your terminal startup file (e.g. `~/.bashrc` or `~/.zshrc`) that will be useful for dealing with your Datomic: | |
| ``` | |
| # To start Datomic REPL: | |
| alias datomic-repl="$HOME/datomic/bin/repl" |
| git filter-branch --force --index-filter \ | |
| "git rm --cached --ignore-unmatch *file-path*" \ | |
| --prune-empty --tag-name-filter cat -- --all | |
| git push --force --verbose --dry-run | |
| git push --force | |
| import javax.crypto.BadPaddingException; | |
| import javax.crypto.Cipher; | |
| import javax.crypto.IllegalBlockSizeException; | |
| import javax.crypto.NoSuchPaddingException; | |
| import javax.crypto.spec.IvParameterSpec; | |
| import javax.crypto.spec.SecretKeySpec; | |
| import java.io.IOException; | |
| import java.nio.charset.StandardCharsets; | |
| import java.security.*; |
| fun uploadFile( | |
| url: String, | |
| headers: Map<String, String>, | |
| files: Map<String, Attachment>, | |
| formDataParts: Map<String, Any> | |
| ): Request { | |
| val body = | |
| MultipartBody.Builder() | |
| .setType(MultipartBody.FORM) | |
| .apply { |
| package me.porge.something.adapters | |
| import android.support.v7.widget.RecyclerView | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import kotlin.reflect.KClass | |
| class AnyRvAdapter( | |
| private val controllers: Map<KClass<*>, AnyRvItemController<*>>, | |
| initialItems: List<Any> = emptyList(), |
| import android.util.Log | |
| import androidx.test.espresso.IdlingRegistry | |
| import com.jakewharton.espresso.OkHttp3IdlingResource | |
| import okhttp3.Interceptor | |
| import okhttp3.OkHttpClient | |
| import okhttp3.Response | |
| import okhttp3.mockwebserver.MockResponse | |
| import okhttp3.mockwebserver.MockWebServer | |
| import okhttp3.mockwebserver.QueueDispatcher |
| import androidx.lifecycle.LiveData | |
| import androidx.lifecycle.Observer | |
| import java.util.concurrent.CountDownLatch | |
| import java.util.concurrent.TimeUnit | |
| fun <T> LiveData<T>.blockingObserve(): T? { | |
| val countDownLatch = CountDownLatch(1) | |
| var result: T? = null | |
| val observer = Observer<T> { |
| /* | |
| * Copyright 2017 Google Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| #!/bin/bash | |
| clear | |
| ./gradlew clean mergedJacocoReport | |
| ./gradlew jacocoFullReport | |
| REPORT_PATH="file://$(pwd)/build/reports/jacoco/jacocoFullReport/html/index.html" | |
| echo ${REPORT_PATH} | pbcopy | |
| echo "Report available at:" | |
| echo ${REPORT_PATH} | |
| echo "Report file path copied to clipboard. You can paste it in your favorite browser. :)" |