Card image cap
C++ program to add the two matrices

C++ Program to add the matrices is given below. Here we will first define the size of the input matrices and then will add the both matrices using 'add' method and will store their result in the third matrix

Card image cap
PHP Program to reverse an array | array_reverse()

array_reverse() is an inbuilt function of PHP used to reverse the array including the nested arrays. It returns the reversed array. But in the case of associative arrays of if you don't want to change the keys of the array, $key_preserve=true can be passed as a parameter to the array_reverse() function.

Card image cap
array_sum() function | PHP

The array_sum() function is an inbuilt function in PHP. This function is used to calculate the sum of the elements of an array.

Card image cap
C++ Program to find Maximum Product Subarray

In this question an array of positive and negative integers is given to you. You have to find the maximum product of subarray. C++ complete program to get the maximum product subarray is given below.

Card image cap
C++ Program to find the Majority element of the Array

C++ Program to find the majority element of the array is given below. The element which occurs more than n/2 times in the array is said to be the majority element. Approach is very simple count the occurrence of each element and then check if it is occurred more than n/2 times or not.

Card image cap
C++ Program to find the element occurring Odd number of times

C++ Program to find the element occurring Odd number of times is given below. Approach is simple we use the concept of hashing where element would be key and the its frequency (number of occurrence) will be value. Then we will check if the value to the key is odd or not.

Card image cap
C++ Program to find the smallest index of the repeated element

Find the first index of the repeated element in an array of integers, i.e., an element that occurs more than once and whose index of first occurrence is smallest.

Card image cap
C++ Program to find the Common Elements in Three Arrays

C++ Program to find out the common elements in the given three arrays is given below. Approach is simple we hashed the occurrence of the elements of first two arrays and then we will match if the element of array 3 is present in array 1 and array 2 or not.

Card image cap
C Program to traverse a matrix in spiral order

C Program to traverse a matrix in spiral order is given below. The program is compiled and checked successfully output is also given below the program. This question has been asked in the interview of many tech giants like Oracle, Microsoft, DE Shaw etc..

Card image cap
Program to rotate an array to the left by N elements

This program will rotate an array to the left by n elements. It will take an input n to which number it will rotate the array to the left. C++ Implementation is here.