Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 886 Bytes

ThinkFirst.md

File metadata and controls

30 lines (25 loc) · 886 Bytes

##Consider First

###Ask Questions

  • what are the data types
  • How much data is there?
  • Do we have time complexity or space complexity requirement
  • What does the array hold? Numbers? Characters? Strings?
  • Are these integers all positive?
  • are there any duplicates?
  • is the array sorted first?
  • What's our return / return type?

###Think first

  • would the input cause overflow? so that I shall use long instead of integers?
  • would the input be invalid?

###Think

  • let me brainstorm the algorithm to handle this

###Design the algorithm

  • what's the time and space time complexity?
  • what happens if there is a lot of data
  • Does the design cause other issues?
  • If there are other limitations, did you make the right trade-off

####Test

  • 0, negative, null, maximums, minimums
  • use error: what happends if the user passes in null or negative value
  • then test the normal case