IHE
BAN USER- 1of 1 vote
AnswersWrite a method to reverse a multibyte character string.
- IHE in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a function
- IHE in United States
int strcspn(string find, string src)
code the most efficient way to return the index of first character that matches in the find string of any character in the src string.
example:
find="ttbbcca"
src="ggabba"| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an unsorted array of integers with duplicate numbers, write the most efficient code to print out unique values in the array. Give the big-o for your algorithm. What are the pros and cons (in the context of hardware usage) of your implementation?
- IHE in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm
So, O(n^2) time, but relatively good with space. I was using a KMP variant to get a partial match, and if the pattern also hits the end of the src, the starting index of the match is the rotation point. That way, I did it in O(m+k), however, I need extra space O(n) for the partial match table for KMP.
- IHE February 18, 2012
Yeah, or vice versa, do srcsrc, which was my original answer. The follow up question then became, what if my src is huge and I don't want to concatenate it, what can you do -- Which I started thinking of using KMP for a partial match.
- IHE February 19, 2012