• 0

Programmers: Your favorite interview questions


Question

I haven't seen one these posts yet on this forum(if there is forgive me : )), but I figured to help out more people looking for programming work I would start a post for employers who are looking to hire new programmers what kind of questions you guys ask. I'm the technical director at a small game studio in LA, and were expanding so I also looking to see what everyone does so I can adjust accordingly.

Some of the basic questions I ask are:

What is global scope/local scope.

What is a template class

What is inheritance/polymorphism/etc.

Than some really basic logic stuff like whats a recursive function, etc etc.

Than I begin to ask a couple questions that are kind of off the wall because one thing I noticed is College graduates from big schools such as UCLA 9/10 can't figure stuff for themselves. Students are so used to stuff getting spoon fed to them, some of which is just nasty. One thing that really irritated me at one of the studios I worked at previously a couple of there senior programmers came to me and said "I don't know how to do xyz, can you help?" This normally is a pretty common thing, except when xyz happens over and over again and its something that easily be found by doing a quick google search.

I ask the interviewee if they can do something that 99% of the programmers out there can't do. They would obviously say I don't know, I would then ask them than to look it up for me on google and write out basic steps on how to get it done. Lets say I ask them how to register a custom Debug Engine in Visual Studio, first google search for "visual studio custom debug engine" which turns up http://msdn.microsof...4(v=vs.80).aspx , with a link to http://msdn.microsof...(v=vs.110).aspx. Even though the information on the latter article is actually wrong if they copied that I would be so happy. I've had guys sit there for 10 minutes struggling, and I feel that's kind of ridiculous. Every programmer in world should know how to use google :/.

Than depending on the level of the job, I would go into some more nitpicker things say in Unreal, Unity, D3D, whatever and if someone didn't know the answer I would ask them to google it and give me an explanation. I had actually had one guy who didn't graduate from a college, straight out of high school and he didn't know something I asked him, and than he immediately asked if he could go on google and look it up. I actually hired him on the spot and he ones of the best programmers I've ever had.

Anyway what kind of stuff do you guys ask?

Recommended Posts

  • 0

The trick is that the naive algorithm only works with a monospace font. The extreme case, a string composed of 'i's, will hold much more letters than normal text in a certain amount of pixels. So you have to measure the text if you want to do it correctly.

but the way he wrote the question it said nothing about text width

2. In Java, write a function which takes a string and returns a string that is the input if the input is 6 characters or less, and the first 3 characters + "..." if it's greater than 6.

that is pretty straight forward, you are only careing about the number of characters... now if you said that as fit a string of text into a row that is 250 pixels wide with the font arial, and type settings of 12pt and bold, itallic, replace any overlap with an elipsis... that would make more sense... can't be a trick question if it only says take 6 char's replace anything over 6 with the first 3 plus an elipsis...

  • Like 2
  • 0

but the way he wrote the question it said nothing about text width

2. In Java, write a function which takes a string and returns a string that is the input if the input is 6 characters or less, and the first 3 characters + "..." if it's greater than 6.

that is pretty straight forward, you are only careing about the number of characters... now if you said that as fit a string of text into a row that is 250 pixels wide with the font arial, and type settings of 12pt and bold, itallic, replace any overlap with an elipsis... that would make more sense... can't be a trick question if it only says take 6 char's replace anything over 6 with the first 3 plus an elipsis...

Well, that's partially why I mentioned that the question is poorly defined. But the main issue is that Java strings are UTF-16, NOT UCS-2. So if you have a string where the first code point is a surrogate pair, then the naive algorithm will produce an invalid string. So what you want is code points. Of course, that's not the entire story. What do you do about control characters? You probably want to interpret those ones you can, like BOM. But what about accents and other "modifiers". Those aren't entire characters, so you probably want to treat "e" and circumflex as a single character. And of course, if the reason why you doing this is to display the string in a restricted space, then the whole "6 characters" is moot since you now need to take into account font, size, weight, and any number of other rendering factors. So overall, not an easy question.

  • 0

