Jump to content



Photo

Programmers: Your favorite interview questions


  • Please log in to reply
105 replies to this topic

#16 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 28 September 2012 - 19:28

This one is kinda subjective. Different people can have different answers and (potentially) they could all be correct.

I don't see it like that. The most important difference is that one is based on .NET and the other isn't. Everything else - the type system, garbage collection, assemblies, etc - derives from that.


#17 vetneufuse

neufuse

    Neowinian Senior

  • Joined: 16-February 04

Posted 28 September 2012 - 20:08

I don't see it like that. The most important difference is that one is based on .NET and the other isn't. Everything else - the type system, garbage collection, assemblies, etc - derives from that.


what if someone says well C++ can also use the CLI if you wanted to? then you have C++ in .NET under the CLI :) ... but yeah polymophism from the base type "object",GC etc etc

if you want to get technical managed C++ probably should be called MC++ but MS still calls it C++ basically

#18 +Majesticmerc

Majesticmerc

    Resident Idealist

  • Tech Issues Solved: 8
  • Joined: 24-August 05
  • Location: United Kingdom
  • OS: Arch Linux / Win 7
  • Phone: HTC One X

Posted 28 September 2012 - 20:13

Some of my more memorable ones:

Test questions:
  • Given the following algebraic equations, determine the value of x and y (simultaneous equations in my case, intended to test math proficiency).
  • Given a rope laid around the equator of the earth, how long is the rope? If you raise the rope 3 feet from the ground all the way round, how much longer would the rope be?
  • Design an algorithm that will print all the numbers between one and a 50,000,000 that are divisible by 13. (easy to write, but a surprising number of people don't write it efficiently).
  • Given the following code (taken from the company's codebase), what would be your best guess as to its purpose.
  • Given the following C++ code, list all the places an exception could be thrown.
  • Given the following code, what efficiency improvements do you feel could be made?
  • Given two integer variables, A and B, how could you swap their values without using a third variable? (This is my favourite. It wasn't actually given to me, but to my housemate at the time. He didn't get it, but the interviewer gave it to him to do on the train home, he figured it out on the train and emailed the answer to the interviewer, subsequently got the job :p)
  • Implement x sorting algorithm using pseudo code or a language of your choice.
Verbal questions:
  • What has been your most memorable project, and why?
  • What is your favourite programming language, and why? What do you feel are it's strengths. What are it's weaknesses?
  • What do you know about our company? (seriously, if a person didn't care to even find out what your company does, they weren't serious about joining, IMO. I admit that I fell for this one when applying for my work placement at university for a company.)


#19 firey

firey

    F͎̗͉͎͈͑͡ȉ͎̣̐́ṙ͖̺͕͙̓̌è̤̞͉̟̲͇̍̍̾̓ͥͅy͓̍̎̌̏̒

  • Tech Issues Solved: 6
  • Joined: 30-October 05
  • Location: Alberta, Canada
  • OS: Windows 7
  • Phone: Android (4.4.2)

Posted 28 September 2012 - 20:25

So, I had never heard of the FizzBuzz test, decided to give it a shot, was not hard at all, my solution was less than elegant, and after reading on here and remembering module I shortened the code up by about 10 lines total.

so try 1:

		static void Main(string[] args)
		{
			for (double i = 1; i < 101; i++)
			{
				Console.WriteLine((isMultOfThree(i) && isMultOfFive(i) ? "FizzBuzz" : (isMultOfThree(i) ? "Fizz" : (isMultOfFive(i) ? "Buzz" : i.ToString()))));
			}
			Console.ReadKey();
		}
		static bool isMultOfThree(double num)
		{
			double val = num / 3;
			if (val.ToString().Contains("."))
				return false;
			else
				return true;
		}
		static bool isMultOfFive(double num)
		{
			double val = num / 5;
			if (val.ToString().Contains("."))
				return false;
			else
				return true;
		}


//The two if's could be shortened to just return (!(num / 5).ToString().Contain("."));


And using modulo

		static void Main(string[] args)
		{
			for (double i = 1; i < 101; i++)
			{
				Console.WriteLine((isMultOfThree(i) && isMultOfFive(i) ? "FizzBuzz" : (isMultOfThree(i) ? "Fizz" : (isMultOfFive(i) ? "Buzz" : i.ToString()))));
			}
			Console.ReadKey();
		}
		static bool isMultOfThree(double num)
		{
			return num % 3 == 0;
		}
		static bool isMultOfFive(double num)
		{
			return num % 5 == 0;
		}


I am not really that efficient, and I like to keep code clean (hence separate functions).

And reading the coding challenges from majestic. I decided to try the Integer one. This was how I did it in C#, 3 lines of code for swapping. Not sure if it will always work, but it does for me.

		    int a = 100;
		    int b = 200;


		    //Point is to make a == b and b == a
		    Console.WriteLine('\n' + a.ToString());
		    Console.WriteLine(b.ToString());

		    b += a;
		    a = b - a;
		    b -= a;

		    Console.WriteLine(a.ToString());
		    Console.WriteLine(b.ToString());


#20 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 28 September 2012 - 20:35

what if someone says well C++ can also use the CLI if you wanted to? then you have C++ in .NET under the CLI :) ... but yeah polymophism from the base type "object",GC etc etc

C++/CLI is a different language with its own syntax.

#21 vetneufuse

neufuse

    Neowinian Senior

  • Joined: 16-February 04

Posted 28 September 2012 - 20:58

C++/CLI is a different language with its own syntax.


It's not a complte differnet language, Managed C++ is just extensions to the C++ language that include grammatical and syntactic extensions

#22 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 28 September 2012 - 21:15

It's not a complte differnet language, Managed C++ is just extensions to the C++ language that include grammatical and syntactic extensions

"C++/CLI should be thought of as a language of its own (with a new set of keywords, for example), instead of the C++ superset-oriented Managed C++ (MC++) (whose non-standard keywords were styled like __gc or __value)." http://en.wikipedia....rg/wiki/C++/CLI

C++/CLI has its own ECMA standard distinct from the ISO C++ standard, it is not designed by the same comittee, it has a different syntax, a different compiler, it compiles for a different platform.

#23 zeta_immersion

zeta_immersion

    Neowinian Senior

  • Joined: 08-October 04
  • Location: Toronto

Posted 28 September 2012 - 21:15

if else man .. ftw ... then again the most i did was arrays

#24 Fahim S.

Fahim S.

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 15-April 02
  • OS: Windows 8 - OG
  • Phone: Google Nexus 4 16GB by LG

Posted 28 September 2012 - 21:18

Haven't coded professionally for some time (about 5 years) but nice to know I aced the FizzBuzz test first time I tried it just a few moments ago in Java.

#25 +Brandon Live

Brandon Live

    Seattle geek

  • Joined: 08-June 03
  • Location: Seattle, WA

Posted 28 September 2012 - 22:57

It's not a complte differnet language, Managed C++ is just extensions to the C++ language that include grammatical and syntactic extensions


Managed C++ and C++/CLI are actually different things :-) Well, the latter replaced the former. And yes, at least C++/CLI is just a set of standardized extensions to C++.

