linkedin Skip to Main Content
Just announced: We now support interviewing in spreadsheets!
Back to blog

4 ChatGPT Prompt Templates to Enhance Your Coding Interview Process

Hiring Developers

Does this sound like your Twitter feed?

Blah blah blah ChatGPT blah blah blah AI blah LLM! 🤖🌎💥

If you have any presence on the internet, you are likely well-acquainted with the discussions surrounding ChatGPT, Bard, and other emerging Large Language Model (LLM) applications.

Although there is much hype around these buzzwords, these tools hold great potential to improve your work processes significantly.

As a coding interview platform, CoderPad is particularly interested in utilizing ChatGPT to enhance the interview process.

We find the modern conversation about the validity of using co-pilot and ChatGPT as a tool in interviewing as a similar conversation to the one we were having decades ago about StackOverflow and Google.   

Amanda Richardson – CEO of CoderPad

We created the CoderPad Interview ChatGPT integration to enable interviewers to observe how candidates critically approach problems and utilize modern toolsets. Many users of our ChatGPT integration use it as a collaboration tool during interviews with candidates. They present a question to the candidate and allow them to use the integration as they would Google or StackOverflow. 

While the initial goal was to enhance the candidate experience, we’ve also started exploring how ChatGPT can ultimately enhance the hiring manager interview experience too.

One of the primary advantages of LLMs is their ability to automate numerous tedious thought processes. This allows you to focus your critical thinking efforts on more impactful matters, such as determining if a candidate is a suitable cultural fit for your team, guiding your team through a crucial project deadline, or adapting your application architecture to accommodate an unforeseen integration.

So if you’re ready to outsource your tedious work to the new generation of developer tools, check out this list of ways to improve your interview processes with ChatGPT:

✅ The screenshots below are from CoderPad Interview’s new AI Chat feature. It’s available to all CoderPad subscribers — you can find out more about how to access it in your account here. If you’re not yet a CoderPad subscriber, you can sign up for a free trial to access the AI Chat feature.

Generate test data

Finding data that mimics what you have in production without compromising user data security can be challenging. 

And often, even if you have a data set, you must translate it from one format – like a CSV file – to another – like JSON or XML. 

You can now save yourself the hassle by having ChatGPT do all that for you. Here’s the template:

Generate [data structure] that contains [number of test data][data type] with randomly generated values for the following keys: [list of keys or fields].

For example, say I need to mimic some customer data for an eCommerce application assessment. I’d write the following prompt to ChatGPT:

Generate a JSON array that contains five JSON objects with randomly generated values for the following keys: “name,” “location,” “phone,” and “customer_id.”

And GPT auto-magically generates a test array for me:

Click to enlarge (this goes for all images in this post).

Oops, I got my applications mixed up, and I need XML instead. No worries:

A screenshot of the chatgpt integration with a response of test data in xml format.

Perhaps you want it as a CSV too?

A screenshot of the chatgpt integration with a response of test data in CSV format.

You can easily add more objects, data fields, and formats. 

Translate starter code snippets from one language to another

Often you don’t mind what languages your candidates are proficient in as long as they know how to code and understand software engineering fundamentals. If this is the case, you’ll usually stick with a language-agnostic interview question where you provide the candidate with a question prompt and allow them to pick a language and answer it from scratch.

However, there may be reasons you don’t want your candidates writing everything from scratch – maybe you want them to focus on a challenging part of the implementation, or perhaps you want to provide them with starter code to save you both time in the interview.

The problem is, providing starter code for several languages is tedious – especially if you’ve never used that language before.

But it’s not tedious if you use ChatGTP.

The prompt template is simple:

Convert this code to [new programming language] : "[original code snippet]".

Take this interview question, for example. It asks users to improve the performance of the given code snippet in Python — but our candidate is more comfortable with JavaScript than Python.

So our prompt would be:

Convert this code to Javascript:

<em>"import random

def generate_random_list(n):
    result = []
    for i in range(n):
        x = random.randint(1,n)
        if x not in result:
            result.append(x)
    return result