Well, that's partially why I mentioned that the question is poorly defined. But the main issue is that Java strings are UTF-16, NOT UCS-2. So if you have a string where the first code point is a surrogate pair, then the naive algorithm will produce an invalid string. So what you want is code points. Of course, that's not the entire story. What do you do about control characters? You probably want to interpret those ones you can, like BOM. But what about accents and other "modifiers". Those aren't entire characters, so you probably want to treat "e" and circumflex as a single character. And of course, if the reason why you doing this is to display the string in a restricted space, then the whole "6 characters" is moot since you now need to take into account font, size, weight, and any number of other rendering factors. So overall, not an easy question.

I don't know about all accents, but in UTF-16 the circumflex and other common accents are not separated from the character. (IIRC, windows-1257 does that, which is useful to remove accents from a string by converting it back into ASCII)

But your question was worded in a way that makes "s.length <= 6 ? s : s.substring(0,3)" an acceptable answer.

  • 0
Well, that's partially why I mentioned that the question is poorly defined.
Then define properly the request. "Character" in Java means "Unicode scalar value" {\u0000 ? \u10FFFF}.
And of course, if the reason why you doing (?)
It is irrelevant because it was not stated in the request.
  • 0

I have a really hard time believing any "programmer" could be eliminated by the fizzbuzz question (I wish I had easy questions like that for my interviews :/)

Personally I think most "interviews" for developers are ridiculous and are usually aimed at making the person fail (only tool you have are pencil and paper and the questions are most of the time extremely obscure and could be answered with more time/better tools)

I know most people I work with that are "good" at interviews are usually just that, most of their code usually look like crap.

  • 0

That's the whole pitfall of FizzBuzz (unless you do duplicate checks, which is usually not wanted)

Could you give the solution? Or is the solution language specific, like Python assigment:

A, B = B, A 

But still, internally I'm sure a temporary variable(s!) is being used.

EDIT: Forgot to add my solution.

void FizzBuzz()
{
	for (int num = 1; num  &lt; 101; num ++)
	{
		bool multiple = false;
		if (num % 3 == 0)
		{
			cout &lt;&lt; "Fizz";
			multiple = true;
		}
		if (num % 5 == 0)
		{
			cout &lt;&lt; "Buzz";
			multiple = true;
		}
		if (!multiple)
			cout &lt;&lt; num;
		cout &lt;&lt; endl;
	}
}
[/CODE]

I'm still not sure if it's better to declare a variable outside of the loop, but I'm fairly sure it will be optimized by the compiler.
And my solution is fairly readable (I hope).

Why not use an else clause rather than a variable?
[code]void FizzBuzz()
{
        for (int num = 1; num  &lt; 101; num ++)
        {
                if (num % 3 == 0)
                {
                        cout &lt;&lt; "Fizz";
                }
                else if (num % 5 == 0)
                {
                        cout &lt;&lt; "Buzz";
                }
                else
                        cout &lt;&lt; num;
                cout &lt;&lt; endl;
        }
}

  • 0

Why not use an else clause rather than a variable?

Because in the case of %3 && %5 you need to print 'FizzBuzz'. Now you don't and have failed the assignment (into it's pitfall).

That's why I have a boolean variable that keeps track of whether it printed "Fizz" OR "Buzz". I thought about doing

it differently, something with scopes but that wouldn't do much and my solution is fairly readable and simple.

  • 0

Why not use an else clause rather than a variable?

void FizzBuzz()
{
        for (int num = 1; num  &lt; 101; num ++)
        {
                if (num % 3 == 0)
                {
                        cout &lt;&lt; "Fizz";
                }
                else if (num % 5 == 0)
                {
                        cout &lt;&lt; "Buzz";
                }
                else
                        cout &lt;&lt; num;
                cout &lt;&lt; endl;
        }
}

You failed!

You're missing the FizzBuzz state (if dividable by both 3 and 5 aka divisible by 15)

  • 0

I've been asked that question. As soon as you give the solution using modulus, they ask you to do it again without using modulus/multiplication/division.

