pretentious.bastard
BAN USER- 1of 3 votes
AnswersOne of the questions in one of the interviews -
- pretentious.bastard in United States for SQL BI
Given a stack S and another empty stack T and a variable v, write a function that returns S but with its elements reversed.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Stacks - 0of 0 votes
AnswersDesign a download manager. The download manager would be shipped with a browser. Detailed design of components and interaction between them.
- pretentious.bastard in United States for Windows Azure Mobile
Follow up question - What features would you add to the download manager so that it is more marketable than others.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Object Oriented Design
- 0 Answers Test Engineer At Google Over Developer At Microsoft?
Hi Guys,
- pretentious.bastard February 26, 2014
I am an SDET at Microsoft. My team is shifting focus from the traditional SDET job definition to something that would result in less coding and more manual testing and data analysis. I have always enjoyed the coding aspect of my job and now I've decided to make a move to a position where I can continue to do that. My goal is to move to a developer position. What I mean by that is something that is coding intensive than what I would do in the future in this team.
I am interviewing internally at MS for developer positions and I applied at Google for an SET position as well. I was offered the TE(Test Engineer) position instead of the SET position. Now here within MS, I am pretty sure I will get into a developer position somewhere or the other if I keep trying even though I do not have a lot of hardcore dev experience. I want to move to a dev position because I want to grow in my career as a developer and not "try" other stuff anymore.
Google told me that if I take up SET and SWE projects as a part of my work and display proficiency, I would be able to switch to those disciplines in 18 months or 2 years.
My question is, do you think it's worth going to Google as a TE and spending all that time just to reach a stage where I would be eligible for consideration to move to an SET/SWE position or do you think I should just grab an MS dev role if I get it and jump into it and put all the hard work into that? What are the pros and cons of taking either of these steps?
I would really appreciate some help deciding here. And please ask me any questions that would help you help me. Again, I am not a person with a hardcore dev background, but I am smart, hard working and rarely make the same mistakes twice. So, I think I can learn and grow in any position. But I'd also appreciate you giving it to me straight.
Thanks!
Pretentious Bastard| Flag | PURGE - 12 Answers Test Engineer At Google Over Developer At Microsoft?
Hi Guys,
- pretentious.bastard February 26, 2014
I am an SDET at Microsoft. My team is shifting focus from the traditional SDET job definition to something that would result in less coding and more manual testing and data analysis. I have always enjoyed the coding aspect of my job and now I've decided to make a move to a position where I can continue to do that. My goal is to move to a developer position. What I mean by that is something that is coding intensive than what I would do in the future in this team.
I am interviewing internally at MS for developer positions and I applied at Google for an SET position as well. I was offered the TE(Test Engineer) position instead of the SET position. Now here within MS, I am pretty sure I will get into a developer position somewhere or the other if I keep trying even though I do not have a lot of hardcore dev experience. I want to move to a dev position because I want to grow in my career as a developer and not "try" other stuff anymore.
Google told me that if I take up SET and SWE projects as a part of my work and display proficiency, I would be able to switch to those disciplines in 18 months or 2 years.
My question is, do you think it's worth going to Google as a TE and spending all that time just to reach a stage where I would be eligible for consideration to move to an SET/SWE position or do you think I should just grab an MS dev role if I get it and jump into it and put all the hard work into that? What are the pros and cons of taking either of these steps?
I would really appreciate some help deciding here. And please ask me any questions that would help you help me. Again, I am not a person with a hardcore dev background, but I am smart, hard working and rarely make the same mistakes twice. So, I think I can learn and grow in any position. But I'd also appreciate you giving it to me straight.
Thanks!
Pretentious Bastard| Flag | PURGE - 0 Answers Test Engineer At Google Over Developer At Microsoft?
Hi Guys,
- pretentious.bastard February 26, 2014
I am an SDET at Microsoft. My team is shifting focus from the traditional SDET job definition to something that would result in less coding and more manual testing and data analysis. I have always enjoyed the coding aspect of my job and now I've decided to make a move to a position where I can continue to do that. My goal is to move to a developer position. What I mean by that is something that is coding intensive than what I would do in the future in this team.
I am interviewing internally at MS for developer positions and I applied at Google for an SET position as well. I was offered the TE(Test Engineer) position instead of the SET position. Now here within MS, I am pretty sure I will get into a developer position somewhere or the other if I keep trying even though I do not have a lot of hardcore dev experience. I want to move to a dev position because I want to grow in my career as a developer and not "try" other stuff anymore.
Google told me that if I take up SET and SWE projects as a part of my work and display proficiency, I would be able to switch to those disciplines in 18 months or 2 years.
My question is, do you think it's worth going to Google as a TE and spending all that time just to reach a stage where I would be eligible for consideration to move to an SET/SWE position or do you think I should just grab an MS dev role if I get it and jump into it and put all the hard work into that? What are the pros and cons of taking either of these steps?
I would really appreciate some help deciding here. And please ask me any questions that would help you help me. Again, I am not a person with a hardcore dev background, but I am smart, hard working and rarely make the same mistakes twice. So, I think I can learn and grow in any position. But I'd also appreciate you giving it to me straight.
Thanks!
Pretentious Bastard| Flag | PURGE
That's why you know about the test/dev culture at Microsoft. Makes sense.
Yeah, I still think it's too early to judge how Nadella will change the course of MS though. Only time will tell. Nobody knows it all. :)
Agreed. Test vs Dev distinction is a Microsoft thing. Personally, I hate it too. But it's not there so much in newer teams. And I agree SET in Google is very different. That is the reason if I got the SET position I would have taken it. I'm sure you read that I mentioned earlier that I was being offered the TE position and not the SET position. The TE position focuses on a different set of goals that I don't want to be the focus of my career.
As far as Nadella goes, you don't know what you're talking about. He has just been in the job for a little over a month. And yes I spoke with Microsofties. No one else has the level of insight into what's going on within MS that Microsofties do (obviously). And as I said, I am able to appreciate the general sense that people are learning from their mistakes at all levels.
Yes, you are right. I have almost made up my mind. Thanks for wishing me luck.
I thought of this same approach too. I will write here why I did so that it helps others think of it this way if they can't think of another more efficient approach. Basically, the running sum with hashtable approach seems to work for most problems where sum of a sub-array is desired. Here the sum of the sub-array is 0 considering zeroes as -1s and ones as 1s.
- pretentious.bastard March 03, 2014Ami, there is a bug in your code.
if(value == 0)
count++;
and
...
+ getNoOfWays(array, index+1, value)
...
will both add 1 when value == 0. This will lead to the same combination counted multiple times.
Try this example - getNoOfWays(new int[]{ 2, 4, 7, 8 }, 0, 6);
I have rewritten it this way. May not be the most optimal one, but it works -
public static int WaysToCalculateTarget(int[] arr, int value, int target, int index, bool atLeastOneElementChosen)
{
if (arr.Length == index)
{
if (target == value && atLeastOneElementChosen)
return 1;
return 0;
}
return WaysToCalculateTarget(arr, value, target, index + 1, atLeastOneElementChosen)
+ WaysToCalculateTarget(arr, value + arr[index], target, index + 1, true)
+ WaysToCalculateTarget(arr, value - arr[index], target, index + 1, true);
}
static void Main(string[] args)
{
int i = WaysToCalculateTarget(new int[]{ 2, 4, 6, 8 }, 0, 12, 0, false);
}
Here's the solution I gave in the interview -
public static List<int> ReverseStackInPlace(List<int> stack)
{
List<int> tempStack = new List<int>();
int v;
while (stack.Count > 0)
{
v = stack[stack.Count - 1];
stack.RemoveAt(stack.Count - 1);
//move all elems from temp to stack
int itemsMoved = 0;
while (tempStack.Count > 0)
{
stack.Add(tempStack[tempStack.Count - 1]);
tempStack.RemoveAt(tempStack.Count - 1);
itemsMoved++;
}
//move v to temp
tempStack.Add(v);
//move items back to temp from stack
for (int i = 0; i < itemsMoved; i++)
{
tempStack.Add(stack[stack.Count - 1]);
stack.RemoveAt(stack.Count - 1);
}
}
//pop temp into stack
while (tempStack.Count > 0)
{
stack.Add(tempStack[tempStack.Count - 1]);
tempStack.RemoveAt(tempStack.Count - 1);
}
//print stack
//foreach (int s in stack)
//{
// Console.Write(s + " ");
//}
return stack;
}
Thank you for your comment.
Personally, difficult interviews will never be a reason for me to take a (supposedly) easier route into any company. I understand what kind of questions they ask and agree that they are difficult. But, I think I should be able to crack an SWE interview.
Anyway, I agree that Google is doing very well. Best in the industry right now. That's the reason I was even thinking so much about this position, even though it's test. But saying MS is on a downward spiral is inaccurate and a shallow/simplistic understanding of what's actually going on in the industry. While the promise in Cloud and Enterprise Engineering and stuff like Xbox indicates anything but a downward spiral, there are other things about Microsoft that don't show up that easily unless you dig for it. There are tons of smart people here who just won't sit back and let a downward spiral happen. The biggest change I see at Microsoft is a universal(top to bottom) acceptance that we have made mistakes and a shift in focus based on that. For example, on executive levels a shift in focus from numbers to drivers(focus on what drives demand for products rather than focus on what numbers are) or on the lower levels like the level I am on, a shift of testing, for instance, from focus on components to scenarios and customer delight. Microsoft still owns the massive PC market and it clearly understands how crucial this point in time is to not lose that and not repeat some of the mistakes it has made. To use that as a foundation to build a unified ecosystem of devices. Then there is this rising focus on embedded systems, internet of things, etc. Trust me, MS is really bad at advertising what its plans are. The ability to learn from mistakes is what gives me optimism and I won't take anybody's word on what will happen in the future. Especially not a proletarian developer's word :). The thing about Google is that it's a great company but as far as getting into Google is concerned, there is a coolness factor associated with it that makes it even more desirable. Which is exactly the opposite with MS. MS is seen as a company for old people. But I try to not get influenced by those kinds of opinions and try to make informed decisions.
What you are saying is exactly what I was hearing initially - a lot - until I started talking to a lot of people, especially those who have been around for a while or interact with the decision makers and understand the direction of the industry. I think at this point my decision to choose a position should be based more on the kind of work that I would like to do just like @BigKdotAtTdot suggested.
Thank you for your comment again.
Here is a simple approach that is not cryptic at all and everybody should be able to understand.
1. One slow 1x and one fast pointer 2x. For instance, start slow one from first and fast one from second node.
2. When they meet, that has to be inside the loop. Say, they meet at node X.
3. Starting from X go to next until you come back to X again. Keep a count of number of other nodes you hit. Say, that's N. N is the number of nodes in the loop minus 1(X).
4. Take 2 pointers p1 = StartNodeOfLinkedList and p2 = StartNodeOfLinkedList.next().next()...N times.
5. Increment p1 an p2 until p2.next() == p1. p2 is the last node of the loop.
I like what some people have suggested to avoid class explosion. Based on that, I have come up with this basic structure. Mind you that there can be many more details added. For instance, for chair, if the back rest breaks first on applying pressure or which leg breaks first. Of course, I haven't really written the class that drives the tests either
public interface IMaterial
{
double GetStressThreshold();
double GetHeatThreshold();
}
public abstract class Material : IMaterial
{
protected double stressThreshold;
protected double heatThreshold;
public Material(double stressThreshold, double heatThreshold)
{
this.stressThreshold = stressThreshold;
this.heatThreshold = heatThreshold;
}
public double GetStressThreshold()
{
return stressThreshold;
}
public double GetHeatThreshold()
{
return heatThreshold;
}
}
public class Wood : Material
{
public Wood(double stressThreshold, double heatThreshold)
: base(stressThreshold, heatThreshold)
{ }
}
public class Metal : Material
{
public Metal(double stressThreshold, double heatThreshold)
: base(stressThreshold, heatThreshold)
{ }
}
public interface ITestableFurniture
{
bool Buckled { get; }
bool Burnt { get; }
void ApplyHeat(double temperature);
void ApplyStress(double psi);
}
public abstract class TestableFurniture : ITestableFurniture
{
protected bool buckled;
protected bool burnt;
protected Material material;
public bool Buckled { get { return buckled; } }
public bool Burnt { get { return burnt; } }
public Material Material { get { return material; } }
public TestableFurniture(Material material)
{
this.material = material;
buckled = burnt = false;
}
public virtual void ApplyHeat(double temperature)
{
if (temperature >= material.GetHeatThreshold())
burnt = true;
}
public virtual void ApplyStress(double psi)
{
if (psi >= material.GetStressThreshold())
buckled = true;
}
}
public class Chair : TestableFurniture
{
public Chair(Material material)
: base(material)
{ }
}
public class Table : TestableFurniture
{
public Table(Material material)
: base(material)
{ }
}
C# Code
public static int DeepestOddLevelLeafNode(TreeNode root)
{
return DeepestOddLevelLeafNodeInternal(root, 1);
}
private static int DeepestOddLevelLeafNodeInternal(TreeNode root, int level)
{
if (root == null)
return 0;
if (root.left == null && root.right == null)
{
if (level % 2 == 0)
return 0;
return level;
}
int left = DeepestOddLevelLeafNodeInternal(root.left, level + 1);
int right = DeepestOddLevelLeafNodeInternal(root.right, level + 1);
return Math.Max(left, right);
}
Thank you. That's a very helpful insight.
- pretentious.bastard March 01, 2014Very true. My confusion was based on some people telling me that working at Google as a test engineer and slowly working my way into the developer position might be more worth the effort than working as a developer at Microsoft. Since, I posted this question on this forum, I have chatted with a number of other people and going to chat with another very senior dev today again. Everyone tells me that's bs and I should grab a dev position at MS if I get one because MS is a great company too and it's not like I have the option of becoming a TE at Google vs a developer at a bank or something. So, I think I have got my answer. Your response provide validation to my decision. Thank you.
- pretentious.bastard February 28, 2014Beautiful!
- pretentious.bastard February 26, 2014C# Code
public static void GetVolume(double inputVolume, int row, int position)
{
double[] prev = new double[1];
prev[0] = inputVolume;
for (int i = 0; i < row+1; i++)
{
double[] next = new double[i+1];
for (int j = 0; j < i + 1; j++)
{
if (j == 0 || j == i)
inputVolume = i==0?prev[0]: (double)(prev[0] / 2.0);
else
inputVolume = (double)(prev[j - 1] / 2.0 + prev[j] / 2.0);
if (i == row && j == position)
{
if (inputVolume > 1)
Console.WriteLine(1);
else
Console.WriteLine(inputVolume);
}
if (inputVolume >= 1)
next[j] = inputVolume - 1.0;
else
next[j] = inputVolume;
}
prev = next;
}
}
public class Terminal
{
private class WaitingRunwayRequestor
{
public IRunwayRequestor runwayRequestor;
public int minLength;
}
public List<Runway> AvailableRunways{get;set;}
public List<WaitingRunwayRequestor> WaitingRunwayRequestors { get; set; }
public Terminal()
{
AvailableRunways = new List<Runway>();
WaitingRunwayRequestors = new List<WaitingRunwayRequestor>();
}
public void RequestRunway(IRunwayRequestor runwayRequestor, int minLength)
{
Runway allocatedRunway=null;
foreach (Runway runway in AvailableRunways)
{
if (runway.length >= minLength)
{
allocatedRunway = runway;
runwayRequestor.AssignRunway(runway);
}
}
if (allocatedRunway != null)
{
AvailableRunways.Remove(allocatedRunway);
}
else
{
WaitingRunwayRequestors.Add(new WaitingRunwayRequestor() { runwayRequestor = runwayRequestor, minLength = minLength });
}
}
public void ReturnRunway(Runway runway)
{
WaitingRunwayRequestor allocatedRunwayRequestor = null;
foreach (WaitingRunwayRequestor waitingRunwayRequestor in WaitingRunwayRequestors)
{
if (waitingRunwayRequestor.minLength <= runway.length)
{
allocatedRunwayRequestor = waitingRunwayRequestor;
waitingRunwayRequestor.runwayRequestor.AssignRunway(runway);
}
}
if (allocatedRunwayRequestor != null)
{
WaitingRunwayRequestors.Remove(allocatedRunwayRequestor);
}
else
{
AvailableRunways.Add(runway);
}
}
}
public class Runway
{
public readonly int length;
public readonly Terminal terminal;//same runway cannot be at 2 terminals
public Runway(Terminal terminal, int length)
{
this.terminal = terminal;
this.length = length;
}
}
public interface IRunwayRequestor
{
void AssignRunway(Runway runway);
void ReturnRunway();
}
public abstract class RunwayRequestor
{
public Runway AssignedRunway{get; set;}
public Terminal Terminal { get; set; }
public virtual void AssignRunway(Runway runway)
{
this.AssignedRunway = runway;
}
public virtual void ReturnRunway()
{
Terminal.ReturnRunway(AssignedRunway);
AssignedRunway = null;
}
}
public class Aircraft : RunwayRequestor
{
public Aircraft(Terminal terminal)
{
this.Terminal = terminal;
}
public override void AssignRunway(Runway runway)
{
base.AssignRunway(runway);
Land();
}
public void Land()
{
//perform takeoff
ReturnRunway();
}
}
public class MaintenanceCrew : RunwayRequestor
{
public MaintenanceCrew(Terminal terminal)
{
this.Terminal = terminal;
}
public override void AssignRunway(Runway runway)
{
base.AssignRunway(runway);
PerformMantenance();
}
public void PerformMantenance()
{
//perform maintenance
ReturnRunway();
}
}
Thanks for the detailed answer.
Here are some differences in how I answered it -
1. First, I outlined all requirements for the DM that came to mind. Starting from the most basic "Should be able to download a file" to others like -
- Should provide admin functionality to blacklist websites so other users can't download from those sites
- Built in virus scanner
- Ability to calculate expected time based on bandwidth and let the user know how long it would take.
and other basic requirements
2. Special features
- I should be able to provide multiple locations - multiple trusted devices and even online storage location like Skydrive, etc and downloading the file should save to each of these simultaneously if I've selected that option.
- Automated download/subscription. Say, my friend uploads pictures to his Instagram occasionally, I can subscribe to it and have the DM auto download whenever pics are available.
For fault tolerance -
Keep appending the bytes of the file to a temp file. Maintain a sourceFile->localTempFileName mapping in a DB. When machine restarts after crash, then check the size of the temp file and start from the byte number after the size. For instance, if the size was 546 bytes, start downloading the source from the 547th byte.
He was very happy with my ideas but unfortunately my component design was actually rough. They had many candidates applying for the position. I was told that my skills didn't match their requirements.
I think the algorithm here is that for an index i, if you position the desired char by swapping once with it's successor, then fine, proceed to the next char or else keep swapping until the character that was initially in the index i goes to the end of the string by swapping in the inner while loop. repeat this pushing to end, until that pushing unmatched chars to the end results in desired char automatically being pulled into position. Does that make sense? If it doesn't then what I'd do is, run this program with sample input and study each step to see what's happening.
- pretentious.bastard February 22, 2014You pretentious bastard.
- pretentious.bastard February 22, 2014I share crankyCoder's bewilderment.
- pretentious.bastard February 22, 2014If I am not mistaken, I think we could use a HashSet here to save the space wasted in indices that are array[i] != 1
Another observation. Please correct me if I'm understanding something wrong here -
If duplicates are NOT allowed in the BST
-------------------------------------------------------
If size of array is S, then S = n + c where n is the number of nodes and c is some constant integer such that c>=0.
Space complexity is O(S) = O(n+c) = O(n).
If duplicates are allowed in the BST
------------------------------------------------
If size of array is S, then S = n + c where n is the number of nodes and c is some constant integer such that c>(-1*n). Worst case space complexity happens when c>=0 in which case it is O(n)
"But as your career progresses, ask yourself this question: How many upper level managers are there from testing vs. dev backgrounds?"
- pretentious.bastard March 06, 2014Definitely more from dev backgrounds. At least MS is definitely a dev driven company. That's my personal opinion. I would assume the same answer for Google as well.
"Another question: Is it just as hard to switch from dev to te as it is from te to dev?
Nope."
I agree, and that's why I also think I should not delay my transition anymore. I'll take the hit now and whatever ramp-up is needed instead of waiting and becoming more senior before making the transition.