Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1462 of 3366
323 Views
In this tutorial, we are going to write a program that finds the total number of substrings that starts and ends with the given strings.We are given one string and two substrings. We need to find the different substrings count that starts and ends with the given two substrings. Let's see an example.Inputstr = "getmesomecoffee" start = "m" end = "e"Output6There are a total of 6 different substrings in the given string. They are me, mesome, mesomemecoffe, mesomemecoffee, mecoffe, mecoffee.Let's see the steps to solve the problem.Initialize the strings.Iterate over the str and find the start and end substrings indexes. ... Read More
363 Views
In this tutorial, we are going to write a program that finds different possible marks for the given n questions with positive and negative marking.Let's say we have 10 questions and each carries 2 marks for correct answers and -1 marks for a negative answer. Our aim is to find all the possible ways in which a student can score in the exam.Let's see the steps to solve the problem.Initialize the number of questions, positive marks for the correct answer and negative marks for the wrong answer.Initialize a set to store the possible marks.Write two inner loops from 0 to ... Read More
429 Views
In this tutorial, we are going to write a program that helps us to find whether the given matrix is diagonally dominant or not.The matrix is called a diagonally dominant matrix if the sum of elements in the matrix other than the diagonal element is less than the diagonal matrix. Let's see an example.421 352 247The above matrix is a diagonally dominant matrix. Because4 > 2 + 1 5 ≥ 3 + 2 7 > 4 + 2All the diagonal elements are greater than or equal to the sum of the non-diagonal elements in the same row.Let's see the steps ... Read More
204 Views
In this tutorial, we are going to learn how to find the diagonal of a regular pentagon.We have to find the length of the diagonal of the regular pentagon using the given side. The length of the diagonal of a regular pentagon is 1.22 * s where s is the side of the pentagon.ExampleLet's see the code. Live Demo#include using namespace std; float pentagonDiagonal(float s) { if (s < 0) { return -1; } return 1.22 * s; } int main() { float s = 7; cout
155 Views
In this tutorial, we are going to learn how to find the diagonal of a regular heptagon.We have to find the length of the diagonal of the regular heptagon using the given side. The length of the diagonal of a regular heptagon is 1.802 * s where s is the side of the heptagon.ExampleLet's see the code. Live Demo#include using namespace std; float heptagonDiagonal(float s) { if (s < 0) { return -1; } return 1.802 * s; } int main() { float s = 7; cout
146 Views
In this tutorial, we are going to learn how to find the position of a third person on a regular N-sided polygon.We have given a regular N-sided polygon. And there are two persons on two different points already. Our task is to find the third point to place the third person such that the distance between the first two persons and the third person is minimized.Let's see the steps to solve the problem.Initialize the N and two points A and B.Initialize the position of the third person, and the minimum sum to find the position.Iterate from 1 to N.If the ... Read More
6K+ Views
In this tutorial, we are going to learn how to find the determinant of a matrix.Let's see the steps to find the determinant of a matrix.Initialize the matrix.Write a function to find the determinant of the matrix.If the size of the matrix is 1 or 2, then find the determinant of the matrix. It's a straightforward thing.Initialize variables for determinant, submatrix, sign.Iterate from 1 to the size of the matrix N.Find the submatrix for the current matrix element.All the elements that are not in the current element row and columnAdd the product of the current element and its cofactor to ... Read More
149 Views
In this tutorial, we are going to learn about the deserium numbers with examples.The number whose sum of pow(digit, digitsCount) is equal to the given number is called Deserium number.Let's see the steps to find whether the given number is deserium number or not.Initialize the number.Find the digits count of the number.Initialize a variable to store the sum.Iterate until the number is less than 0.Get the last digit by diving the number with 10.Add the pow(digit, digitsCount) to the sum.If the sum is equal to the number, then it is deserium number else it is not.ExampleLet's see the code. Live Demo#include ... Read More
146 Views
In this tutorial, we are going to learn how to find the deepest odd level node in a binary tree.This is similar to finding the depth of the binary tree. Here, we have to one more condition i.e.., whether the current level is odd or not.Let's see the steps to solve the problem.Initialize the binary tree with dummy data.Write a recursive function to find the deepest odd level node in a binary tree.If the current node is a leaf node and the level is odd, then return the current level.Else return the max of left node and right node with ... Read More
1K+ Views
In this tutorial, we are going to learn how to find the depth of the n-ary tree.An n-ary tree is a tree in which each node of the tree has no more than n child nodes.We have to find the depth of the n-ary tree. We will be using the vector to store the children of each node in the tree.Let's see the steps to solve the problem.Initialize the tree with dummy data.Write a recursive function to find the depth of the n-ary tree.Initialize a variable to store the max depth of the tree.Iterate over the children of each node.The ... Read More