androidify
BAN USER
Questions (3)
Comments (2)
Reputation 45
- 0of 0 votes
AnswersGiven two string, check whether the other is permutation of first one or not.
- androidify in United States
Eg: box
xob Ans: True
Eg: box
obxx : Ans: False
This was simple one for Microsoft Developer profile.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 3 vote
Its simple. Find the sum until the sum gets negative. When the sum gets negative start from zero.
Eg: 2,3 , -2 , 4 , -8 , 8, 9, -2, 10
1: Initially the sum is 2 (first no.). Start from second if first no. is zero and so on.
2: Keep adding the number until the sum is negative. (2+3-2 + 4) =7 but adding -8 gives sum = -1 so start from zero.
3: Repeat step 2 again. Now the sum is 8 + 9 -2 + 10 =25. This is max contiguous sum.
Note: do not include the last no. in sum if it is negative.
Complexity: O(n)
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Not needed. That will take O(n log n) time. Just use an array of 26 elements and keep increasing the indexes for each character. This will work in O(n) time.
- androidify August 25, 2012