Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Programming Articles
Page 153 of 2544
How to increase the X-axis length of histogram in base R?
To increase the X-axis length of histogram in base R, we can use the axis function. The most important thing to remember while using the axis function is mentioning the appropriate sequence based on the values in the vector or in the column of the data frame if a data frame is used.Examplex
Read MoreFind letter's position in Alphabet using Bit operation in C++
In this problem, we are given a string str consisting of english alphabets. Our task is to find the letter's position in the Alphabet using the Bit operation. Problem Description: Here, we will return the position of each character of the string as it is in english alphabets.The characters of the string are case-insensitive i.e. “t” and “T” are treated the same.Let’s take an example to understand the problem, Input: str = “Tutorialspoint”Output: 20 21 20 15 18 9 1 12 19 16 15 9 14 20 Solution ApproachA simple solution to find a character's position is by finding its logical AND operation with 31.Program ...
Read MoreHow to set the plot area to assign the plots manually in base R?
We can split the screen to assign the plots manually in the plot area. The split.screen function can be used for this purpose. For example, if we want to create 4 plots in the plot window then we can use split.screen(c(2, 2)). Now to create the plot in first screen the command will be screen(1) then plot will be created. If we again create the plot then the original plot in screen(1) will be replaced with the new one. To create the plot in 3rd screen that is screen(3), we first need to use the command screen(3) and then create ...
Read MoreFind longest length number in a string in C++
In this problem, we are given a string str consisting of character and alphabets only. Our task is to find the longest length number in a string. Problem Description: we need to find the length of the number i.e. consecutive numerical characters in the string.Let’s take an example to understand the problem, Input: str = “code001tutorials34124point”Output: 34124Explanation: Numbers in the string are001 - size 334124 - size 5Solution ApproachA simple solution to the problem is by traversing the sting and finding the number’s length and its starting index. We will store the starting position and count of characters in the string for each number ...
Read MoreFind M-th number whose repeated sum of digits of a number is N in C++
In this problem, we are given two positive numbers N and M. Our task is to find the M-th number whose repeated sum of digits of a number is N. Problem description: Here, we need to find the Mth number whose sum of digits till the sum becomes single digit is equal to N.Let’s take an example to understand the problem, Input: N = 4 M = 6Output: 49Solution ApproachA simple solution of the problem, is by finding all numbers and count the number whose sum of digits is N, and return m-th number.Another solution to the problem is using formula to find M-th ...
Read MoreFind m-th smallest value in k sorted arrays in C++
In this problem, we are given k different arrays of different sizes. Our task is to find m-th smallest value in k sorted arrays. Problem Description: Here, we need to find m-th smallest element of the merged array of all k arrays.Let’s take an example to understand the problem, Input: m = 4 arr[][] = { {4 , 7}, {2, 5, 6}, ...
Read MoreFind m-th summation of first n natural numbers in C++
In this problem, we are given two integers m and n. Our task is to Find m-th summation of the first n natural numbers. Problem Description: we will find sum of sum of n natural numbers m times. The sum is given by the formula, if (m > 1), sum(n, m) = sum( sum(n, (m-1)), 1 )if (m = 1) sum(n, m) = sum(n, 1) = sum of n natural numbersLet’s take an example to understand the problem, Input: m = 4, n = 2Output: 231Explanation: sum(2, 4) = sum ( sum(2, 3), 1 ...
Read MoreFind max of two Rational numbers in C++
In this problem, we are given two Rational Numbers. Our task is to find max of two Rational numbers. Here, the rational numbers are in the form of p/q.Let’s take an example to understand the problem, Input: rat1 = 5/4, rat2 = 3/2Output: 3/2Explanation: 5/4 = 1.253/2 = 1.5Solution Approach −A simple solution to the problem is by using a method similar to the one we used to perform in school.For this, we will find the L.C.M of the denominator. And then multiply the numerator based on the denominators value. Then for the common denominator, the rational number with maximum numerator value is the ...
Read MoreFind maximum (or minimum) in Binary Tree in C++
In this problem, we are given a binary tree. Our task is to Find maximum (or minimum) in Binary Tree. Problem Description: We need to find the nodes of the binary tree that have maximum and minimum value in the binary tree.Let’s take an example to understand the problem, Input: Output: max = 9 , min = 1Solution ApproachWe need to find the max node of the binary tree. We will do this by traversing the pointer until we reach the leaf node and then find the maximum node of the tree.Program to illustrate the working of our solution, Example#include using namespace std; ...
Read MoreFind maximum (or minimum) sum of a subarray of size k in C++
In this problem, we are given an array arr[] and a number k. Our task is to Find the maximum (or minimum) sum of a subarray of size k. Let’s take an example to understand the problem, Input: arr[] = {55, 43, 12, 76, 89, 25, 99} , k = 2Output: 165Explanation:The subarray of size 2 has sum = 76 + 89 = 165Solution ApproachA simple approach to solve the problem is by finding all k sized subarrays and then return the sum with maximum value.Another Approach is using the sliding window, we will find the sum of k sized subarrayes. For this, the ...
Read More