Skip to content

Instantly share code, notes, and snippets.

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

Vamsi Tallapudi vamsitallapudi

🚩
Be better than yesterday
View GitHub Profile
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
package main.leetcode.kotlin
class Mariott {
private val basePrice = 2000
private val tax = 500
fun getPrice(): Int {
return basePrice + tax
}
}
class Taj {
package main.leetcode.kotlin
interface Hotel {
fun getPrice(): Int
}
class Mariott : Hotel {
private val basePrice = 2000
private val tax = 500
override fun getPrice(): Int {
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)
}
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(",")
@vamsitallapudi
vamsitallapudi / NextGreaterNodeInLL.py
Created September 6, 2020 05:16
Next Greater node in Linked List
# 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.
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
"""
Deleting a node at start.
"""
def delete_at_start(head):
def delete_at_pos(head, position):
if not head:
return None
if position is 0:
return head.next
prev_node = head
curr_node = head.next
current_pos = 1
def delete_at_end(head):
if not head:
return None
prev_node = head
while prev_node.next.next:
prev_node = prev_node.next
prev_node.next = None
return head
def delete_at_start(head):
# edge case: return if head is null
if not head:
return None
head = head.next # moving head to next node
return head