khushaalan.hashnode.devWhat is HeapThere are two types of heaps. Min heap and max heap. Height of a heap is O(log n) Max Heap Max heap is used for heapsort. Value of i <= Value of parent Can be represented as this array : [21, 17, 15, 14, 9, 12, 13, 8, 5, 1] Root of the tree is a...Apr 27, 2025·1 min read
khushaalan.hashnode.devReverse IntegerGiven a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2<sup>31</sup>, 2<sup>31</sup> - 1], then return 0. Assume the environment does not allow you to store...Feb 12, 2025·1 min read
khushaalan.hashnode.devTwo SumGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the a...Feb 12, 2025·1 min read
khushaalan.hashnode.devClear DigitsYou are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit character to its left. Return the resulting string after removing all digits. def clearDigits(self, s: ...Feb 11, 2025·1 min read
khushaalan.hashnode.devAdd Two Numbers using LinkedList and return a LinkedList# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Opti...Jan 23, 2025·2 min read