Skip to content

Instantly share code, notes, and snippets.

View vamsitallapudi's full-sized avatar
🚩
Become better than yesterday

Vamsi Tallapudi vamsitallapudi

🚩
Become better than yesterday
View GitHub Profile
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)
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)
implementation project(':module1')
dynamicFeatures = [':module2', ':module3']
class StoriesDataSourceProvider : DataSourceProvider {
override fun getDataSource(context:Context) : DataSource {
//build dependencies
return datasource
}
}
interface DataSourceProvider {
fun getDataSource(context:Context):DataSource
}
...
val providers = ServiceLoader.load(DataSourceProvider::class.java, null)
val dataSources = providers.map {
it.getDataSource(activity)
}.toSet()
...
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']++
class Node:
def __init__(self, data):
self.data = data # assigning the data passed
self.next = None # initializing the node as null