# Help me in solving LPC problem

### My issue

I need hint for solving

### My code

``````#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,b,a) for(ll i=b;i>=a;i--)
#define ppi pair<ll,ll>
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll
#define sz(x) (ll) x.size()
#define fast1 ios_base::sync_with_stdio(false)
#define fast2 cin.tie(0)
const ll mod = 1e9+7;

void solve(){

int n,m;
cin>>n>>m;
string s;
string k;
cin>>s;
cin>>k;

int i=0;
int j=0;
int res=INT_MAX;
int cnt=0;
while(j<n){
if(j-i+1>m){
i++;
}
if(j-i+1==m){
res=min(res,cnt);
}

j++;
}

}

int main()
{
fast1;
fast2;
ll t;
cin>>t;
while(t--){
solve();
}
}

``````

Problem Link: LPC Problem - CodeChef

@mahesh_024
U can apply brute force in this problem.
Plzz refer the following solution for better understanding of logic.

``````#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
// constant
const int mod = 1e9+7;
using namespace std;

int main(){
int t;  cin>>t;
while(t--){
int n,m;
cin>>n>>m;
string s,k;
cin>>s>>k;
int cnt = 0;
int ans = INT_MAX;
int j = 0;
for(int i = 0; i<n-m+1; i++){
for(int j = 0; j<m; j++){
int x= abs(s[i+j]-k[j]);
if(x>5){
x = 10 - x;
}
cnt += x;
}
ans = min(ans,cnt);
cnt = 0;
}
cout<<ans<<endl;
}
return 0;
}
``````