This is Sumanta Chakraborty's Typepad Profile.
Join Typepad and start following Sumanta Chakraborty's activity
Join Now!
Already a member? Sign In
Sumanta Chakraborty
Recent Activity
Going back to the original issue, here are my 2c. This "FizzBuzz" is a good problem for an interview question, because you could complicate the problem after the interviewee solves it. So first solution would probably have: 1. a statement where they REDO the divide by 3 and divide by 5. 2. Console.Write and Console.WriteLine (in the C# world, or printf or System.out....) in three places. First performance optimization would be to remove the additional divides by a flag. Now the interviewer could complicate the problem to writing to a different IO stream - say a slower one -say a file across the network. So we are writing 100 lines right now. Would it not be better to write the entire output into a StringBuilder(in C#,Java) and then push it out the output channel? probably yes. Now of course if we were doing the same exercise on 1000 lines instead of 100, maybe we should flush the buffer every now and then, say after every hundred lines. So on and so forth...
Sumanta Chakraborty is now following The Typepad Team
Mar 17, 2010