Codechef Starters 155 | Video Solutions - A to F | by Harsh Gupta | TLE Eliminators

preview_player
Показать описание
Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D, E, F of Codechef Starters 155 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest.

Solution Codes:

Be sure to check out TLE Eliminators.

Timestamps:-
0:00 Problem A & B
12:11 Problem C
30:13 Problem F
50:00 Problem D
1:02:55 Problem E
Рекомендации по теме
Комментарии
Автор

I have solved the Replace with first character question with out using dp in simple O(N) time complexity import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int ti=sc.nextInt();
while(ti-- >0){
int n=sc.nextInt();
int m=sc.nextInt();
String s=sc.next();
String t=sc.next();
if(s.charAt(0)!=t.charAt(0)){
System.out.println("-1");
}
else{
if(n==m ){
int i=0;
for( i=0;i<m;i++){
if(s.charAt(i)!=t.charAt(i)){
break;
}
}
if(i==m){
System.out.println("0");
}
else{
System.out.println("2");
}
}
else{

if(m<n){
int temp=n;
n=m;
m=temp;
String test=s;
s=t;
t=test;
}
int i=0;
for( i=0;i<n;i++){
if(s.charAt(i)!=t.charAt(i)){
break;
}
}
int j=n-1, k=m-1;
while(j>=i && s.charAt(j)==t.charAt(k)){
j--;
k--;
}
if(j<i){
System.out.println("1");
}
else{
System.out.println("2");
}


}
}
}

}
}

VarunReddy-rliz
Автор

today's codechef was easy but couldn't figured it out

aritradhabal
Автор

GCD hard version fill-3 if(i%min(n, m)==j%min(n, m))
else fill-2

piashbiswas
Автор

void func(){
ll count = 2;
ll n, m; cin>>n>>m;
vector<vector<ll>>mat(n, vector<ll>(m, 2));
int i=0, j=0;
int maxi = max(n, m);
while(maxi--){
mat[j%n][i%m] = 3;
i++;
j++;
}
for(auto it:mat){
for(auto itt:it){
cout<<itt<<" ";
}
nl;
}
}
This one too much more clean

vaibhavyadav
Автор

I don't how but it show the constraints 1e5 in my codechef page 😢for 3rd one

gauravpunia
Автор

Hi TLE can you provide your discord server link. Thanks

aryansudan