解题思路:
(1)贪心算法
class Solution {
public:
bool stoneGame(vector<int>& piles) {
int i=0,j=piles.size()-1;
int count1=0,count2=0;
while(i<j) {
if(piles[i]>piles[j]) {
count1+=piles[i];
count2+=piles[j];
} else {
count1+=piles[j];
count2+=piles[i];
}
i++;
j--;
}
if(count1>count2) return true;
else return false;
}
};