Skip to content

Latest commit

 

History

History
66 lines (36 loc) · 1.81 KB

File metadata and controls

66 lines (36 loc) · 1.81 KB

Structured Problem Solving

In this section, we'll:

  1. Learn how to apply a structured problem solving approach.
  2. Practice this skill by solving a couple of exercise problems.

Problem Statement

Find the contiguous subarray within a one-dimensional array of numbers which has the largest sum

What's a contiguous subarray? https://www.quora.com/What-is-difference-between-subarray-and-contiguous-subarray

Step 1: Understand the problem

Video 1: https://www.youtube.com/watch?v=s2uRlOu4Nj8

Step 2: Come up with a plan

Video 2: https://www.youtube.com/watch?v=xWOumExKGF8

Step 3: Write code

Video 3: https://www.youtube.com/watch?v=wFI4xNGai6Q

Final Solution

Here's the final solution:

https://gitlab.com/snippets/1968149


FAQs

This problem was too difficult

Don't worry. Use this problem just as an example to understand the overall problem solving process. You will soon reach a point where you'll be able to solve such problems on your own.


Tips and Tricks

1. Run code on your own system:

Don't run your code directly on HackerRank or Edabit. It will be difficult for you to debug the code and you'll end up wasting a lot of time.

Instead:

  1. Install your programming language of choice on your system.
  2. Install VSCode - https://code.visualstudio.com/
  3. Write your own test cases
  4. Once the code works on your system, submit it on HackerRank / Edabit

2. Write Helper functions

  1. Break down your problem into small steps
  2. Create "helper functions" and test them individually.