You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contains a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.

## Python: Two Sum Problem

Given an array of integers, return indices of the two numbers such that they add up to a specific target. The below python code will return the first solution found, and assumes that no element appears twice. def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ index_map = {} for i

## Python: Stack with Push, Pop and seek Minimum Value with O(1)

Pyhton 3 code to implement a stack with push, pop and seekMin function with time complexity of O(1) class Stack: def __init__(self): self.items = [] self.minList = [] self.min = None   def push(self, item): print("Push: ", item) self.items.append(item) if not self.min: self.min = item else: if item <= self.min: self.minList.append(self.min) self.min = item

## Python: Lowest Common Ancestor of a Binary Tree – Non Recursive

Python 3 code to find the Lowest Common Ancestor of a Binary Tree This is a Non Recursive solution using DFS method. class Node(): def __init__(self, val, left = None, right = None): self.val = val self.left = left self.right = right   class Tree(): def __init__(self, root = None): self.root = root   def

## Python: Lowest Common Ancestor of a Binary Search Tree

Python 3 code to find the Lowest Common Ancestor of a Binary Search Tree def lowestCommonAncestor(root, p, q): """ :type root: TreeNode :type p: TreeNode :type q: TreeNode :rtype: TreeNode """ if root is None or p is None or q is None: return None   if p.val > q.val: temp = p p =

## Python: Array/List Rotation – Right

Python program to rotate an array towards its right Inplace Method # Rotate Array def roateRight(arr, size, rotate_count): array_length = len(arr) if array_length <= 0: return arr   if size > array_length: size = array_length   # Figure out effective roation count # eg: size = 10 and rotation_count = 15 # effective roation_count is