摘要:
题面: 题解: 双指针找区间即可。 代码: class Solution { public: int numberOfSubstrings(string s) { int numa = 0,numb = 0,numc = 0,l = 0,r = 0; int n = s.size(); int an 阅读全文
摘要:
题面: 题解:维护长度为p的长度的滑动窗口,cnts维护当前窗口内个字母s与p的差,用一个变量res维护不同的数量,当res=0时是异位词。 class Solution { public: int cnts[26]; int cntp[26]; vector<int> findAnagrams(s 阅读全文
摘要:
题面: 样例: 题解:暴力搜索,加上相等剪枝。 代码: class Solution { public: int n,m; int k; int dx[4]={-1,1,0,0}; int dy[4]={0,0,-1,1}; int vis[205][205]; vector<vector<char 阅读全文
摘要:
题面: 题解:从小到大排序,取相邻的最小差即可。 代码: class Solution { public: int findMinDifference(vector<string>& t) { vector<int>res; int n=t.size(); if(n>1440)return 0; f 阅读全文