Stroustrup's thoughts on it are an interesting read:
http://www.stroustru...faq.html#CppCLI

#26 rfirth

rfirth

    Software Engineer

  • Tech Issues Solved: 2
  • Joined: 11-September 09
  • Location: Baton Rouge, Louisiana
  • OS: Windows 8
  • Phone: Nokia Lumia 620

Posted 29 September 2012 - 20:02

And reading the coding challenges from majestic. I decided to try the Integer one. This was how I did it in C#, 3 lines of code for swapping. Not sure if it will always work, but it does for me.

			int a = 100;
			int b = 200;


			//Point is to make a == b and b == a
			Console.WriteLine('\n' + a.ToString());
			Console.WriteLine(b.ToString());

			b += a;
			a = b - a;
			b -= a;

			Console.WriteLine(a.ToString());
			Console.WriteLine(b.ToString());


It's probably worth mentioning why that won't always work... what happens if a = MAX_INT - 2 and b = MAX_INT - 3? The addition of a and b will overflow...

Can you think of another operator you can use?

#27 +Zag L.

Zag L.

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 21-April 04
  • Location: Dallas, Texas

Posted 29 September 2012 - 21:14

I no longer ask technical questions because we aren't allowed to do face to face interviews and over the phone, any one can do fairly well so I base my judgement on the applicants technical inquiries.

#28 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 11
  • Joined: 26-October 05

Posted 29 September 2012 - 21:31

It's probably worth mentioning why that won't always work... what happens if a = MAX_INT - 2 and b = MAX_INT - 3? The addition of a and b will overflow...

Can you think of another operator you can use?

There's a cute trick with the xor operator but I don't see any value in testing if the candidate knows about it. If he can find it on the spot then that's certainly impressive, but is it really the kind of skills you're looking for? On modern CPUs this is even counter-productive compared to using a temporary variable, so it's a typical example of premature and misguided "optimization". I view this type of question as outdated and as an interviewee it'd raise doubts in my mind about the company.

#29 Fahim S.

Fahim S.

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 15-April 02
  • OS: Windows 8 - OG
  • Phone: Google Nexus 4 16GB by LG

Posted 29 September 2012 - 22:02

I no longer ask technical questions because we aren't allowed to do face to face interviews and over the phone, any one can do fairly well so I base my judgement on the applicants technical inquiries.


Wow, really? I would struggle to employ anyone I haven't met face to face. Just out of interest, how many of the candidates you employ turn out to be a waste of space?

#30 ZakO

ZakO

    Neowinian

  • Tech Issues Solved: 2
  • Joined: 21-September 07
  • Location: Finland

Posted 29 September 2012 - 22:16

As already mentioned by a few of the people above, FizzBuzz (well, a slight variation on the FizzBuzz question) is probably my favourite. While it doesn't find "good" programmers it does well to quickly weed out the 80-90%+ of applicants applying for programming jobs who can't code at all. At work we always ask it before the proper interview, if the applicant can't do it with and without modulo in a reasonable time we don't even bother with the full interview.