In this program, we will make a python program to calculate the GCD of two numbers using recursion. GCD stands for the greatest common divisor. Sometimes, they can ask you to write a program for HCF of two numbers, so don’t worry about this because…
In this Calculator program in C using a switch case, we will perform arithmetic operations (i.e., addition, subtraction, multiplication, and division) between two numbers in c language using a switch case and do-while loop. Calculator program in C using switch case In this post, we will…
In this program, we are going to make a simple python program that will add two numbers with user input. We will take numbers from users or else we can also hard code values. Pre-requisite: Syntax to print Output in python I am using f-string to…
In this program, we will reverse a linked list using recursion. Whenever you solve a problem using recursion, then please think about the following things: Pre-requisite: Linked Lists Data Structure in C++ Reverse a Linked List using Recursion in C++ In this program, our base…
In this program, we are going to make pattern in c programming using loops. It gives us a better understanding of the implementation of loops. Pre-requisite: For/While loop Half Pyramid Pattern in C In this program, we will print half pyramid of numbers. 1 1…
I will share the best resources to learn data structures and algorithms in this post.Resources will be mostly the videos playlist on YouTube, and once you are done with the videos, start solving questions of that topic on leetcode so that you get a clear…
Dwight is always bragging about how amazing he is at solving complicated problems with much ease. Jim got tired of this and gave him an interesting problem to solve. Jim gave Dwight a sequence of integers a1, a2, …, an and q queries x1, x2, …, xq on…
#include<bits/stdc++.h>using namespace std;void BulidTree(int * arr,int start,int end,int i,int * tree){ if(start==end) { tree[i]=arr[start]; return; } int mid=start+(end-start)/2; BulidTree(arr,start,mid,2*i,tree); BulidTree(arr,mid+1,end,(2*i)+1,tree); tree[i]=min(tree[2*i],tree[(2*i)+1]); }int query(int * tree,int start,int end,int i,int left,int right){ //completely outside given range if(start>right||end<left) return INT_MAX; //completely inside given range if(start>=left&& end<=right) return tree[i];…
int dp[501][501]; bool isPalindrome(string str,int i,int j) { while(i<=j) { if(str[i]!=str[j]) return false; i++; j–; } return 1; } int solve(string str,int i,int j) { if(i>=j) return 0; if(dp[i][j]!=-1) return dp[i][j]; if(isPalindrome(str,i,j)) return 0; int mn=INT_MAX; for(int k=i;k<j;k++) { int left,right; if(dp[i][k]!=-1) left=dp[i][k]; else left=solve(str,i,k);…
In this post, we are going to make a palindrome program in c++ using for loop and recursion. We will make a program that will check whether the given word or sentence is a palindrome or not. A palindrome is a word, number, phrase, or…