Category Archives: Arrays

Questions regarding Arrays

Subsequence with maximum odd sum

Given a set of integers, check whether there is a subsequence with odd sum and if yes, then finding the maximum odd sum. If no subsequence contains odd sum, return -1. Examples: Input : arr[] = {2, 5, -4, 3, -1}; Output : 9 The subsequence with maximum odd sum is 2, 5, 3 and… Read More »

Find Duplicates of array using bit array

You have an array of N numbers, where N is at most 32,000. The array may have duplicates entries and you do not know what N is. With only 4 Kilobytes of memory available, how would print all duplicates elements in the array ?. Examples: Input : arr[] = {1, 5, 1, 10, 12, 10}… Read More »

Window Sliding Technique

This technique shows how a nested for loop in few problems can be converted to single for loop and hence reducing the time complexity. Let’s start with a problem for illustration where we can apply this technique – Given an array of integers of size ‘n’. Our aim is to calculate the maximum sum of… Read More »