CodeChef Online Judge Solution Subsequence Equality Problem Code: LIKECS01 – Solution

CodeChef Online Judge Solution CodeChef-Beginner Solution

CodeChef Online Judge Solution Subsequence Equality Problem Code: LIKECS01 – Solution

CodeChef Online Judge Solution Subsequence Equality | Beginner
CodeChef Problem Link – https://www.codechef.com/problems/LIKECS01

Problem Name: Subsequence Equality solution Codechef
Problem Number : CodeChef- Subsequence Equality LIKECS01
Online Judge : CodeChef Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

CodeChef Online Judge Solution Subsequence Equality Problem Code: LIKECS01 - Solution

CodeChef Solution Subsequence Equality Code in C:

#include <stdio.h>

int main(void) {

char s[101];

int hash[30];
int t,i;
int j;
int tog1=0;
scanf("%d",&t);
for(i=0;i<t;i++)
{
tog1=0;
scanf("%s",s);
for(j=0;j<26;j++)
hash[j]=0;
j=0;
while(s[j]!='')
{
hash[(int)s[j]-'a']++;
if(hash[(int)s[j]-'a']>1&&tog1==0)
tog1=1;

j++;
}
if(tog1==1)
printf("yesn");
else
printf("non");
}

return 0;
}

CodeChef Solution Subsequence Equality Code / CodeChef LIKECS01 solution in CPP:

#include <bits/stdc++.h>
using namespace std;

int main(){

int tt;
scanf("%d", &tt);
while(tt--){
char c[250];
set s;
scanf("%s", c);
int x = 0;
for(int i=0; c[i]; ++i){
s.insert(c[i]);
++x;
}

puts(s.size()==x ? "no" : "yes");
}
return 0;
}

CodeChef Solution Subsequence Equality Code / CodeChef LIKECS01 solution in Java:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
class LIKECS01 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

int t = Integer.parseInt(br.readLine().trim());
while (t-- > 0) {
String str = br.readLine().trim();
int chars[]=new int[27];
for(char ch:str.toCharArray()) {
chars[ch-'a']++;
}
boolean flag=false;
for(int i=0;i1)
flag=true;
if(!flag)
pw.println("no");
else
pw.println("yes");
}
pw.flush();
pw.close();
}
}

CodeChef Solution Subsequence Equality Code / CodeChef LIKECS01 solution in  Python:

n=input()
for _ in range(n):
x=raw_input()
f=0
for i in x:
if x.count(i) > 1:
print "yes"
f=1
break
if f==0:
print "no"

CodeChef Solution Subsequence Equality Problem Code: LIKECS01 Code / CodeChef LIKECS01 solution in  C# (C Sharp):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int cases;
Int32.TryParse(Console.ReadLine().ToString(),out cases);
string [] arrString=new string[cases];
for (int i = 0; i < cases; i++)
{
arrString[i] = Console.ReadLine();
}

for (int k = 0; k < arrString.Length; k++)
{
int[] arr = new int[26];
bool hasSubseq = false;
for (int j = 0; j < arrString[k].Length; j++)
{
int pos = arrString[k][j] - 'a';
if(pos>=0&&pos 1)
{
hasSubseq = true;
}
}

if (hasSubseq)
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
}
Console.ReadKey();
}
}
}

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: CodeChef Online Judge Solution, CodeChef OJ Solution list, CodeChef Problems Solution, CodeChef solver, URI all problem solution list, URI Subsequence Equality  code in C, CodeChef LIKECS01 code in C++, CodeChef Subsequence Equality  solution in C, URI solution, CodeChef LIKECS01 solution in C,CodeChef LIKECS01 solution in C++-CPP,CodeChef LIKECS01 solution in C# (C sharp),CodeChef LIKECS01solution in Java,CodeChef LIKECS01 solution in Python,

Leave a Reply

Your email address will not be published.