First and Last X Digits Equal

 

Java Code:

import java.util.*;
public class Hello {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        String str=s.next();
        int  n=s.nextInt();
        char ch[]=str.toCharArray();
        int l=str.length();
       int i,j,k=l-n-1;
        String s1="",s2="";
        for(i=0;i<n;i++)
            s1+=ch[i];
        for(j=k+1;j<l;j++)
            s2+=ch[j];
        if(s1.equals(s2))
        System.out.print("Yes");
        else
        System.out.print("No");
    }
}

Comments

  1. Sands Casino | Entertainment, Gaming, Slots, Games, Poker
    Play your favourite 샌즈카지노 online slots, poker, blackjack, roulette, and more at Sands 메리트카지노 Casino. Sign 바카라 사이트 up and claim your welcome bonus and play for real.

    ReplyDelete

Post a Comment

Popular posts from this blog

Fisherman's Mantra

First & Last X Digits

N Integers – Sum S – All Combinations(Weekly Test)