When it comes to weight loss, maintaining a calorie deficit is the only thing that matters. If you can achieve a calorie deficit with your diet alone, it can lead to weight loss without performing exercise.
However, if you want to specifically lose body fat and retain lean muscle mass, ensuring adequate protein intake within your diet and performing physical activity is necessary, apart from maintaining a calorie deficit.