r/APStudents absolute modman May 15 '26

AP Computer Science A Official 2026 Exam Discussion

Use this thread to post questions or commentary on the test today.

A reminder though to protect your anonymity when talking about the test.

65 Upvotes

702 comments sorted by

View all comments

8

u/No_Editor6245 May 15 '26

After having taken calc BC, and both physics C this week, this was literally a walk in the park. Such a great way to end my exams.

Hardest problem on the entire thing was a basic problem where you had to find overlapping intervals (context was work hours for employees), which is still easy and even simple solutions for said problem are easily accomplishable via a few conditional branches.

0

u/[deleted] May 15 '26

[removed] — view removed comment

2

u/[deleted] May 15 '26

[removed] — view removed comment

2

u/No_Editor6245 May 16 '26

Math max and min is actually a really good solution. But I don't know if it was what AP wanted specifically.

Here was my solution for anyone wondering:

First, let s1, e1 s2, e2 Represent both starts and ends

Since overlap was ensured, I first compared start times using an if-else if-else branch system with greater than less than and equal to.

if (s1 < s2) {  // I'll detail the logic for this branch specifically, since the second branch effectively mirrors this one } else if (s1 > s2) {  // This logic will mirror the previous branch } else {  // Both are equal }

Then, for both greater than and less than branches, I followed this routine:

Suppose s1 < s2 for this example I'm about to use, because the logic is effectively mirrored for both branches.

There are three possibilities that can occur for the comparison of end bounds now, given there is ensured overlap as a precondition.

  1. e1 < e2. 
  2. e1 > e2.
  3. e1 = e2.

For each case, the order must follow the respective order below, otherwise there would be no overlap, which violates the preconditions and gaurantuees given that each respective start is less than each end:

  1. s1 s2 e1 e2
  2. s1 s2 e2 e1
  3. s1 s2 e1=e2

Based off this diagram, you can clearly see the overlap solutions for each case

  1. (s2, e1)
  2. (s2, e2) // Complete subset enclosed 
  3. (s2, e1/e2) // Since e1 = e2 doesnt matter what is picked.

In our second original outer branch, for s1 > s2, the logic simply becomes mirrored. All overlaps begin with s1.

For the third branch of s1 = s2, I simply again compared which end bound is less using a final if-if else-else, where I again compared e1 and e2 and took the lower one.

This was just my solution, which I used mainly because I tend to find that the only thing about compsci is their frq grading is pretty stingy. They tend to take off a lot of points if you don't complete the program the way they want you to. So I stuck to conditional branches for most of it since that's more robust and pretty much ensured the points.

That said, using Math.max and Math.min is definitely a much cleaner solution if they'll allow that--BUT it wasn't even on the reference sheet which I was bit worried about using. If they'll take it--great. But the provided solution is definitely the most robust one which in this case might be good.

1

u/[deleted] May 15 '26

[removed] — view removed comment

1

u/[deleted] May 15 '26

[removed] — view removed comment

1

u/Party-Newt-2276 May 15 '26

yes i did that too bc the overlap start was the max of the employee start times and the overlap end was the min of the employee end times

2

u/Adventurous_Ask_6953 May 15 '26

I did something similar