Skip to content

The most asked interview question

Estimated time to read: 5 minutes

Arguably, the most asked question in coding interviews is the Two Number Sum. It is used by many Bigtechs and AAA Game Studios. You can see this question in many youtube videos, coding websites such as hackerank, leetcode, algoexpert ...

Agenda: Two Number Sum Coding Dojo

Introduction (5 minutes)

  1. Welcome participants to the dojo
  2. Introduce the Two Number Sum question as a common coding interview question
  3. Discuss the importance of problem-solving skills in coding interviews
  4. Briefly explain the rules and structure of the dojo
  5. Problem Explanation (10 minutes)

Provide a brief overview of the Two Number Sum question

  1. Define the problem and its requirements
  2. Discuss potential edge cases and constraints
  3. Review sample inputs and expected outputs
  4. Coding Session (50 minutes)

Problem restrictions and characterization

Write a function that will receive an array/vector/list of integers and a target number. Find two numbers inside the array that summed will match the target. You have to return both in a array/vector/list ordered.

Implement the solution in 3 different ways. Open the details only after you try. First approach:

1. Naive solution. O(N^2) time and O(1) space; - required to know this;

Can you make it faster?

2. Fastest solution. O(N) time and O(N) space; - this will make you

Can you make it not use much memory, but still be fast?

3. Fastest without mem allocation. O(N*log(N)) time and O(1) space;

Participants work on solving the Two Number Sum problem in pairs or small groups

  1. Emphasize the importance of communication and collaboration during the coding session
  2. Encourage participants to use a whiteboard or paper to sketch out their solutions
  3. Provide guidance and support as needed
  4. Code Review (20 minutes)

Participants share their solutions with the group

  1. Facilitate a discussion about each solution, highlighting strengths and areas for improvement
  2. Encourage participants to ask questions and provide feedback to their peers
  3. Discuss potential optimizations and alternative approaches to the problem
  4. Wrap-Up (5 minutes)

Recap the main takeaways from the dojo

  1. Encourage participants to continue practicing problem-solving skills on their own
  2. Thank participants for attending the dojo and provide any additional resources or support as needed.
  3. Note: The time allocation can be adjusted based on the group's needs and pace.