(deyim) If you hit on an idea or a solution to a problem, or hit upon it, you think of it: "After running through the numbers in every possible combination, we finally hit on a solution."
(deyim) If someone hits on you, they speak or behave in a way that shows they want to have a sexual relationship with you: "She was hitting on me and I was surprised and flattered
If you hit on an idea or a solution to a problem, or hit upon it, you think of it. After running through the numbers in every possible combination, we finally hit on a solution. = stumble on
If someone hits on you, they speak or behave in a way that shows they want to have a sexual relationship with you. She was hitting on me and I was surprised and flattered