I assumed by that you meant no arithmetic operations (including bitwise) whatsoever and was like hmm that's impossible. But, I see it was only the particular types.

 

EDIT: well other than just comparisons over and over...  :laugh:

  • 0

 

  • 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)

I think this is a poor question because the only solution is not really an solution since it contains defects that break the intended purpose. Clever tricks with potentially subtle bugs aren't really clever tricks at all. Personally, I would have just given an inline asm solution that only used registers and pointed out that the only memory accesses would be the fetch/storeback of A&B and that no temporary exists in memory. It's not clever and the compiler will do it automatically anyway, but it works in all cases.

 

EDIT: There's also an XOR solution for this, but it has caveats in practice also.

  • 0

I rely on their ability to solve logical problems using their own made up syntax. I've only had to hire once though so my experience in it is limited. My train of thought was that I prefer that they can solve complex problems instead of code complex solutions.

 

FizzBuzz is great and all, but I prefer someone who can learn it quickly as opposed to someone that can (re)code it efficiently; let's be honest, most of the people who pass a fizzbuzz test have already done or practiced a fizzbuzz test. I have (and for merits of ability it's in my interest to inform you all I passed it, but of course).

 

 

In the end it worked out great. They were a stronger programmer than I am, which isn't that hard to do lol.

  • Like 2
  • 0

Hello,

I actually read you guys talk about FizzBuzz and I think Im missing something:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace fizzbuzz
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i=1;i<101;i++)
            {
                if   ((i % 3 == 0) && (i %5==0))
                {
                    Console.WriteLine("FizzBuzz");
                }
                else if (i % 5 == 0)
                {
                    Console.WriteLine("Buzz");
                }
                else if (i%3==0)
                {
                    Console.WriteLine("Fizz");
                }
                else
                {
                    Console.WriteLine(i);
                }
            }
            Console.ReadLine();
        }
    }
}

Something wrong with the code? :)
  • 0

Hello,

I actually read you guys talk about FizzBuzz and I think Im missing something:

 

Something wrong with the code? :)

 

 

Your code should work... but you might want to think about efficiency. If the number is divisible by 3, but not 5, you end up checking if the number is divisible by 3 twice and 5 twice.

 

But efficiency can be misleading. Should we optimize for (code) space efficiency, memory efficiency, or time efficiency... and how much longer should we assume a multiply/divide/modulus takes than an add?

  • 0

Your code should work... but you might want to think about efficiency. If the number is divisible by 3, but not 5, you end up checking if the number is divisible by 3 twice and 5 twice.

 

But efficiency can be misleading. Should we optimize for (code) space efficiency, memory efficiency, or time efficiency... and how much longer should we assume a multiply/divide/modulus takes than an add?

No point in wasting time or effort on simple optimizations that the compiler is going to do for you anyway: it just obfuscates the high level code for no benefits in practice. Same with throwing away assignments to temporary variables.

  • 0

No point in wasting time or effort on simple optimizations that the compiler is going to do for you anyway: it just obfuscates the high level code for no benefits in practice. Same with throwing away assignments to temporary variables.

 

I absolutely agree. However, your interviewer is going to have some questions for you after you finish writing the code. It's good to have some answers about efficiency, and other possible ways to write it.

It's a shame this topic got so hopeless devoted to beating the dead FizzBuzz horse. There are much more interesting questions that are more likely to be asked. Other than Hulu, who asked me to code FizzBuzz, every other interview I have been on have asked questions about linked lists... and sometimes about doubly linked lists.

  • 0

I absolutely agree. However, your interviewer is going to have some questions for you after you finish writing the code. It's good to have some answers about efficiency, and other possible ways to write it.

True that, any interviewer worth their salt will try to explore the problem and see your logical processes. The thing is, I see suggestions to do those sort of thing in real code in spots where it is obviously not any sort of bottleneck all of the time. In practice, I think it is focusing on the wrong thing in real world optimization.

 

