challenge for interview

6 views
Skip to first unread message

uday3prakash

unread,
Feb 26, 2015, 1:10:33 AM2/26/15
to lamp_t...@googlegroups.com
yesterday, a HR called me and told to solve atleast one of these Four challenge to get a chance for interview.

CHALLENGES:
1. Finding intersection of two rectangles. 
 
Write a function that takes the following arguments as input: 
 
x1, y1, x2, y2 (coordinates of rectangle 1)
a1, b1, a2, b2 (coordinates of rectangle 2) 
 
The function should try and figure out whether the rectangles overlap or not. If they do, then it should return true, else return false. 
 
The coordinates are float values, and can be large numbers. They can also be negative (in cartesian coordinate space). 
 
-----------------------
 
2. Finding dictionary rank of a combination of letters. 
 
Your function should do the following: 
 
Given an array of letters as input, first find all permutations of those letters (without using a permutation library). 
Next, for each permutation, a resulting word that one can be formed through combining all the letters (it doesn't need to be an actual english word). Create a sorted array of all these words. 
Finally, it should also take a word as input, and find its rank in that sorted array. 
 
The output of your function should be the position of the word whose rank you need to output. 
 
Hence, your function / input could be the following: 
 
function ( ['c', 'a', 'r'], 'arc')
 
Output would be position of 'arc' in the following --- in this case, 2. 
 
acr 
arc
car
cra
rac
rca
 
----------------------
 
3. Function that suggests auto-corrections to spelling mistakes
 
Write a function that takes as input an array of words (your dictionary) as first argument, and a misspelt word as a second argument. 
 
The misspelt word is simply one of the words in the dictionary (array of words), with one of the following possibilities (take 'maruti' as an example word in the dictionary): 
 
-- maximum of 2 characters can be missing ('mauti')
-- a character is swapped with the previous or next one ('maurti')
-- a maximum of one extra character could have been added by mistake ('marutix')
-- a maximum of one character could have been written wrong ('maruty')
 
Your function should be case insensitive for its inputs, and output the right possible match from the dictionary. If there are two or more possible matches from the dictionary, it should output all of them as possibilities. 
 
-----------------------
 
4. Function that finds paths through a maze. 
 
Write a function that takes an 2-dimensional array of NxN, a start point cell coordinate, and an end point cell coordinate as input. 
 
The array represents a simple maze. Each cell of the array has either a 0 or 1. The 0 represents empty space, and 1 represents a block through which there is no path. 
 
The start point is simply the index of a point on the array (outer edge of the maze). Eg. (0, 0) or (0, 7) etc. 
 
The end point is the index of the end point on the array. 
 
Your function should output all the possible paths from the start point to the end point in the array. In other words, the output is an array of arrays, where each entry in the first array is itself an array which should be array of indices through which there is a path. Eg. 
 
[[(0,0), (1,1), ...... ], [(0,0), (0,1), ....]]

i solved one and working on the other.

someone could take this challenge and post on our group
Reply all
Reply to author
Forward
0 new messages