## Prime numbers

Prime number A prime number is a natural number with exactly 2 distinct divisors. For example 2, 3, 5, 7 and so on. Given number N, How do we determine if it is prime? One approach is to iterate through the numbers [1, N] and count how many of them divide N. Can we check it faster than this? If prime number has only 2 divisors, that means it s divisible by only 1 and itself....

## Union Find

About the Disjoint Set Union (Union Find) data structure: Judging by its name, the data structure consists of three words: union, find, and disjoint. There are three main operations or concepts associated with it. Determining to which part it belongs Union, which involves combining two separate parts. The structure has two actions. Initially, we start with multiple separate parts and the goal is to connect them easily while being able to determine to which part it belongs....

## Graph

What is graph Wikipedia: A graph is a structure made of vertices and edges. I: Ok A graph can be described as a way of representing relationships between things. For example, let’s consider the relationship of friends. A is a friend of B, B is a friend of C, and C is a friend of D. Additionally, D is a friend of A, and B. In this scenario, we refer to these individuals as vertices, and the connections between them as edges....

## Binary search

Binary search algorithms are everywhere, and for good reason. They embody a simple yet powerful idea. In general, algorithms are named with purpose. Let’s take a closer look at this algorithm through an example problem. Problem We are given an ascending sequence of length N and Q requests. Each request consists of a number, and the answer indicates whether that number exists in the sequence. 1 <= N, Q <= 10^5, abs(a[i]) <= 10^9....

## Power of number

Problem Find the answer obtained by raising A to the power of B, modulo the prime number 10^9+7. Here, A and B are both less than or equal to 10^13. We can find this using a simple loop. In other words, the number A is multiplied by B times, and we are talking about 10^13 times. How much action is that in general? A lot, and if you imagine that 300 million operations are performed in 1 second, then it will work for more than 9 hours....

## Basic data structure

C++ has many simplified data structures that we don’t need to write ourselves, and let’s talk about them. At first, I will write about what they do, what their structure is, and then I think I will write the code for all of them myself and how they work. Array About Array. An Array can be thought of as a container that can hold many things. Currently we only store 1 value in 1 variable, so what if we need to store 2000 variables?...

## Recursion

About recursion. We have seen about functions in previous post is. So what happens if the function calls itself? This is called a recursive function. For example int sum(int a, int b) { return sum(a, b); } Let’s look at the function. sum takes 2 variables and returns an int value. But what will happen if he called himself inside? Of course it will run indefinitely and I certainly don’t want that....

## Step by Step Programming - C

How to learn programming? In my experience, I have familiarized myself with the basics of programming and understand the fundamental concepts, then I start solve competitive programming problems. To begin with, it’s recommended to focus on learning the fundamentals of C and C++ programming languages, as they provide a solid foundation. As I mentioned earlier, problem-solving skills are paramount. Platforms like Hackerrank, Codeforces, and Codechef are excellent resources to enhance your problem-solving abilities....

## Intro

In this blog, I will share my knowledge with anyone interested in algorithm, programming. I enjoy solving problems and will include algorithm lessons starting from the basic level to ensure clarity for everyone. If you have any questions, please leave a comment. In the future, I have plans to explore beautiful problems and their analysis. Additionally, I have plans to write about technology and discuss various software engineering problems.