Found 26504 Articles for Server Side Programming

Difference between !== and ==! operator in PHP

Mahesh Parahar
Updated on 13-Jan-2020 06:33:04

547 Views

'!==' comparison operator'!==' operator checks the unequality of two objects with a type check. It does not converts the datatype and makes a typed check.For example 1 !== '1' will results true.'==!' comparison operator'==!' operator is combination of two operators and can be written as == (!operands).ExampleFollowing example, shows usage of '!==' vs '==!' operators. Live Demo    PHP Example     Output$x !== operator $y = bool(true) $x ==! operator $y = bool(true)

Difference between float and double in C/C++

Mahesh Parahar
Updated on 24-Feb-2020 08:04:39

2K+ Views

As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them.In simple words it could be state that double has 2x more precision as compare than float which means that double data type has double precision than as compare to that of float data type.In terms of number of precision it can be stated as double has 64 bit precision for floating point ... Read More

Difference between Structure and Array in C

Mahesh Parahar
Updated on 25-Feb-2020 07:13:01

7K+ Views

In C both Structure and Array are used as container for data types i.e in both structure and array we can store data and also can perform different operations over them.On the basis of internal implementation following are some basic differences between both.Sr. No.KeyStructureArray1DefinitionStructure can be defined as a data structure used as container which can hold variables of different types.On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.2Memory AllocationMemory allocation for input data in structure does not necessary to be ... Read More

Difference between strlen() and sizeof() for string in C Program

Mahesh Parahar
Updated on 25-Feb-2020 06:57:24

322 Views

As we know that in programming string can be defined as the collection of characters. Now for the requirement of finding how many characters are being used to create a string, C provides two approaches which are strlen() and sizeof().As mentioned in above point both of these methods are used to find out the length of target operand but on the basis of their internal implementation following are some basic differences between both.Sr. No.Keystrlen()sizeof()1Definitionstrlen() is a predefined function defined in a Header file named string.h in C.On other hand sizeof() is a Unary operator and not a predefined function.2Implementationstrlen is ... Read More

Maximum path sum in an Inverted triangle in C++

Narendra Kumar
Updated on 03-Jun-2020 08:27:16

191 Views

In this problem, we are given numbers in the form of an inverted triangle. Our task is to create a program that will find the maximum path sum in an inverted triangle.Inverted triangle form of number is an arrangement when the first row contains n elements, second n-1, and so on.Here, we have to find the maximum sum that can 3 be obtained by adding one element from each row.Let’s take an example to understand the problem −Input  −5 1 9  3 6   2Output − 17Explanation − Here, I have found the path from the last row to the ... Read More

Maximum path sum in a triangle in C++

Narendra Kumar
Updated on 03-Jun-2020 08:29:07

377 Views

In this problem, we are given numbers that are in the form of a triangle. Our task is to create a program that will find the maximum path sum in a triangle.The elements are arranged starting from the 1st row with 1 one element and then next rows with an increasing number of elements till there are elements in the nth row.So, the program will find the path that will provide the maximum sum of elements in the triangle. So, we have to find the path that will provide the maximum sum.Let’s take an example to understand the problem −Input ... Read More

Maximum Path Sum in a Binary Tree in C++

Narendra Kumar
Updated on 03-Jun-2020 08:35:04

298 Views

In this problem, we are given a binary tree with each node containing a value. Our task is to create a program to find the maximum path sum between two leaves of a binary tree.Here, we have to find the path form one leaf node to another leaf node that will provide the maximum sum of values. This maximum sum path can/cannot include the root node.Binary Tree is a tree data structure in which each node can have a maximum of two child nodes. These are called a left child and right child.Example −Let’s take an example to understand the ... Read More

Maximum OR sum of sub-arrays of two different arrays in C++

Narendra Kumar
Updated on 10-Jan-2020 08:04:03

210 Views

Problem statementGiven two arrays of positive integers. Select two sub-arrays of equal size from each array and calculate maximum possible OR sum of the two sub-arrays.ExampleIf arr1[] = {1, 2, 4, 3, 2} andArr2[] = {1, 3, 3, 12, 2} then maximum result is obtained when we create following two subarrays −Subarr1[] = {2, 4, 3} andSubarr2[] = {3, 3, 12}AlgorithmWe can use below formula to gets result −f(a, 1, n) + f(b, 1, n)Example Live Demo#include using namespace std; int getMaximumSum(int *arr1, int *arr2, int n) {    int sum1 = 0;    int sum2 = 0;    for ... Read More

Maximum number of Unique integers in Sub- Array of given sizes in C++

Narendra Kumar
Updated on 03-Jun-2020 08:38:55

309 Views

In this problem, we are given an array of size n and a number M. Our task is to create a program that will find the maximum number of unique integers in Sub-array of given size.Here, we will have to find the sub-array of size M that has the maximum number of unique elements.Let’s take an example to understand the problem, Input − array = {4, 1, 2, 1 , 4, 3}. M = 4Output − 4Explanation −All possible combinations of sub-arrays of size 4. {4, 1, 2, 1} = 3 unique elements {1, 2, 1, 4} = 3 unique ... Read More

Maximum number of fixed points using at most 1 swaps in C++

Narendra Kumar
Updated on 10-Jan-2020 07:58:37

193 Views

Problem statementGiven a permutation of N elements from 0 to N-1. A fixed point is an index at which the value is same as the index i.e. arr[i] = i. You are allowed to make at most 1 swap. Find the maximum number of fixed points that you can get.ExampleIf input array is {0, 1, 2, 3, 4, 6, 5} then answer is 7.To adjust fixed point, we have to swap 6 and 5After this entire array becomes fixed point and maximum value of fixed point is 7.AlgorithmCreate an array pos which keeps the position of each element in the ... Read More

Advertisements