Can you attribute your poor AP Chemistry exam performance to luck, a bad teacher, poor preparation, or something like that? If you tried your best and had a fair shot/didn’t just have a fluke, and still got a 2, then maybe Chemical Engineering isn’t a good idea. But if it was just a bad day or you know you could’ve prepared better, it may still be an option.
Just to note: Chemical engineering is an incredibly difficult field, and it actually involves more physics and calculus than chemistry. Even being a high ranking math student in your high school is no guarantee that it won’t be difficult for you. It’s the same for other fields of engineering, but especially for chemical, electrical, and aero. That doesn’t mean you can’t try it, but you do have to be committed to working hard.
If you like “math and problem solving”, then yeah, computer science might be a possibility. Your school probably has an introductory computer science class that you can check out without committing to the major long term. For that matter, many departments do - could you take a mix of those classes? It’s especially possible with subjects like economics that more people are inclined to take as electives.