## Don't edit testcases below, it's cheating!

import time

# SMALL TEST
start = time.time()
generate_random_list(100)
test_time = (time.time() - start) * 1000
print(f'Small test took {test_time:.1f} ms')
assert test_time < 100, 'Too slow!'

# LARGE TEST
start = time.time()
generate_random_list(20000)
test_time = (time.time() - start) * 1000
print(f'Large test took {test_time:.1f} ms')
assert test_time < 100, 'Too slow!'"
</em>Code language: Python (python)

This is the converted code that ChatGPT produces:

function generateRandomList(n) {
  const result = [];
  for (let i = 0; i < n; i++) {
    const x = Math.floor(Math.random() * n) + 1;
    if (!result.includes(x)) {
      result.push(x);
    }
  }
  return result;
}

// Don't edit testcases below, it's cheating!

// SMALL TEST
const startSmall = performance.now();
generateRandomList(100);
const testTimeSmall = performance.now() - startSmall;
console.log(`Small test took ${testTimeSmall.toFixed(1)} ms`);
if (testTimeSmall > 100) console.error('Too slow!');

// LARGE TEST
const startLarge = performance.now();
generateRandomList(20000);
const testTimeLarge = performance.now() - startLarge;
console.log(`Large test took ${testTimeLarge.toFixed(1)} ms`);
if (testTimeLarge > 100) console.error('Too slow!');
Code language: JavaScript (javascript)

And here’s what it looks like if we replaced “JavaScript” in our prompt with the relatively obscure “OCaml” language:

open Printf
open Random

let generate_random_list n =
  let rec aux result count =
    if count < n then
      let x = 1 + Random.int n in
      if not (List.mem x result) then
        aux (x :: result) (count + 1)
      else
        aux result count
    else
      result
  in
  aux [] 0

(* Don't edit testcases below, it's cheating! *)

(* SMALL TEST *)
let () =
  let start = Unix.gettimeofday () in
  let _ = generate_random_list 100 in
  let test_time = (Unix.gettimeofday () -. start) *. 1000.0 in
  printf "Small test took %.1f ms\n" test_time;
  if test_time > 100.0 then print_endline "Too slow!"

(* LARGE TEST *)
let () =
  let start = Unix.gettimeofday () in
  let _ = generate_random_list 20000 in
  let test_time = (Unix.gettimeofday () -. start) *. 1000.0 in
  printf "Large test took %.1f ms\n" test_time;
  if test_time > 100.0 then print_endline "Too slow!"
Code language: OCaml (ocaml)

The hardest part is coming up with the original starter code. After that, it’s a matter of seconds for ChatGPT to convert the code to another language. How’s that for a time saver?

Create test cases 

Already have an interview question in mind but don’t want to spend time working out the test cases to validate your candidates’ code? Use ChatGPT.

For the template, use:

Create a test case for the technical interview question and starter code below. The question is in the format of a comment at the top of the code snippet: "[code snippet you need test cases for]".

I plugged this Code Challenge question into ChatGPT and asked it to give me test cases. You’ll need to include the instructions as comments at the top of the starter code:

Create a test case for the technical interview question and starter code below. The question is in the format of a comment at the top of the code snippet:

<em>'''
This function is supposed to rotate a square matrix clockwise, but it is not behaving as expected. Can you take a look?
Bonus points if you can keep the computation in-place, without significant extra memory (you can declare a few variables but not a whole new array )
'''

def rotate_in_place(matrix):
    n = len(matrix)
    for r in range(n):
        for c in range(n):
            matrix[r][c] = matrix[n-c-1][r]

MATRIX1 = [
    [ 1,  2,  3,  4],
    [ 5,  6,  7,  8],
    [ 9, 10, 11, 12],
    [13, 14, 15, 16]
]

EXPECTED1 = [
    [13,  9,  5,  1],
    [14, 10,  6,  2],
    [15, 11,  7,  3],
    [16, 12,  8,  4]
]