It's a shame this topic got so hopeless devoted to beating the dead FizzBuzz horse. There are much more interesting questions that are more likely to be asked. Other than Hulu, who asked me to code FizzBuzz, every other interview I have been on have asked questions about linked lists... and sometimes about doubly linked lists.

I've heard google asks some difficult questions (none of that FizzBuzz). Another question I've heard is the algorithm for palindromes, and then to step it up to more difficulty, finding the sub palindromes (including shifted palindromes, e.g. abbattttttttttt, where 'abba' and 'bb' are matches).

  • 0

True that, any interviewer worth their salt will try to explore the problem and see your logical processes. The thing is, I see suggestions to do those sort of thing in real code in spots where it is obviously not any sort of bottleneck all of the time. In practice, I think it is focusing on the wrong thing in real world optimization.

 

I've heard google asks some difficult questions (none of that FizzBuzz). Another question I've heard is the algorithm for palindromes, and then to step it up to more difficulty, finding the sub palindromes (including shifted palindromes, e.g. abbattttttttttt, where 'abba' and 'bb' are matches).

 

I've had all of those logical questions (fizzbuzz, palindromes, you name it) on tests and exams for Java, in my 1st year of college (1st semester, really); it really pushes the logical thinking forward so when a student starts learning higher maths, physics and programming it can use the rational thinking to think out of the box.

 

by the way: i'm not a programmer :)

 

the problem solving aspect is one of the most valuable things a programmer must have (not only just the programmer, but since this is the topic...), not to mention code knowledge and the ability to learn new stuff. I've had questionable interviews made by psychologists that didn't know jack about the job i was being interviewed (and therefor they used questions that anybody could find on the interwebs, not really doing a good job filtering the interviewer really) or being asked incredible dumb and trick questions that made me want to question why should i want to join an enterprise that can't even do a proper interview; when i answered all those questions i realized that all they wanted is someone that was good but for cheap. :/

 

so, answering OP (this thread is kind of oldie...2012, eh?): my favorite question i ever had in a interview was:

- HR woman: "well lets see... i think for starting the paycheck will be 1400?..."

- Praetor: /does an incredible stunned face since i don't even get 1000? (tough days we are getting in my country)... 1400? for starting is a very welcome jump!

- HR woman: "oh... you seem really upset; i think we can push to 1500? + bonus, is that OK for you?"

- Praetor: / eyes pupils change to euro signs. :woot:

  • Like 2
  • 0

I've had all of those logical questions (fizzbuzz, palindromes, you name it) on tests and exams for Java, in my 1st year of college (1st semester, really); it really pushes the logical thinking forward so when a student starts learning higher maths, physics and programming it can use the rational thinking to think out of the box.

 

by the way: i'm not a programmer :)

 

the problem solving aspect is one of the most valuable things a programmer must have (not only just the programmer, but since this is the topic...), not to mention code knowledge and the ability to learn new stuff. I've had questionable interviews made by psychologists that didn't know jack about the job i was being interviewed (and therefor they used questions that anybody could find on the interwebs, not really doing a good job filtering the interviewer really) or being asked incredible dumb and trick questions that made me want to question why should i want to join an enterprise that can't even do a proper interview; when i answered all those questions i realized that all they wanted is someone that was good but for cheap. :/

 

so, answering OP (this thread is kind of oldie...2012, eh?): my favorite question i ever had in a interview was:

- HR woman: "well lets see... i think for starting the paycheck will be 1400?..."

- Praetor: /does an incredible stunned face since i don't even get 1000? (tough days we are getting in my country)... 1400? for starting is a very welcome jump!

- HR woman: "oh... you seem really upset; i think we can push to 1500? + bonus, is that OK for you?"

- Praetor: / eyes pupils change to euro signs. :woot:

I think you are absolutely right: many of these are just simple 1st year assignment type things. And, really, they are just used to weed out applicants who can't even do that much. At the same time when you start to step up the difficult and have them work through successively more difficult versions of a similar problem, you get a feel for how the applicant approaches problem solving. That's how I'd conduct an interview myself. For example, asking the interviewee how they'd handle arbitrary sized swaps in the case of the integer swapping, asking what the potential problems are; or in the case of the palindromes asking for a better complexity solution than what is probably going to be offered. Just seeing if they can reason through things like that.

 

