codealtecdown
BAN USER
Questions (1)
Comments (2)
Reputation 170
- 4of 4 votes
AnswersWrite a program to process the matrix. If an element is 0 at ith row and jth column, then make the whole ith row and jth column to 0.
- codealtecdown in United States
Constraints:
Space complexity should be O(1)
Time complexity - Only single pass is allowed. Note that single pass is not O(n). This is single pass : An element will read and written only ones.
Edit:
Recursion is not allowed since it is O(n) space on stack| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm
Page:
1
2
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
First number of one stream could be higher than (or equal to) the last number of other stream
S1 S2 S3 S4
10 12 15 7
9 11 14 4
5 8 13 3
1 7 6 0
We create a Min-Heap which takes O(nlogn) for creation and
ReadNextNumber - O(1) - findmin operation on min-heap
WriteToStream - O(log n) - insert operation on min-heap
Page:
1
2
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
c# implementation
- codealtecdown July 20, 2015