MATRIX2 = [
    [ 1,  2,  3,  4,  5,  6,  7],
    [ 8,  9, 10, 11, 12, 13, 14],
    [15, 16, 17, 18, 19, 20, 21],
    [22, 23, 24, 25, 26, 27, 28],
    [29, 30, 31, 32, 33, 34, 35],
    [36, 37, 38, 39, 40, 41, 42],
    [43, 44, 45, 46, 47, 48, 49]
]

EXPECTED2 = [
    [43, 36, 29, 22, 15,  8,  1],
    [44, 37, 30, 23, 16,  9,  2],
    [45, 38, 31, 24, 17, 10,  3],
    [46, 39, 32, 25, 18, 11,  4],
    [47, 40, 33, 26, 19, 12,  5],
    [48, 41, 34, 27, 20, 13,  6],
    [49, 42, 35, 28, 21, 14,  7]
]</em>
Code language: PHP (php)

This is the test function ChatGPT responded with:

def test_rotate_in_place():
    test_cases = [
        (MATRIX1, EXPECTED1),
        (MATRIX2, EXPECTED2)
    ]

    for matrix, expected in test_cases:
        rotate_in_place(matrix)
        assert matrix == expected, f"Expected: {expected}, but got: {matrix}"

    print("All test cases passed.")

test_rotate_in_place()
Code language: PHP (php)

You may have to reframe your prompts if you have a particularly complex use case you want to test for, as often ChatGPT will generate boilerplate code but will not generate specifics without prompting. 

In other words, it may not consider non-obvious or nuanced edge cases, and you may need to provide it with feedback so that it can generate the code necessary to test those edge cases. Even then, though, you’ll still probably spend less time writing the code for those test cases than you would without ChatGPT.

Come up with question ideas

One of the hardest parts of any interview is coming up with the questions themselves. But if you have a general idea of what you want to assess for, ChatGPT can help you come up with some questions.

The key with prompt creation is 1) to be specific and 2) to reframe the question to get the response if the first few tries aren’t precisely what you’re looking for. Take this initial prompt:

“Generate five technical interview questions to assess a senior react developer’s ability to work with an eCommerce application that stores data in a MongoDB database. These questions should require the developer to demonstrate their coding and critical thinking skills. “

Here’s what ChatGPT produced: 

How would you design the React component structure for an eCommerce application with product listing, product details, shopping cart, and checkout features? Please explain the reasoning behind your choices, and discuss the use of class components, functional components, and hooks.

Imagine you need to implement a product search feature that provides autocomplete suggestions as the user types in a search query. Describe your approach to implementing this feature in React, considering performance and user experience. How would you handle debouncing and fetching data from the MongoDB database?

In an eCommerce application, it's important to ensure that the shopping cart remains consistent across different devices and sessions for a logged-in user. How would you manage the state of the shopping cart in a React application? Discuss your approach to persisting the cart data, synchronizing it with the MongoDB database, and handling potential conflicts.

Our eCommerce application has a dashboard for sellers to manage their products, orders, and customer information. Implement a higher-order component (HOC) or custom hook to handle user authentication and authorization, ensuring that only users with the "seller" role can access the dashboard. How would you manage server-side authentication and role-based access control using the data stored in MongoDB?

As the application grows, performance optimization becomes critical. Describe your approach to optimizing the performance of the eCommerce React application, considering techniques like lazy loading, code splitting, and memoization. How would you leverage the MongoDB database to improve the performance of queries and data retrieval?

Not bad, but I want the questions to be framed so that the candidate understands that they need to code to solve it. So I responded with: 

“Reframe these questions to imply that the candidate needs to answer the questions by writing code in an IDE.”

The response:


Write a sample React component structure for an eCommerce application with product listing, product details, shopping cart, and checkout features. Use class components, functional components, and hooks where appropriate, and include comments to explain the reasoning behind your choices.

Implement a product search component in React that provides autocomplete suggestions as the user types in a search query. Demonstrate how you would handle debouncing and fetching data from the MongoDB database in your implementation. Include comments to address performance and user experience considerations.

