Yahoo Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

public void print(Node root){

int count=0;
//count the number in the first round
while(node!=null){
count ++;
}

int smallest =integer.MIN_VALUE;
int previoussmallest =integer.MIN_VALUE;
int times;

for(int i=0;i<count;i+=times){
while(node!=null){
//find next smallest one, i don't have time to write it now

}
for(int j=0;j=times;j++)
system.out.println(smallest );
}

}

- Anonymous September 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<div class="cpp" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><ol><li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> </div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;">&nbsp; &nbsp; <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> N <span style="color: #000080;">=</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;">&nbsp; &nbsp; <span style="color: #0000ff;">int</span> ar<span style="color: #008000;">&#91;</span>N<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#123;</span><span style="color: #0000dd;">1</span>, <span style="color: #0000dd;">2</span>, <span style="color: #0000dd;">2</span><span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span><span style="color: #666666;">//, 2, 3, 3, 4, 4, 5, 6, 6};&nbsp; </span></div></li>
<li style="font-weight: bold; vertical-align:top;font-weight: bold; color: #006060;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;">&nbsp; &nbsp; std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> getit<span style="color: #008000;">&#40;</span>ar, N<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></li>
<li style="font-weight: normal; vertical-align:top;font: normal normal 130% 'Courier New', Courier, monospace; color: #003030;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;color: #000020;"><span style="color: #008000;">&#125;</span></div></li>
</ol></div>

- Anonymous October 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="c++" line="1" title="CodeMonkey92393" class="run-this">include <iostream>

using namespace std;

int main() {

return 0;
}
</pre><pre title="CodeMonkey92393" input="yes">
</pre>

- Anonymous October 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In one pass, find the min of the list
In second pass, print the min as you encounter it on the list. If we were allowed extra memory, we could have a kept the counter of the min and avoid second pass.
Now we have found the min element. Do this for the rest of the list to find the second min
O(n^2).

- Anonymous February 11, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More