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>() |
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 |
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] |
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" |
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") | |
} | |
} |
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) | |
} | |
} |
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; |
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 { |
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; | |
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