Server Side Programming Articles - Page 1385 of 2650

Find ways an Integer can be expressed as sum of n-th power of unique natural numbers in C++

Hafeezul Kareem
Updated on 29-Dec-2020 10:47:42

526 Views

In this tutorial, we are going to write a program that find the number of ways a integer can be expressed as sum of given n-th power of unique numbers.We have two integers number and power. And we need to find in how many ways can we represent the given number as sum of n-th power of unique natural numbers. Let's see an example.Input − number = 50, power = 2Output − 3There is only possible way we can write 4 as sum of 2 powers.We will be using recursion to solve the problem. Let's see the steps to solve ... Read More

Find unique pairs such that each element is less than or equal to N in C++

Hafeezul Kareem
Updated on 29-Dec-2020 10:43:17

135 Views

In this tutorial, we are going to learn how to find the unique pairs that are less than the given number n.Let's see the steps to solve the problem.Initialize the number.Iterate from i = 1 to i < n.Iterate from j = i + 1 to j < n.Print the (i, j).ExampleLet's see the code. Live Demo#include using namespace std; void uniquePairs(int n) {    for (int i = 1; i < n; ++i) {       for (int j = i + 1; j < n; j++) {          cout

Find Union and Intersection of two unsorted arrays in C++

Hafeezul Kareem
Updated on 29-Dec-2020 10:42:05

803 Views

In this tutorial, we are going to learn how to write a program for union and intersection of two unsorted arrays. Let's see an example.Input arr_one = [1, 2, 3, 4, 5] arr_two = [3, 4, 5, 6, 7]Output union: 1 2 3 4 5 6 7 intersection: 3 4 5Let's see the steps to solve the problem.UnionInitialize the two arrays with random values.Create an empty array called union_result.Iterate over the first array and add every element to it.Iterate over the section array and add element if it is not present in union_result array.Print the union_result array.IntersectionInitialize the two arrays with random ... Read More

Find two numbers with sum and product both same as N in C++ Program

Hafeezul Kareem
Updated on 29-Dec-2020 10:38:11

252 Views

In this tutorial, we are going to write a program to find two numbers where x + y = n and x * y = n. Sometimes it's not possible to find those types of numbers. We'll print None if there are no such numbers. Let's get started.The given numbers are the sum and products of a quadratic equation. So the number doesn't exist if n2 - 4*n

Find total number of distinct years from a string in C++ Program

Aman Kumar
Updated on 07-Aug-2025 16:06:02

737 Views

In this article, we will write a C++ program to find the total number of distinct years from a string. Here, we have a string that contains the words and the dates. Our task is to find the number of distinct years mentioned. Let's see the following example scenario to understand the problem better: Scenario 1 Input: str = "The Berlin Wall fell on 09/11/1989. The first website was launched on 06/08/1991." Output: Total number of distinct years: 2 Explanation: Two distinct years are referenced: 1989, and 1991 Scenario 2 Input: str = "TutorialsPoint India was founded on ... Read More

Find time taken for signal to reach all positions in a string - C++

Hafeezul Kareem
Updated on 29-Dec-2020 10:30:07

149 Views

In this tutorial, we are going to write a program that computes the time taken for a signal to reach all positions in a string. Let me explain it with an example.We will have a string that contains only s and p characters. s is a signal and p is a position in the string. A signal starts at s and travels in both left and right directions. We are assuming it takes one unit of time to travel to the next position in the string. Our task is to compute the time needed to convert all positions into signals.Let's ... Read More

Find three integers less than or equal to N such that their LCM is maximum - C++

Hafeezul Kareem
Updated on 29-Dec-2020 10:27:54

540 Views

In this tutorial, we are going to write a program that is based on the concepts of LCM. As the title says, we have to find three numbers that are less than or equal to the given number whose LCM is maximum.Let's see an example.Before diving into the problem let's see what LCM is and write program for it.LCM is the least common multiple of a number. It is also known as Least common divisor. For two positive number a and b, the LCM is the smallest integer that is evenly divisible by both a and b.If the given integers ... Read More

Python - Add Label to kivy window

Pradeep Elance
Updated on 28-Dec-2020 11:25:51

696 Views

Kivy is an pen source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. It is used to develop the Android application, as well as Desktops applications. In this article we will see how to add labels to the windows created through Kivy.Creating LabelIn the below example we create a window and give it a custom label by using Label function available in uix.lable module. Once we run the app with this code we get the new window showing the custom label.Examplefrom kivy.app import App from kivy.uix.label import Label class ... Read More

Python - Combine two lists by maintaining duplicates in first list

Pradeep Elance
Updated on 28-Dec-2020 11:22:16

425 Views

In data analysis using python we may come across situation when two lists need to be merged. But it may be a challenge to handle the duplicate elements present in those lists. In this article we will see how to combine two lists by maintain all the elements form the first list and only the unique elements from the second list.Using extendIn this approach we take the first list and create a result list. Then we design a for loop to check for the presence of element of the first list in the second list and if the element is ... Read More

Python - Convert 1D list to 2D list of variable length

Pradeep Elance
Updated on 28-Dec-2020 11:20:56

3K+ Views

A list in python is normally a 1D list where the elements are listed one after another. But in a 2D list we have list nested inside the outer list. In this article we will see how to create a 2D list from a given 1D list. We also supply the values for the number of elements inside the 2D list to the program.Using append and indexIn this approach we will create a for loop to loop through each element in the 2D list and use it as an index for the new list to be created. We keep incrementing ... Read More

Advertisements