Monthly Archives: August 2018

Climbing Stairs

https://leetcode.com/problems/climbing-stairs/discuss/155645/Jave-Soulution package test4; /** * ClimbingStairs Problem * @author asharda * */ public class ClimbingStairs { public static void main(String[] args) { ClimbingStairs s=new ClimbingStairs(); System.out.println(s.climbStairs(4)); //s.climbStairs(4); } public int climbStairs(int n) { int result = 1, temp; int a … Continue reading

Posted in Uncategorized | Leave a comment

Dequeue in Python

”’ Created on Aug 11, 2018 @author: asharda ”’ import collections deq=collections.deque([“Mon”,”Tue”,”Wed”]) deq.append(“Thu”) deq.appendleft(“Sun”) print(deq) deq.pop() print(deq) deq.reverse() print(deq)

Posted in Uncategorized | Leave a comment

LinkedLists in Python

”’ Created on Aug 3, 2018 @author: asharda ”’ class node: def __init__(self,data=None): self.data=data self.nextVal=None n1=node(1) n2=node(2) n3=node(3) n1.nextVal=n2 n2.nextVal=n3 t1=n1 while t1: print(t1.data) t1=t1.nextVal

Posted in Python, Uncategorized | Leave a comment

Using sets in Python

”’ Created on Aug 3, 2018 @author: asharda ”’ days=set([“Mon”,”Tue”,”Wed”,”Thu”,”Fri”]) daysA=set([“Tue”,”Wed”,”Thu”,”Fri”]) print(days-daysA) print(days & daysA) for d in days: print(d) days.add(“Sun”)

Posted in Python, Uncategorized | Leave a comment