Given an array of characters, reverse the words in the sentence.
For example, if the sentence is "Reverse these words", then the output should be "words these reverse".
Source : this interview q
Showing posts with label array. Show all posts
Showing posts with label array. Show all posts
Find duplicates in an array
Given an array of size 'n', containing elements from 1 to 'n', find out if there are any duplicates in the array. Solve this, if
- a single duplicate number exists
- multiple duplicate numbers exist
Find subarray with maximum sum
Given an array of size n, containing positive and negative integers, find the longest sub-array such that the sum of the elements in the sub-array is the maximum.
For example,
Given array :
10, 8, -5, 1, -27, 5, 7, -5, 11
the sub array should be : 10, 8
Source : CLRS & this sample interview question
For example,
Given array :
10, 8, -5, 1, -27, 5, 7, -5, 11
the sub array should be : 10, 8
Source : CLRS & this sample interview question
Algorithms from "100 Interview Questions for Software Developers" : Part 3
Find repeating element in array
I felt this question deserves a post of its own. So here it is :
Q5. In an array from 1 to n, one number is present twice. How to do you determine which one?
There are multiple answers - all correct. We would, obviously, aim for the optimized one - benchmark parameters being time & space complexity
Source : Algorithms from 100 Interview Questions for Software Developers
I felt this question deserves a post of its own. So here it is :
Q5. In an array from 1 to n, one number is present twice. How to do you determine which one?
There are multiple answers - all correct. We would, obviously, aim for the optimized one - benchmark parameters being time & space complexity
Source : Algorithms from 100 Interview Questions for Software Developers
Dividing array into groups
Divide a list of numbers into groups of consecutive numbers but their original order should be preserved.
Example:
<8,2,4,7,1,0,3,6>
should be divided into two groups like this:
<2,4,1,0,3> <8,7,6>
Source : http://discuss.techinterview.org/default.asp?interview.11.770712.8
Example:
<8,2,4,7,1,0,3,6>
should be divided into two groups like this:
<2,4,1,0,3> <8,7,6>
Source : http://discuss.techinterview.org/default.asp?interview.11.770712.8
Subscribe to:
Posts (Atom)