Instantly share code, notes, and snippets.

# Sourabh Saldi saldisobi

Created April 9, 2023 17:33
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): Boolean { val indegree = IntArray(numCourses) prerequisites.forEach{preArr-> val dependentCourse = preArr[0] indegree[dependentCourse]++ } val queue = LinkedList()
Created April 9, 2023 16:32
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, 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
Created April 9, 2023 15:10
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, n: Int, k: Int): Int { val graph = HashMap>() // 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]
Created February 13, 2023 15:37
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"
Last active March 11, 2023 10:37
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") } }
Last active March 11, 2023 10:36
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) } }
Created October 7, 2020 14:43
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;
Created September 21, 2020 15:54
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 {
Created April 5, 2020 05:22
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;
Last active April 5, 2020 05:20
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() {