3.Cheerleaders(SotongPractice) Môtả ChomộtxâugồmNkítự(N≤10),yêucầuinratấtcảcáchoánvịphânbiệtcủaxâuđótheothứtựtừđiển. Vídụ Vớixâu“aba”,sẽcótấtcả3hoánvịkhácnhautheothứtựtừđiểnlà“aab”,“aba”,“baa”. Phântích MộtxâucóđộdàiNsẽcótốiđaN!hoánvịphânbiệtkhitấtcảcáckítựcủaxâuđóđềukhácnhau. Hướnggiải Vétcạn Dựavàotầnsốcủacáckítựtrongxâu,dùngkĩthuậtđệquyđểsinhratấtcảhoánvịkhácnhautheothứtựtừđiển. ĐộphứctạptínhtoánO(N!). 24 2. Exhaustive Search -Problem voidper(inti){ //basic condition// if(i == N){ cout << S << endl; return; } //Recursion// for (intj = 0; j < 26; j++){ if(cnt[j]){ S[i] = 'a'+j; cnt[j]--; per(i+1);//đệ quy cnt[j]++; } } }
I would like to say that the word
blog
is not personal blog but it will be publicly published unless you draft those blogs.Also, you should write in English as an international language for better understanding for readers