Given three strings D, M, and Y representing a date. The task is to check whether concatenation of date and month results in the same digits as of the year. Examples:Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a […]

Continue ReadingGiven a positive integer N, the task is to check whether all the digits of the given integer N are the same or not. If found to be true, then print Yes. Otherwise, print No.Examples:Input: N = 222Output: YesInput: N = 232Output: NoNaive Approach: The simplest approach to solve the given problem is to iterate […]

Continue ReadingGiven a matrix mat[][] of size N×N where two elements of the matrix are ‘1’ denoting the coordinate of the rectangle and ‘0’ denotes the empty space, the task is to find the other two coordinates of the rectangle.Note: There can be multiple answers possible for this problem, print any one of them.Examples: Input: mat[][] = […]

Continue ReadingGiven a sorted array arr[] of size N, the task is to print all the unique elements in the array.An array element is said to be unique if the frequency of that element in the array is 1.Examples:Input: arr[ ] = {1, 1, 2, 2, 3, 4, 5, 5}Output: 3 4Explanation: Since 1, 2, 5 […]

Continue ReadingProgram to calculate Kinetic Energy and Potential EnergyGiven three integers M, H, and V representing the mass, velocity, and height of an object respectively the task is to calculate its Kinetic Energy as well as its Potential Energy,Note: The value of acceleration due to gravity (g) is 9.8 and ignore units. Examples:Input: M = 25, […]

Continue Reading#include using namespace std; void crossProduct(int vect_A[], int vect_B[], int cross_P[]){ cross_P[0] = vect_A[1] * vect_B[2] – vect_A[2] * vect_B[1]; cross_P[1] = vect_A[2] * vect_B[0] – vect_A[0] * vect_B[2]; cross_P[2] = vect_A[0] * vect_B[1] – vect_A[1] * vect_B[0];} void checkCollinearity(int x1, int y1, int z1, int x2, int y2, int z2){ int A[3] = { x1, y1, z1 }; int B[3] = { x2, y2, z2 }; int cross_P[3]; crossProduct(A, B, cross_P); if (cross_P[0] == […]

Continue ReadingProgram to find the Magnitude of a VectorGiven three integers representing the X, Y, and Z coordinates of a 3-D vector, the task is to find the magnitude of that vector.Example:Input: X = 1, Y = 2, Z = 2Output: 3Explanation: Magnitude of the vector is equal to √9 =3Input: X = 0, Y = […]

Continue Reading