Implement a shopping cart component in a React application that remains consistent across different devices and sessions for a logged-in user. Write code to manage the state of the shopping cart, persist the cart data, synchronize it with the MongoDB database, and handle potential conflicts.

Create a higher-order component (HOC) or custom hook to handle user authentication and authorization in a seller dashboard, ensuring that only users with the "seller" role can access the dashboard. Demonstrate how you would manage server-side authentication and role-based access control using the data stored in MongoDB.

Assume you have an existing eCommerce React application. Write code samples to demonstrate how you would optimize its performance using techniques like lazy loading, code splitting, and memoization. Additionally, provide code examples to show how you would leverage the MongoDB database to improve the performance of queries and data retrieval.

Much better! I knew some questions would be better than others, which is why I prompted it for five questions rather than just one.

So the final template to generate interview questions will be:

Generate [desired number of questions] technical interview questions to assess a [job level][job title]'s ability to work with a(n) [type of application the candidate will be working with] application that [add any other business logic or tech stack info you'd like to assess the candidate on]. These questions should require the developer to demonstrate their coding and critical thinking skills. These questions should to imply that the candidate needs to answer the questions by writing code in an IDE.

Even with these templates you may need to reframe prompts more than once — and that’s okay! This is still a pretty new technology and it’s going to take time to figure out the best way to get the answers you want.

Of course we’re not finished saving ourselves time with ChatGPT.

To continue from our example above, let’s say I want to use the customer review question that ChatGPT provided in my upcoming technical interview. I probably want to include some starter code so the candidate isn’t wasting their time with trivial coding tasks – I want them to get straight into the stuff that will test their critical thinking. 

Save yourself some time and have ChatGPT write that starter code for you:

Write the scaffolding code for the third question that the candidate will need to flush out to complete.

The response:

import React, { useState } from 'react';

const ReviewForm = (props) => {
  const [name, setName] = useState('');
  const [rating, setRating] = useState('');
  const [comment, setComment] = useState('');

  const submitHandler = (e) => {
    e.preventDefault();
    // Write code to submit the review data to the server and update the state for reviews
    setName('');
    setRating('');
    setComment('');
  };

  return (
    <div>
      <h2>Write a customer review</h2>
      <form onSubmit={submitHandler}>
        <div>
          <label htmlFor="name">Name</label>
          <input
            type="text"
            id="name"
            placeholder="Enter name"
            value={name}
            onChange={(e) => setName(e.target.value)}
            required
          ></input>
        </div>
        <div>
          <label htmlFor="rating">Rating</label>
          <select
            id="rating"
            value={rating}
            onChange={(e) => setRating(e.target.value)}
            required
          >
            <option value="">Select</option>
            <option value="1">1 - Poor</option>
            <option value="2">2 - Fair</option>
            <option value="3">3 - Good</option>
            <option value="4">4 - Very Good</option>
            <option value="5">5 - Excellent</option>
          </select>
        </div>
        <div>
          <label htmlFor="comment">Comment</label>
          <textarea
            id="comment"
            value={comment}
            onChange={(e) => setComment(e.target.value)}
            required
          ></textarea>
        </div>
        <button type="submit">Submit review</button>
      </form>
    </div>
  );
};

export default ReviewForm;
Code language: JavaScript (javascript)

Boom. You just saved yourself a few hours (at least!) worth of work with just a few simple prompts.

Is that all?

Absolutely not! CoderPad is trailblazing the use of ChatGPT in interviews, but we’ve only scratched the surface regarding how you can use it in interviews. 

If you’re a CoderPad subscriber and have used ChatGPT in your interviews, we’d love to hear how YOU have been using it so we can share it with other CoderPad members.

🆓If you’re not currently using CoderPad, we’d encourage you to sign up for a free trial, give the ChatGPT integration a try, and let us know how it goes.

We look forward to seeing how ChatGPT makes your interviewing experience better!