rajnikant12345
BAN USER- -1of 1 vote
AnswersGiven a circular array of images, in LandScape and Portrait mode. Bidirectional movement in array is allowed.
- rajnikant12345 in India for Office
e.g.
LPPPLPPP
L-> Landscape
P-> Portrait
Cost of Viewing a Portrait image is Vp
Cost of Viewing a Landscape is (Rp(rotate) + Vp).
Cost of movement is -> m
once you visited the image viewing cost is zero if you revisit the image. Only movement cost is considered.
Jumps in array is not allowed.
Calculate the maximum number of images you can see with cost X.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 0of 0 votes
AnswersGiven a DNA sequence e.g. AAAGTAAGTAAGTGGG.....
- rajnikant12345 in India for Office
Find all the duplicates with length 10.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 String Manipulation
Actually , he straight forward said. Tell me something without hashing.
- rajnikant12345 March 15, 2016Create a doubly liked list of characters.
Now start moving from start.
If you find a duplicate.
Remove that node.
Find a place for it where it fits in a linked list.
So , every time you find a duplicate , just repeat it.
If no place is found for a duplicate, return false bcz we cannot solve it.
Actually You are right but the person , I was dealing with was not convinced with the hashing solution.
He wanted tries.
And actually he was concerned with cost of hashing. :P
I replied same to him, but he was not impressed with complexity. Later when i came out of room, I thought about it.
So, Tries hit my mind. A trie of depth 10 can do the job and complexity can be improved.
Still need to impliment the solution.
ABCDAA ---> test this input
- rajnikant12345 March 13, 2016I used Doubly linked list so it allowed me the free movement and non recursive solution.
- rajnikant12345 March 13, 2016We don't need to count the revisited images.
We have to find the max number of different images.
You can just move to next image.
No Random jump is allowed.
I was able to solve ot in O(n2) , using optimized bruite force. But
- rajnikant12345 March 15, 2016a better solution was expected.