What are Wild Pointers? How can we avoid?
Uninitialized pointers are known as wild pointers because they point to some arbitrary memory location and may cause a program to crash or behave unexpectedly....
read more
Why Does C Treat Array Parameters as Pointers?
In C, array parameters are treated as pointers mainly to,...
read more
Find k pairs with smallest sums in two arrays | Set 2
Given two arrays arr1[] and arr2[] sorted in ascending order and an integer K. The task is to find k pairs with the smallest sums such that one element of a pair belongs to arr1[] and another element belongs to arr2[]. The sizes of arrays may be different. Assume all the elements to be distinct in each array. Examples:...
read more
C++ Program for Two Pointers Technique
Two pointers is really an easy and effective technique which is typically used for searching pairs in a sorted array.Given a sorted array A (sorted in ascending order), having N integers, find if there exists any pair of elements (A[i], A[j]) such that their sum is equal to X....
read more
Clockwise/Spiral Rule in C/C++ with Examples
The Spiral/Clockwise Method is a magic tool for C/C++ programmers to define the meaning of syntax declaration in the head within seconds. This method was created by David Anderson and here is a short brief about how to apply this method....
read more
Creating array of pointers in C++
An array of pointers is an array of pointer variables. It is also known as pointer arrays. We will discuss how to create a 1D and 2D array of pointers dynamically. The word dynamic signifies that the memory is allocated during the runtime, and it allocates memory in Heap Section. In a Stack, memory is limited but is depending upon which language/OS is used, the average size is 1MB....
read more
Rank of remaining numbers in Array by replacing first and last with max and min alternatively
Given an array arr[ ] of size N, the task is to find the rank of the remaining element in an array after performing the given operation:...
read more
How to declare a 2D array dynamically in C++ using new operator
Prerequisite: Array BasicsIn C/C++, multidimensional arrays in simple words as an array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order). Below is the general form of declaring N-dimensional arrays:...
read more
auto_ptr vs unique_ptr vs shared_ptr vs weak_ptr in C++
Prerequisite – Smart Pointers...
read more
Reduce the array such that each element appears at most 2 times
Given a sorted array arr of size N, the task is to reduce the array such that each element can appear at most two times....
read more
Java Program to Find a triplet such that sum of two equals to third element
Given an array of integers, you have to find three numbers such that the sum of two elements equals the third element....
read more
Minimal distance such that for every customer there is at least one vendor at given distance
Given N and M number of points on the straight line, denoting the positions of the customers and vendors respectively. Each vendor provides service to all customers, which are located at a distance that is no more than R from the vendor. The task is to find minimum R such that for each customer there is at least one vendor at the distance which is no more than R....
read more