@braydenCN I'm sorry but the code can be shorter:

class Solution { public: bool validUtf8(vector<int>& data) { int win=0; for(int i=0;i<data.size();i++, win--) { if(data[i]>255) return false; int n1=0, mask=128; while(data[i]&mask) { mask>>=1; n1++; } if((n1>4)||(win>0&&n1!=1)||(win<=0&&n1==1)) return false; if(win<=0) win=n1; } return win<=0; } };UTF-8 Validation