Given an unsorted array arr[] and two numbers x and y, find the minimum distance between x and y in arr[]. The array might also contain duplicates. You may assume tha...

Share

Given an unsorted array and a number n, find if there exists a pair of elements in the array whose difference is n.
Examples:
Input: arr[] = {5, 20, 3, 2, 50, 80}, n...

Share

Given an array of size n, the array contains numbers in range from 0 to k-1 where k is a positive integer and k <= n. Find the maximum repeating number in this arr...

Share

Given a string, find the first non-repeating character in it. For example, if the input string is “GeeksforGeeks”, then output should be ‘f...

Share

Write a program to find sum of positive integers without using any operator. Only use of printf() is allowed. No other library function can be used.
Solution
It ...

Share

Find the length of a string without using any loops and string.h in C. Your program is supposed to behave in following way:
Enter a string: GeeksforGeeks (Say user e...

Share

Given a binary tree, find height of it. Height of empty tree is 0 and height of below tree is 3.
Example Tree
Recommended: Please solve it on “PRACTICE ...

Share

Given root of binary search tree and K as input, find K-th smallest element in BST.
For example, in the following BST, if k = 3, then output should be 10, and if k =...

Share

We can find size of an array using sizeof operator as shown below.
// Finds size of arr[] and stores in 'size'
int size = sizeof(arr)/sizeof(arr[0]);
Can w...

Share

If inverse of a sequence follows rule of an A.P i.e, Arithmetic progression, then it is said to be in Harmonic Progression.In general, the terms in a harmonic progres...

Share