Topic — Add New » Posts Last Poster Freshness
Leader of an Array 3 sheldoncooper 1 month

Given an array A of integers of size N, the [b]leader[/b] of the array is the element which occurs more than half of the size of the array times. i.e. if the array A={1,3,5,2,4,2,4,2,2,2} then the[b] leader of the array will not be 2 as it occurs exactly 5 times,[/b] thus it has to occur 6 or more times to be the leader.
Size of array can be from 0 to 10000
The array elements can range from 0 to 2147483647
Expected worst case running complexity=O(n)
Expected worst case...

find the element appearing n times in an array of 2n elements 17 Tyson 1 month

Given an array of 2n elements of which n elements are same and the remaining n elements are all different. Write a C program to find out the value which is present n times in the array

Global scholar interview question for QA... 2 kartik 2 months

An arrya contains nos from 0-n. But only one number is missing.instead one no repeats.find the repeating number in linear time without using any other data structures??

Swap 2 arrays of different size inplace 5 camster 2 months

2 arrays are stored contiguously in memory and sizes of both arrays are known. Swap the contents of both arrays . Initially, you only have the pointer to element 1 of array 1 .
eg if array 1 is 1234 and array 2 is 567 , they are stores in memory as 1234567.After swapping , it should become 5671234.

Balanced 0-1 matrix 3 3 months

Given an n*n matrix --->in how many ways we can fill n/2 0 and n/2 1 in each and every column....!!

Sort an array which is already sorted in two parts 8 3 months

Given an array with two subparts sorted. How will you make a final sorted array.

i/p:
1, 5, 7, 9, 11, 23, 2, 3, 8, 9, 21

o/p:
1, 2, 3, 5, 7, 8, 9, 9, 11, 21, 23

Algorithm to remove duplicates from array 1 learner 4 months

Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program?

Number of Comparisons! 2 Venki 7 months

How many comparisons are necessary to find the largest and smallest of a set of n distinct elements?
Let's discuss it for n = 10 and maybe we can generalize it from there.

Minimum missing number in array 1 saurabh 7 months

An array of size N. All the elements are positive (> 0). Find the minimum element, which is not present in the array.

Find the extent of rotation 8 jpchaandy 7 months

suppose you've two arrays arr1[N] and arr2[N] of integers. 'arr2' is cyclic right rotated version of arr1 by some unknown places 'k'. where it's known that 1 <= k <= N. you've to determine 'k'.

example-

arr1 = 1, 2, 3, 4, 5

arr2 = 3, 4, 5, 1, 2

you see, if you rotate right (cyclic) to arr1 by 3 places (thus, here, k == 3) then you'll find arr2. thus arr2 is cyclic right rotated (by 3 places) version of arr1.

complexities requirements-

time: O(N)...

Find n numbers that sum upto a given number 2 wgpshashank 7 months

eg:
Find a pair of numbers that sum up to zero (or any other number), then find three (and then four) numbers that sum up to zero .. so on

Find the number of blocks 6 Sambasiva 8 months

Given a matrix, you need to find the number of blocks in it. A block has the same numbers.
EG:
1 1 3
1 2 3
2 2 4
has 4 blocks namely,
1 1
1
2
2 2

3
3

4

1 2 3
4 5 6
7 8 9
has 9 blocks

1 1 1
1 1 3
4 4 5
has 4 blocks,
1 1 1
1 1

3

5

4 4

sort N decks of 52 playing cards 3 Kalyan.Nelluri 8 months

Write a function to sort N decks of 52 playing cards represented as an integer array with indexes from 0 to N*52 - 1. You are supplied a random generator that produces numbers from 0 to N - 1 for this task. What is the worst case runtime and memory bound?

Find a pair of close numbers 3 9 months

For a set S of n real numbers, a pair of elements x, y belong to S, where x < y, are said to be close if
y – x <= ( max(S) – min(S) ) / (n-1)
Suppose you are given an unsorted array A[1 : n] of distinct real numbers. Design an algorithm that finds a pair of close numbers in A in O(n) time.

Subset Sum 1 9 months

You are given an array of N integers. Now you want to find the sum of all those integers which can be expressed as the sum of at least one subset of the given array.
What can be the fastest way to do this?

Sizeof dynamic array 2 piyush 10 months

How can you find the sizeof a dynamically created array?

Eg: int *arr = (int *)malloc(sizeof(int)*int);

sizeof(arr) will give you 4 as arr pointer. Is there anything like finding the sizeof of int without using sizeof operator.