Server Side Programming Articles - Page 1823 of 2650

Power of a prime number r in n! in C++

sudhir sharma
Updated on 17-Apr-2020 06:49:39

230 Views

In this problem, we are given two integer n and r. Our task is to find the power of the given prime number r in the factorial of the number n.Let’s take an example to understand the problemInput − n = 6 r = 2Output − 4Explanation −Factorial n, 6! = 6*5*4*3*2*1 = 720 720 = 24 * 32 * 5, power of 2 is 4To solve this problem, a simple solution would be directly finding the factorial and then finding the power of the prime number. But this is not the best solution.Another efficient solution is using a formula, ... Read More

Power Set in Lexicographic order in C++

sudhir sharma
Updated on 17-Apr-2020 06:46:51

775 Views

In this problem, we are given string str. Our task is to print the power set of this string’s elements in lexicographical order.Power Set − The power set of a set is the set of all subsets of the set. Denoted by P(S) where s is the set.Example −S = {1, 2, 3} ; p(S) = {{}, {1}, {1, 2}, {1, 3}, {2}, {2, 3}, {3}, {1, 2, 3}}In this problem, we will treat the string as a set. So, its characters will be the elements of the set.Let’s take an example to understand the problemInput − str = “xyz”Output ... Read More

Powers of 2 to required sum in C++

sudhir sharma
Updated on 17-Apr-2020 06:43:33

689 Views

In this problem, we are given an integer N. Our task is to print the number which when raised to the power of 2 gives the number.Let’s take an example to understand the problemInput − 17Output − 0, 4Explanation − 17 = 24 + 20 = 16 + 1To solve this problem, we will divide the number with 2 recursively. By this method, every number can be represented as a power of 2. This method is used to convert the number to its binary equivalent.ExampleThe program to show the implementation of our solution Live Demo#include using namespace std; void sumPower(long ... Read More

Powers of two and subsequences in C++

sudhir sharma
Updated on 17-Apr-2020 06:41:39

220 Views

In this problem, we are given an array of N integers. Our task is to find the count of subsequences that can be formed such that if their elements are multiplied, they result in a number which is a power of two.Let’s take an example to understand the problem, Input − arr = [2, 5, 4]Output − 3Explanation − subsequences [2], [4] and [2, 4] give the desired result.To solve this problem, we need to understand the logic of power.Only those numbers with are powers of 2 will multiply to give the desired result. So, we have to consider only ... Read More

Difference between Python and Bash

Mahesh Parahar
Updated on 16-Apr-2020 06:20:19

1K+ Views

PythonPython is a programing language designed to be simple to implement and easy to understand. It is a dynamically typed language. It is not using pointers.BashBash is a command-line interpreter and is shipped by default in Linux and MacOS operating systems. It can be installed in other operating systems as well. It is default User Shell for Linux and MacOS.The following are some of the important differences between Python and Bash.Sr. No.KeyPythonBash1TypePython is a programming language mostly used in automation programming.Bash is a command-line interpreter or user shell to interpret user commands.2BasisPython is developed as an easy to implement an ... Read More

map::at() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:58:18

439 Views

In this article we will be discussing the working, syntax and examples of map::at() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::at()?map::at() function is an inbuilt function in C++ STL, which is defined in  header file. at() is used to access a ... Read More

map::size() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:56:27

8K+ Views

In this article we will be discussing the working, syntax and examples of map::size() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::size()?map::size() function is an inbuilt function in C++ STL, which is defined in  header file. size() is used to check the ... Read More

map::empty() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:51:44

537 Views

In this article we will be discussing the working, syntax and examples of map::empty() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::empty()?map::empty() function is an inbuilt function in C++ STL, which is defined in  header file. empty() is used to check whether ... Read More

map::begin() and end() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:48:05

823 Views

In this article we will be discussing the working, syntax and examples of map::begin() and map::end() functions in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::begin()?map::begin() function is an inbuilt function in C++ STL, which is defined in  header file. begin() is used to ... Read More

map::at() and map::swap() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:45:24

596 Views

In this article we will be discussing the working, syntax and examples of map::at() and map::swap() functions in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::at()?map::at() function is an inbuilt function in C++ STL, which is defined in  header file. at() is used to ... Read More

Advertisements