- accepted / - tried
It is quite common to see switches and checkboxes in web apps.
Implement useToggle() to make things easier
useToggle()
function App() { const [on, toggle] = useToggle() ...}
What is time & space complexity of your approach?
Try it out
Console