This file contains hidden or 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: | |
def numIslands(self, grid): | |
if not grid: | |
return 0 | |
count = 0 | |
for i in range(len(grid)): | |
for j in range(len(grid[0])): | |
if grid[i][j] == '1': | |
self.dfs(grid, i, j) |
This file contains hidden or 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: | |
def search(self, nums: List[int], target: int) -> int: | |
pivot = self.get_pivot(nums, 0, len(nums)-1) | |
if pivot == -1: | |
return self.binary_search(nums, target, 0, len(nums)-1) | |
if target == nums[pivot]: | |
return pivot | |
elif target >= nums[0]: | |
return self.binary_search(nums,target, 0, pivot-1) |
This file contains hidden or 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
implementation project(':module1') |
This file contains hidden or 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
implementation project(':app') |
This file contains hidden or 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
dynamicFeatures = [':module2', ':module3'] |
This file contains hidden or 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 StoriesDataSourceProvider : DataSourceProvider { | |
override fun getDataSource(context:Context) : DataSource { | |
//build dependencies | |
return datasource | |
} | |
} |
This file contains hidden or 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 DataSourceProvider { | |
fun getDataSource(context:Context):DataSource | |
} |
This file contains hidden or 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
... | |
val providers = ServiceLoader.load(DataSourceProvider::class.java, null) | |
val dataSources = providers.map { | |
it.getDataSource(activity) | |
}.toSet() | |
... |
This file contains hidden or 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 PermutationInString { | |
fun checkInclusion(s1:String, s2: String): Boolean { | |
val len1 = s1.length | |
val len2 = s2.length | |
val value = Array(26) {0} | |
if (len2 < len1) return false | |
for (i in 0 until len1) { | |
// filling value array with the frequencies of string 1 | |
value[s1[i] - 'a']++ |
This file contains hidden or 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 Node: | |
def __init__(self, data): | |
self.data = data # assigning the data passed | |
self.next = None # initializing the node as null |