algorithm and data structures

algorithm and data structures using python

Feauture image of a triagular prism

Auto-differentiation and Autograd explained step by step

We will understand what is automatic differentiation for absolute beginners, although this concept requires a fair amount of theoretical understanding of derivatives and the chain rule, But don’t worry I will try to explain in a very practical way, and we will build our knowledge one concept at a time and the end you will …

Auto-differentiation and Autograd explained step by step Read More »

Daily Coding Problem Solution 4

This problem was asked by Stripe. Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should …

Daily Coding Problem Solution 4 Read More »

Daily Coding Problem Solution 5

This problem was asked by Jane Street. cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4. Given this implementation of cons: def cons(a, b): def pair(f): return f(a, b) return pair Implement car and cdr. I managed to get a solution from none other than a Python Core Developer, …

Daily Coding Problem Solution 5 Read More »

Daily Coding Problem Solution 3

This problem was asked by Google. Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. For example, given the following Node class class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right The following test should …

Daily Coding Problem Solution 3 Read More »