Distinct numbersYou are given a list of N integers, and your task is to calculate the number of distinct values in the list. Input The first input line has an integer n: the number of values. The second line has the integers x1,x2,…,xn. Output Print one integer: the...Feb 14, 2024·1 min read
Missing NumberYou are given all numbers between 1,2,…,n except one. Your task is to find the missing number. Input: The first input line contains an integer n. The second line contains n−1 numbers. Each number is distinct and between 1 and n (inclusive). Output: P...Jan 28, 2024·1 min read
Weird Algorithm - CsesProblem Statement: Consider an algorithm that takes as input a positive integer. If it is even, the algorithm divides it by two, and if it is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this until it is one. For exam...Jan 28, 2024·1 min read
Distance Queries - CSESHello everyone, I hope you are learning well, In this blog, we shall learn to solve yet another application of the lowest common ancestor of two nodes which is present in the tree algorithm section of the CSES problem set. So, Let's define the proble...Sep 20, 2023·5 min read
Binary Lifting - Calculating the Lowest Common AncestorHello everyone, I hope you are doing great, I am back with another blog in which I discussed a common category of problems involving trees, the problems seem tricky at first but solving these problems with the technique explained below becomes really...Sep 17, 2023·5 min read
Tree: ImplementationHello everyone, I hope you are doing extremely well and learning from the tree series, In this blog, I shall be discussing with you the implementation of the tree data structure using an adjacency list and adjacency matrix. Implementation using adjac...Aug 31, 2023·1 min read
Trees: Basic To AdvancedHello everyone, I hope you are doing well, I am starting this blog for trees where I shall be teaching trees from the very basics to advance, Stay with me and I will make you get everything covered for your interviews as well as for CP :) What are Tr...Aug 30, 2023·2 min read