Found 26504 Articles for Server Side Programming

Find the Number of Reflexive Relations on a Set using C++

Prateek Jangid
Updated on 24-Nov-2021 11:20:05

511 Views

In this article, we will explain the approaches to find the number of reflexive relations on a set. In this problem, we are given with number n, and on a set of n natural numbers, we must determine the number of reflexive relations.Reflexive Relation − A relation in a set A is called reflexive if ( a, a ) belongs to R for every 'a' belongs to set A. For example −Input : x = 1 Output : 1 Explanation : set = { 1 }, reflexive relations on A * A : { { 1 } } Input ... Read More

Find the Number of quadruples where the first three terms are in AP and last three terms are in GP using C++

Prateek Jangid
Updated on 24-Nov-2021 11:16:28

128 Views

In this article, we will describe every possible approach to find the number of quadruples in which the first 3 terms are in A.P., and the last 3 are in G.P. First, we will explain the basic definition of arithmetic progression(A.P.) and geometric progression (G.P.).Arithmetic progression(A.P.) − It is a sequence of numbers in which the common difference (d) is the same or constant that means a difference of two consecutive numbers is constant. For example: 1, 3, 5, 7, 9 | d = 2Geometric Progression(G.P.) − It is a sequence of numbers in which the common ratios (r) are ... Read More

Find the Number of Quadrilaterals Possible from the Given Points using C++

Prateek Jangid
Updated on 24-Nov-2021 11:12:38

438 Views

A quadrilateral forms a polygon with four vertices and four edges in Euclidean plane geometry. The name 4-gon etc. Included in other names of quadrilaterals and sometimes they are also known as a square, display style, etc.In this article, we will explain the approaches to finding the number of quadrilaterals possible from the given points. In this problem, we need to find out how many possible quadrilaterals are possible to create with the provided four points ( x, y ) in the cartesian plane. So here is the example for the given problem −Input : A( -2, 8 ), B( ... Read More

Find the Number of Primes In A Subarray using C++

Prateek Jangid
Updated on 24-Nov-2021 11:08:25

245 Views

In this article we will describe the ways to find the number of primes in a subarray. We have an array of positive numbers arr[] and q queries having two integers that denote our range {l, R} we need to find the number of primes in the given range. So below is an example of the given problem −Input : arr[] = {1, 2, 3, 4, 5, 6}, q = 1, L = 0, R = 3 Output : 2 In the given range the primes are {2, 3}. Input : arr[] = {2, 3, 5, 8 ... Read More

Find the Number of Prime Pairs in an Array using C++

Prateek Jangid
Updated on 24-Nov-2021 11:03:12

325 Views

In this article, we will explain everything about finding the number of prime pairs in an array using C++. We have an array arr[] of integers, and we need to find all the possible prime pairs present in it. So here is the example for the problem −Input : arr[ ] = { 1, 2, 3, 5, 7, 9 } Output : 6 From the given array, prime pairs are (2, 3), (2, 5), (2, 7), (3, 5), (3, 7), (5, 7) Input : arr[] = {1, 4, 5, 9, 11} Output : 1Approaches to Find ... Read More

Find the Number of Prefix Sum Prime in Given Range Query using C++

Prateek Jangid
Updated on 24-Nov-2021 08:03:58

265 Views

In this article, we need to find a number of prefix sum which are prime numbers in a given array arr[ ] of positive integers and range query L, R, where L is the initial index value arr[ L ] for prefixsum[ ] array and R is the number of prefix sum we need to find.To fill the prefix sum array, we start with index L to index R and add the present value with the last element in the given array. So here is the Example for the problem −Input : arr[ ] = { 3, 5, 6, 2, ... Read More

Node.js – Timers Module – Cancelling Timers

Mayank Agarwal
Updated on 24-Nov-2021 07:36:33

458 Views

A timer can only be cancelled after it is being scheduled. The Immediate class has an object for setImmediate() method and passes the same object to clearImmediate(), in case it wants to cancel the scheduled timer function.Scheduling TimersThis type of timers schedules the task to take place after a certain instant of time.setImmediate()setInterval()setTimeout()Cancelling TimersThis type of timers cancels the scheduled tasks which is set to take place.ClearImmediate()clearInterval()clearTimeout()1. clearImmediate() methodThis method clears the Immediate timer object that is created by the setImmediate() method.SyntaxclearImmediate( timer )Examplefilename - clearImmediate.js// clearImmediate() Example var timer = setImmediate(function A() {    console.log("Timer set"); }); ... Read More

Find the Number of Possible Pairs of Hypotenuse and Area to Form Right Angled Triangle using C++

Prateek Jangid
Updated on 24-Nov-2021 07:57:31

226 Views

In this article, we will explain how to solve the number of possible pairs of hypotenuse and area form a right-angled triangle in C++.We need to determine the number of all possible pairs of a hypotenuse and the area ( H, A ) to form a right-angled triangle with H as hypotenuse and A as Area.In this example −         x = Base of Right Angled Triangle         y = Height of Right Angled Triangle         H = hypotenuse of Right Angled TriangleWe know Area of right angled triangle, A = ( x * ... Read More

Find the Number of permutation with K inversions using C++

Prateek Jangid
Updated on 24-Nov-2021 07:36:22

453 Views

In an array, A pair a[i], a[j] is known as an inversion if a[i] > a[j] and i < j. We have two numbers N and k, and need to figure out how many possible permutations of the first N numbers end in a perfect K inversion. So here is the example −Input: N = 4, K = 1 Output: 3 Explanation: Permutation of the first N numbers in total : 1234, 1243, 1324 and 2134. With 1 inversion we have 1243, 1324 and 2134. Input : N = 3, K = 2 Output : 3 Explanation: Permutation of ... Read More

Using Redis Cache with Spring Boot

Mayank Agarwal
Updated on 24-Nov-2021 07:34:57

6K+ Views

In this article, we will see how to integrate Redis Cache with Spring Boot. We will learn how we can configure Redis data inside the Spring boot cache.Let's look at the dependencies first that are required to import Redis into a Spring boot application.Dependencies// Adding spring-boot cache & redis dependencies    org.springframework.boot    spring-boot-starter-cache    2.4.3    org.springframework.boot    spring-boot-starter-data-redis    2.4.3 ConfigurationAfter adding the Redis dependencies, you now need to perform some configuration so that it could be used in your project. Spring Boot will automatically configure a Redis-cache Manager but with default properties. We can ... Read More

Advertisements