View CourseKahnAlgoleetcode207
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
class Solution { | |
fun canFinish(numCourses: Int, prerequisites: Array<IntArray>): Boolean { | |
val indegree = IntArray(numCourses) | |
prerequisites.forEach{preArr-> | |
val dependentCourse = preArr[0] | |
indegree[dependentCourse]++ | |
} | |
val queue = LinkedList<Int>() |
View findCityFloydWarshall1334
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 findTheCity(n: Int, edges: Array<IntArray>, distanceThreshold: Int): Int { | |
val graphArr = Array(n){ | |
IntArray(n) | |
} | |
for (i in 0 until n) { | |
Arrays.fill(graphArr[i], Int.MAX_VALUE) | |
graphArr[i][i] = 0 |
View NetworkDelayDijkastraLeetcode743
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
class Solution { | |
fun networkDelayTime(times: Array<IntArray>, n: Int, k: Int): Int { | |
val graph = HashMap<Int, LinkedList<IntArray>>() | |
// step 1 iterate over given times list & create an adjancy list graph representation | |
times.forEach{node-> | |
val src: Int = node[0] | |
val target : Int = node[1] | |
val weight : Int = node[2] |
View Screen.kt
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
Icon( | |
modifier = Modifier.clickable { commandProcessor(AddCommand()) }, | |
imageVector = Icons.Filled.Add, | |
contentDescription = "add" | |
) | |
Icon( | |
modifier = Modifier.clickable { commandProcessor(TextUpdateCommand(nameMyModel)) }, | |
imageVector = Icons.Filled.Edit, | |
contentDescription = "edit" |
View ProductListViewModel.kt
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
class MyModelViewModel @Inject constructor( | |
private val myModelRepository: MyModelRepository | |
) : ViewModel(), CommandReceiver { | |
override fun onAddClicked() { | |
viewModelScope.launch { | |
Log.v(TAG, "add command") | |
} | |
} |
View MyModelCommands.kt
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 CommandReceiver { | |
fun onAddClicked() | |
fun onTextUpdate(newText: String) | |
fun onDeleteClicked() | |
fun onListClicked() | |
fun onSaveClicked(text: String) | |
fun processCommand(command: Command) { | |
command.execute(this) | |
} | |
} |
View Dijkstra.java
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 countdown.graphtheory; | |
import java.util.*; | |
public class Dijkstra { | |
static class Edge { | |
int from; | |
int to; | |
int weight; |
View coroutine recipies
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
class BlankViewModel : ViewModel() { | |
fun testCoroutines() { | |
viewModelScope.launch(Dispatchers.IO) { | |
} | |
runBlocking { | |
launch { |
View AvlTree
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 backToBasics; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
public class MyAvlTree { | |
private AvlNode mRootNode; | |
View Trie
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 backToBasics; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class MyTrie { | |
private TrieNode mRootTrieNode; | |
MyTrie() { |
NewerOlder