You know, now that you pointed out the thread is from 2012, I'm not even sure HOW I managed to get to it. I could have sworn I clicked on the updated threads or spy and saw it there. I rather do like your answers though. I think they fit the bill better for favorites.

  • 0

Guys, this thread is from 2012.

That's my fault. I didn't notice that when I initially posted. But like I said before, I'm not even sure how I ended up on the thread to post since I only go to threads though the spy or thread lists.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Amazon Prime Day slashes Samsung's newest Galaxy Watch Ultra by 45 percent by Karthik Mudaliar Samsung’s flagship Android smartwatch has received one of its steepest Prime Day cuts. Amazon has dropped the 2025 Samsung Galaxy Watch Ultra in Titanium Blue to $357.24, saving buyers around $292 from its $649.99 list price. That's a 45 percent discount (purchase link below). The 47mm Galaxy Watch Ultra uses a titanium casing and a 1.5-inch Super AMOLED display with a resolution of 480 x 480 and peak brightness of 3,000 nits. It includes LTE connectivity, Bluetooth 5.3, Wi-Fi, NFC, and dual-frequency L1+L5 GPS for more accurate outdoor route tracking. The 2025 model has 64GB of storage, a 590mAh battery, sapphire crystal glass, 10ATM water resistance, IP68 protection, and MIL-STD-810H durability testing. Its health and fitness tools include heart rate monitoring, sleep coaching, Energy Score, Running Coach, body composition analysis, temperature sensing, and ECG support, where available. This model is best suited to Android users who regularly run, hike, cycle, or train outdoors and want cellular access without carrying a phone. The larger battery, rugged construction, bright display, and dedicated Quick Button also make it a stronger option than Samsung’s regular Galaxy Watch models for extended workouts and demanding environments. Grab the Titanium Blue Galaxy Watch Ultra before the Prime Day price resets: Samsung Galaxy Watch Ultra (2025) [Sold and Shipped by Amazon] Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • Google begins rolling out its post-Epic Play Store billing model next week by Karthik Mudaliar Google has confirmed that its redesigned Play Store billing and fee structure will take effect on June 30, 2026, in the United States, the United Kingdom, and the European Economic Area. The changes will let eligible developers offer their own payment systems or send users to an external website for purchases, while separating Google’s platform service fee from the cost of using Google Play Billing. The rollout puts concrete dates and detailed rate cards behind the broader Android policy overhaul Google announced in March. That announcement followed a proposed settlement with Epic Games intended to resolve their long-running disputes over app distribution and payments, although the U.S. portion of the agreement still requires court approval. Under the new billing choice program, developers selling digital content or services can display an alternative payment option alongside Google Play Billing. They may also direct users to their own websites to complete a purchase. Developers can use Google’s standard payment-choice screen or design one that complies with the company’s user-interface rules. Choosing another payment processor does not eliminate Google’s cut altogether. The company will continue charging a service fee for transactions associated with apps distributed through Google Play, regardless of whether payment is handled by Google, an alternative provider, or a developer’s website. Google argues that this fee covers the value and infrastructure provided by Android and the Play Store. For developers earning up to $1 million annually, the service fee will generally be 10 percent. That rate also applies to auto-renewing subscriptions. When Google Play Billing is used in the U.S., U.K., or EEA, Google will add a separate 5 percent billing fee, and developers processing payments elsewhere will not pay that additional charge. This means Google’s familiar flat 30 percent commission is disappearing, but developers will not necessarily see a dramatic reduction on every transaction. An in-app purchase from an existing user processed through Google Play Billing can still reach a combined 30 percent. The biggest savings are likely to come from subscriptions, smaller developers covered by the $1 million tier, and companies able to move customers to their own payment infrastructure. Google is also offering lower rates through its Apps Experience and revamped Games Level Up programs. Apps and games that satisfy the company’s requirements can qualify for 15 percent service fees on new-install transactions and 20 percent on existing-install transactions. The criteria include performance and reliability standards, support for additional Android device categories, and selected platform features. Those program rates are scheduled to become available in the initial markets and Australia on September 30. For consumers, the immediate effect will depend on whether developers adopt alternative payments and pass any savings on through lower prices. For developers, however, June 30 begins a more flexible but considerably more complicated Play Store economy in which distribution, billing, install dates, revenue thresholds, and program participation can each affect Google’s final cut. Google is also separately developing a Registered App Stores program designed to simplify the installation of qualifying third-party stores. That initiative is expected to arrive with a major Android release later in 2026 and will launch outside the U.S. first. Google says the rest of the world will receive the changes by September 30, 2027, although billing rates for markets outside the US, UK, and EEA have not yet been announced.
    • 38% off a super insane price is still an INSANE price.
    • 1TB Samsung T9 and Samsung 9100 PRO SSDs are now selling at great prices by Fiza Ali Amazon is now offering the 1TB variant of Samsung T9 and Samsung 9100 PRO SSD at great prices with limited-time 38% and 39% discounts, respectively, so you may want to check them out if you have been looking to upgrade your storage solution. The Samsung T9 connects via a USB 3.2 Gen 2x2 (20Gbps) interface and delivers sequential read speeds of up to 2,000MB/s and sequential write speeds of up to 1,950MB/s, making it suitable for transferring large files, backing up data, and handling high-resolution media content. When it comes to the security features, the SSD includes AES 256-bit hardware encryption to help protect sensitive data. Designed for portability, the drive is reportedly resistant to drops from heights of up to 3 metres. Furthermore, it operates within a temperature range of 0°C to 60°C and can be stored at temperatures between -40°C and 85°C. Samsung Magician Software is included for drive management, firmware updates, performance optimisation, and health monitoring. Finally, the T9 is certified to multiple international standards, including CE, FCC, UL, UKCA, and RoHS 2 compliance, and is backed by a five-year limited warranty as well. 1TB Samsung T9 SSD: $179.99 (Amazon US) - 38% off The Samsung 9100 PRO uses the M.2 2280 form factor and connects through a PCIe 5.0 x4 interface with NVMe 2.0 support. Built with Samsung V-NAND TLC flash memory, an in-house controller, and 1GB of low-power DDR4X cache memory, the 9100 PRO is engineered for high-performance computing and gaming workloads. Furthermore, the SSD delivers sequential read speeds of up to 14,700MB/s and sequential write speeds of up to 13,300MB/s. Random performance is rated at up to 1,850,000 IOPS for reads and up to 2,600,000 IOPS for writes, depending on system hardware and configuration. The drive supports TRIM, S.M.A.R.T monitoring, automatic garbage collection, and device sleep mode to help maintain performance and efficiency over time. In terms of security features, it includes AES 256-bit encryption, TCG Opal support, and IEEE 1667 compliance. The 9100 PRO operates within a temperature range of 0°C to 70°C, is rated for 1.5 million hours MTBF, and can reportedly withstand shocks of up to 1,500G for 0.5 milliseconds. Finally, Samsung Magician Software is also included for firmware updates, performance monitoring, drive management, and optimisation. 1TB Samsung 9100 PRO SSD: $206.99 (Amazon US) - 39% off Alternatively, you can also check out other SSD deals here. Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Dedicated
      Scoobystu earned a badge
      Dedicated
    • First Post
      Tom Schmidt earned a badge
      First Post
    • One Month Later
      D0nn13 earned a badge
      One Month Later
    • Rookie
      +ChiefOfNeo went up a rank
      Rookie
    • One Year In
      Tom Schmidt earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      463
    2. 2
      +Edouard
      177
    3. 3
      PsYcHoKiLLa
      124
    4. 4
      Michael Scrip
      81
    5. 5
      Xenon
      76
  • Tell a friend

    Love Neowin? Tell a friend!