Can I snack without gaining weight if I run for 20-30 minutes after snacking?
It depends what you snack on, and how much, just because you consume calories does not mean you have to burn them out with physical exercise.
You see, when I was on my weight loss journey I had this vision for every calorie I consume, I have to burn it with physical exercise, so I wrote it all down in my notebook;
Apple = 50kcal, 10 minutes jogging
Banana = 100kcal, 20 minutes of jogging
Brown rice = 300kcal, 20 minutes of jogging, 30 minutes of biking
But this just simply is not the case thanks to our metabolism, we burn a certain amount of calories each day dependent upon your height, weight, and age. The absolute only way to lose fat is burn more energy than you exceed. eating an unhealthy snack every one in awhile does not mean you need to walk/jog to combat the weight gain from it. You need to remember that food is not the enemy, you should never be scared of food. Enjoy as much healthy snacks as you'd like without feeling the urge to go exercise it off, and moderately enjoy guilt snacks without feeling the urge to burn it off. I highly suggest an app like myfitnesspal, or lose it, to track your calories burned and calories consumed. That helped/helps me tremedously!