#### Do the order of or operation matters in C++?

When I am changing the order of isPossible function then it’s giving wrong answer otherwise present code gives correct answer. I wanted to know why this is happening.
Here is the problem statement: https://leetcode.com/problems/partition-equal-subset-sum/submissions/
Here is my accepted solution

``````class Solution {
unordered_map<int, bool> um;
public:
bool isPossible(vector<int>&nums, int currentIndex, int sum){
if(sum == 0){
return true;
}
if(currentIndex >= nums.size() || sum < 0){
return false;
}
if(um.find(sum) != um.end()){
return um[sum];
}
// include present and recur for left elements
// =====> when I am changing the order of isPossible then it's giving wrong answer
bool result = isPossible(nums, currentIndex + 1, sum - nums[currentIndex]) || isPossible(nums, currentIndex + 1, sum);
um[sum] = result;
return result;
}
bool canPartition(vector<int>& nums) {
int l = nums.size();
if(l == 0){
return false;
}
int sum = 0;
unordered_map<int, bool> um;
for(int num: nums){
sum += num;
}
if(sum % 2 != 0){
return false;
}
int half = sum/2;
//cout<<"half "<<half<<endl;
return isPossible(nums, 0, half);
}
};

``````

Source: Windows Questions C++