
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
Found 26504 Articles for Server Side Programming

316 Views
Suppose we have a string s, we have to make this string palindrome. in each step we can insert any character at any position, we have to find minimum number of characters that require to make this palindrome. If the string is like “mad”, then the answer will be 2 as we can add “da” before “mad”, or “am” after “mad” to make this palindrome.To solve this, we will follow these steps −Define a function lcs(), this will take s, x := sn := size of sreverse the string xs := concatenate space before s, x := concatenate space before ... Read More

291 Views
In this problem, we are given four numbers that define the totalPrice and the ratio of coins of 1 Rs, 50 paise, 25 paise in the bag. Our task is to create a program to find the count of coins of each type from the given ratio in C++.Code description − Here, we need to use the coins of 1 Rs, 50 paise, and 25 paise from the bag to give the total sum of coins to the given total.Let’s take an example to understand the problem, InputTotalPrice = 225, 1Rs = 2, 50P = 3, 25P = 4Output1 Rs ... Read More

177 Views
Suppose we have a m x n binary matrix mat. In one step, we can choose one cell and flip its bit and all the four neighbors of it if they are present. We have to find the minimum number of steps required to convert mat to a zero matrix. If there is no solution, then return -1.So if the given input is like [[0, 0], [0, 1]], alteration will be like −So we need 3 steps, the output will be 3.To solve this, we will follow these steps −n := number of rows, m := number of columns, x ... Read More

477 Views
In this problem, we are given a 2D array that denotes coordinates of three vertices of the triangle. Our task is to create a program to find the Centroid of the Triangle in C++.Centroid of a triangle is the point at which the three medians of the triangles intersect.Median of a triangle is the line that connects the vertex of the triangle with the center point of the line opposite to it.Let’s take an example to understand the problem, Input(-3, 1), (1.5, 0), (-3, -4)Output(-3.5, -1)ExplanationCentroid (x, y) = ((-3+2.5-3)/3, (1 + 0 - 4)/3) = (-3.5, -1)Solution ApproachFor solving ... Read More

259 Views
In this problem, we are given the three variables that denote total monthly expenditure (E), selling price (S) of the product, overhead maintenance (M) on each product. Our task is to create a program to find the Break Even Point in C++.Break-Even Point is the total number of products that are required to be sold so that there should not be any loss or profit for the seller.Problem Description − We need to find the total no. of products to be sold to make sure there is no loss.Let’s take an example to understand the problem, InputE = 2400, S ... Read More

226 Views
Suppose we have a string s that is containing lowercase letters and an integer k. We have to maintain some properties. These are −First, we have to change some characters (if needed) of s to other lowercase English letters.Then divide the string s into k substrings such that each substring is a palindrome.We have to find the minimal number of characters that we need to change to divide the string.So if the string is like “ababbc” and k = 2, then the answer will be 1, as we have to change one character to split this into two palindrome strings. ... Read More

661 Views
In this problem, we are given a number n that denotes that side of the pentagon. Our task is to create a program to find the Area of a Pentagon in C++.Pentagon is a five-sided geometric figure.Regular pentagon is a pentagon with all five sides and angles equal.Let’s take an example to understand the problem,Inputa = 7Output84.3Program to illustrate the working of our solution,Example Live Demo#include using namespace std; float calcpentagonArea(int a){ return ( ((6.8819)*a*a)/4); } int main() { int a = 7; cout

1K+ Views
Suppose we have a car, that starts at position 0 and speed +1 on an infinite number line. The car runs automatically according to a sequence of instructions A: for accelerate and R − for reverse. When we get an instruction "A", our car does the following −position := position + speed, then speed = speed * 2.When we get an instruction "R", our car does the following −if speed is positive then speed = -1, otherwise speed = 1.For example, after executing the instructions "AAR", our car goes to positions 0->1->3->3, and speed goes to 1->2->4->-1.Now suppose we have ... Read More

434 Views
In this problem, we are given two values that denote the base and height of a parallelogram. Our task is to create a Program to find the Area of a Parallelogram in C++.Parallelogram is a four side closed figure that has opposite sides equal and parallel to each other.Let’s take an example to understand the problem, InputB = 20, H = 15Output300ExplanationArea of parallelogram = B * H = 20 * 15 = 300Solution ApproachTo solve the problem, we will use the geometrical formula for area of parallelogram, Area = base * height.Program to illustrate the working of our solution, ... Read More

1K+ Views
Suppose we have a list of bus routes. In each routes[i] there is a bus route that the i-th bus repeats forever. So, if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the sequence 1, 5, 7, 1, 5, 7, 1, ... forever.Now suppose we start at bus stop S, initially not on a bus, and we want to go to bus stop T. we have to find the least number of buses we must take to reach our destination? If this is not possible then return -1.So if the input is like ... Read More