Ok! I did not form any equations.

First I calculated the maximum tax for each slab

like for

300000 600000 900000 (slabs)

10 20 30 (percentage)

I would form an array like the following

for 300000-600000 max tax = (600000-300000)*10/100 = 30k

for 600000-900000 max tax = 300000 * 20/100 = 60k

This means if someone is paying 30k tax, then his/her salary would be exactly 600000 or if someone is paying exactly 30k + 60k = 90k tax, his/her salary would be exactly 900000

so what I did next was, take a variable salary and initialize it to slab[0] (300000 in the sample case). Here I am assuming that no oneâ€™s salary can be below slab[0] which is a pure assumption of mine which matched with the assumption of the problem setter also by chance.

next, I took the tax paid, and started subtracting from it the max tax for each slab until I could not subtract it anymore or I subtracted the max taxes for all slabs. Concurrently, I am also adding the range of slab in salary.

for example if tax paid = 100k,

I would subtract from it max tax for first slab so tax paid = 100 - 30 = 70k

and I would add (600000 - 300000) in salary and then there are some terminating conditions.

Hereâ€™s my code

Note: I have pushed an extra element at the end of maxTax which is infinite.

vector slab, percentage, maxTax, salaryVector;

int rebate;

```
int calculateSalary(int tax){
int salary = slab[0];
unsigned int i;
for(i=0; i<maxTax.size(); i++){
if(tax < maxTax[i] || i == maxTax.size()-1){
salary = salary + (tax*100)/(percentage[i]);
//cout << i << " " << salary << endl;
}
else{
salary = salary + (maxTax[i]*100) / percentage[i];
tax-=maxTax[i];
}
}
return salary+rebate;
}
```

Let me know if you donâ€™t understand anything.