boston-code-coffee / workshop

4 stars 3 forks source link

Prompt for the two sum problem (Finding Sums in Arrays) #4

Closed parthasarathydNU closed 4 months ago

parthasarathydNU commented 4 months ago

Adding "Finding Sums in Arrays" Challenge

Overview

This PR introduces a new coding challenge titled "Finding Sums in Arrays," aimed at practicing the use of maps (hash tables) to solve common algorithmic problems. The challenge is divided into two parts: the "Two Sum" problem and its extension, the "Three Sum" problem. This challenge is designed to encourage critical thinking, problem-solving skills, and the exploration of different algorithmic approaches.

The submission follows this structure

# Title
<!------ ---->

principle: maps

## Prompt Description
<!------ ---->

### Example Input and output
<!------ ---->

### Before You Start Coding

1. **Think About Assumptions**:
2. **Ask Clarifying Questions**: 
3. **Consider Different Approaches**: 

Kindly review this challenge, provide feedback, and suggest improvements. Our goal is to create an engaging, educational experience for all participants.

boston-code-coffee commented 4 months ago

Very Cool. I will review this tonight. Thank you.

boston-code-coffee commented 4 months ago

I have a bit of time before work starts.

Feedback:

Restructure the sections. Pose the challenge at the top. "Given an array, find two elements which sum to a value x" at the top.
Discuss a problem and discuss "clarifying questions" and "test cases." Then, include the material on "solve this with a map."

Add a new section: Clarifying Questions. It's essential to emphasize. I often see interview candidates failing to ask questions of the prompt. Find and discuss edge cases.

Add a new section: Test Cases. I frequently see candidates failing to test their solutions during the interview. They incorrectly feel time pressure, dash off an answer, and declare it done, leading to a poor answer.

Add sections to the end: Follow up study. Our prompts are good but rely on more profound concepts. For example, this problem is an example of the scary-sounding subject "Dynamic Programming," but for obvious reasons, it comes up with many challenges. Here are a few links to DP. Please consider adding these or some others you think would be better. https://en.wikipedia.org/wiki/Dynamic_programming https://mat.gsia.cmu.edu/classes/dynamic/dynamic.html https://www.topcoder.com/thrive/articles/Dynamic%20Programming:%20From%20Novice%20to%20Advanced

I will update the other prompts with links to follow up next week.

parthasarathydNU commented 4 months ago

I think the PR description is not representative of the actual file that I am committing as part of the PR.

I have followed the structure you mentioned in the Markdown file that I am committing.

Will update the PR to accurately reflect the changes.

Also I was wondering if we need dynamic programming to solve the Two Sum / Three Sum problem, I was thinking along the lines of using HashMaps and solving it through an iterative process without any recursion / greedy approach involved.

Use a map, and check if the complement (target - number) already exists in the map, if not add the current number and it's corresponding index to the map, if it does exist we have our answer.

But I notice that I missed adding the test cases and study resources part, will include that.

parthasarathydNU commented 4 months ago

@boston-code-coffee - added a section for test cases and further study here : https://github.com/boston-code-coffee/workshop/pull/4/commits/3468912bef00fd0b19dec1a74ebf85035663c26d