Skip to content

Dipin krishna

Ubuntu

How to upgrade Ubuntu server 20.04 to Ubuntu 22.04 (latest)

1. Let’s fetch the latest version of the package list from the repositories. sudo apt update 2. Upgrade the installed packages. sudo apt upgrade 3. Upgrade the distribution and reboot the server. sudo apt dist-upgrade sudo reboot 4. Let’s make sure we have the Update Manager Core installed. sudo apt install update-manager-core 5. Let’s make… Read More »How to upgrade Ubuntu server 20.04 to Ubuntu 22.04 (latest)

0 comments
python

Python: Add Two Numbers – Linked List

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.… Read More »Python: Add Two Numbers – Linked List

2 comments
python

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… Read More »Python: Two Sum Problem

0 comments
python

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

0 comments
python

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 lowestCommonAncestor(self, root,… Read More »Python: Lowest Common Ancestor of a Binary Tree – Non Recursive

0 comments
python

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 = q… Read More »Python: Lowest Common Ancestor of a Binary Search Tree

0 comments