Programming Questions

  • Newest
  • Popular Tags
  • Ask A Question
  • Overlapping Rectangles Input
    I am confused as whether the question is expecting: an array of string or just a single string? "(0,0),(2,2),(2,0),(0,2),(1,0),(1,2),(6,0),(6,2)." to me this is a string. Would somebody please clarify?
    normanshengtaoli posted this question on 12/5/14 | overlapping, rectangle
    Answers
  • +
  • 1
  • -
  • Hey guys sorry for the confusion. The input is a string array with only one element which is the string of points where the first 4 make up the first rectangle and the last 4 make up the second rectangle. So ["(0,0),(2,2),(2,0),(0,2),(1,0),(1,2),(6,0),(6,2)"] is a string array with one string element being all the points.
  • +
  • 0
  • -
  • An example shown on the side has the wrong expected output too (though the one in the description is correct). The answer for the example "(0,0),(5,0),(0,2),(5,2),(2,1),(5,1),(2,-1),(5,-1)" is actually supposed to be 2 instead of 3 (meaning it's not just area to compare, but actually physically how many rectangles could fit, but assuming you can't change the orientation). The problem should also mention that the input rectangles will always be axis-aligned (otherwise this problem is way more difficult).
  • +
  • 0
  • -
  • Agreed, the question is written poorly. The examples given in the problem are strings, while the examples of incorrect test cases given are a single string inside of an array of length 1. The question expects inputs to be in the latter format: ["(0,0),(2,2),(2,0),(0,2),(1,0),(1,2),(6,0),(6,2)"]
  • +
  • 0
  • -
  • It is a string in an array. You can tell by the parameter in the main function named strArr. If it's a string it will be named str. If it's a number it will be named num, ect.
    Log in to write an answer.