Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Vamsi Tallapudi vamsitallapudi

🎯
Focusing
View GitHub Profile
View InterfaceSegregationGoodEg.kt
package main.leetcode.kotlin.solidPrinciples.InterfaceSegregation
enum class TYPE {
FAST_FOOD, DESSERT, INDIAN, CHINESE
}
interface Food {
fun name(): String
fun type(): TYPE
}
View InterfaceSegregationBadEg.kt
package main.leetcode.kotlin.solidPrinciples.InterfaceSegregation
enum class TYPE {
FAST_FOOD, DESSERT, INDIAN, CHINESE
}
interface Food {
fun name(): String
fun type(): TYPE
fun boil() : String
View LSPPassScenario.kt
open class Bird{
fun makeSound(){}
}
open class FlyingBird : Bird() {
fun fly() {}
}
class Eagle : FlyingBird()
class Penguin : Bird()
View LSPFailScenario.kt
open class Bird{
fun makeSound(){}
fun fly() {}
}
class Eagle : Bird()
class Penguin : Bird() // fails LSP because it cannot fly therefore has different behaviour and cannot call fly() method
View WithoutSingleResponsibility.kt
package main.leetcode.kotlin
class Mariott {
private val basePrice = 2000
private val tax = 500
fun getPrice(): Int {
return basePrice + tax
}
}
class Taj {
View SingleResponsibility.kt
package main.leetcode.kotlin
interface Hotel {
fun getPrice(): Int
}
class Mariott : Hotel {
private val basePrice = 2000
private val tax = 500
override fun getPrice(): Int {
View PostsAdapter.kt
override fun onBindViewHolder(postsViewHolder : ViewHolder, position: Int) {
val post = posts[position]
holder.title!!.text = post.title
holder.description!!.text = post.description
var hashtags = post.hashTags
val sb = StringBuilder()
hashtags.forEach {
sb.apply {
append(it)
append(",")
View PostsAdapter.kt
override fun onBindViewHolder(postsViewHolder : ViewHolder, position: Int) {
val post = posts[position]
holder.title!!.text = post.title
holder.description!!.text = post.description
holder.hashtags.text = AppUtils.convertListToStr(post.hashTags)
}
@vamsitallapudi
vamsitallapudi / NextGreaterNodeInLL.py
Created Sep 6, 2020
Next Greater node in Linked List
View NextGreaterNodeInLL.py
# find next greater node and print it
# eg:
# Input: [2,1,5]
# Output: [5,5,0]
# Definition for singly-linked list.
from typing import List
# Definition for singly-linked list.
View SinglyLinkedListDeletion.py
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
"""
Deleting a node at start.
"""
def delete_at_start(head):
You can’t perform that action at this time.