TCS March 19th March Digital Capability Assessment (DCA) All 3 Shifts Asked Coding Question with Solution

TCS March 19th March Digital Capability Assessment (DCA) All 3 Shifts Asked Coding Question with Solution

TCS March 19th March Digital Capability Assessment (DCA) All 3 Shifts Asked Coding Question with Solution

  1. Today Morning, Afternoon, and Evening All Shifts Asked Coding Questions
  2. Coding Solution in JAVA, PYTHON, C++
  3. Today 19th DCA Exam Analysis


tcs dca,
tcs,
tcs dca march exam,tcs online proctored exam,
tcs opa,
tcs cpa exam,
tcs dca exam syllabus,
tcs dca march 2021,
tcs xplore 2021,
tcs xplore,
tcs nqt 2021,
tcs exam,
tcs dca exam pattern,
tcs dca test,march dca exam mail not received,
tcs dca xplore drc on 16th march,
tcs cpa exam questions,
16th march drc coding question,
tcs dca previous year coding question,
tcs dca march,
tcs 12 march camera proctored assessment,
tcs nqt,
tcs xplore program,
tcs dca sample coding question
tcs nqt questions,
tcs,
tcs nqt coding questions,
tcs nqt interview questions,
tcs nqt 2020,
tcs nqt,
tcs nqt drc test,
tcs dca,
tcs nqt mock test,
tcs dca coding question,
drc test,
dca drc coding question,
tcs dca java coding question,
tcs ninja questions,tcs nqt 2021,
tcs dca sample coding question,
tcs coding questions,
tcs dca previous year coding question,
16th march drc coding question,
tcs interview questions,
tcs nqt preparation,
tcs irc test,tcs nqt aptitude questions,
tcs nqt last year questions
tcs nqt questions,
tcs,
tcs nqt coding questions,
tcs nqt interview questions,
tcs nqt 2020,
tcs nqt,tcs nqt drc test,
tcs dca,
tcs nqt mock test,
tcs dca coding question,
drc test,
dca drc coding question,
tcs dca java coding question,
tcs ninja questions,
tcs nqt 2021,
tcs dca sample coding question,tcs coding questions,
tcs dca previous year coding question,
16th march drc coding question,
tcs interview questions,
tcs nqt preparation,
tcs irc test,tcs nqt aptitude questions,
tcs nqt last year questions

1. Coding Question - Backward and Forward:

Consider one string as input. You have to check whether the strings obtained from the input string with single backward and single forward shifts are the same or not. If they are the same, then print 1, otherwise, print 0.

Hint:
Backward shift: A single circular rotation of the string in which the first character becomes the last character and all the other characters are shifted one index to the left. For example, “abcde” becomes “bcdea” after one backward shift.
Forward shift: A single circular rotation of the string in which the last character becomes the first character and all the other characters are shifted to the right. For example, “abcde” becomes “eabcd” after one forward shift.

Instructions:
* The system does not allow any kind of hard-coded input values.
* The written program code by the candidate will be verified against the inputs that are supplied from the system.
* For more clarification, please read the following points carefully till the end.

Constraints:
String str should not allow space, special characters, and numbers.
String str should only be in the English language.

Input / Output:

Input:
sfdlmnop
Output:
0

Explanation:
In the first example, the string is "sfdlmnop" Forward shift: fdlmnops Backward shift: psfdlmno Both the strings above are not equal so the output is 0.

Source code for Backward and Forward Shifts Question

1. Java Solution for Backward and Forward

import java.util.*;
public class MyClass{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String str = s.nextLine();
        String s1 = leftRotate(str,1);
        String s2 = rightRotate(str,1);
        if(s1.equalsIgnoreCase(s2))
            System.out.println("1");
        else
            System.out.println("0");
    }
    public static String leftRotate(String str, int div){
        String result = str.substring(div) + str.substring(0, div);
        return result;
    }
    public static String rightRotate(String str, int div){
        return leftRotate(str, str.length()-div);
    }
}

2. Python Solution for Backward and Forward

if __name__ == "__main__":
    str = input().strip()
    s1 = str[1:] + str[:1]
    s2 = str[-1:] + str[:-1]
    if s1 == s2:
        print(1)
    else:
        print(0)

3. C++ Solution for Backward and Forward

#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;
    string s1 = str.substr(1) + str.substr(0,1);
    string str2 = str[str.size() - 1] + str.substr(0, str.size() - 1);
    cout<<(str == str2);
    return 0;
}

2. Coding Question - transform a wrong word:

Write a program to find the number of ways in which we can transform a wrong word to a correct word by removing zero or more characters from the wrong word. Given: Strings, i.e. S1(for wrong word) and S2(for correct word).

Input / Output:

Input:
ggoog - String S1, i.e. wrong word
go - String S2, i.e. correct word

Output:
4

Explanation:

Explanation: The four ways will be "g.o..", "g..o.", ".go..", and ".g.o." "." is where characters are removed.

Input:
Indiiian - String S1, i.e. wrong word
Indian - String S2, i.e. correct word

Output:
3

Explanation:
Explanation: The three ways will be "ind..ian", "indi..an", and "ind.i.an" where "." is character to be removed.

Source code for transform a wrong word Question

1. Java Solution for transform a wrong word

import java.io.*;

public class Shift {
 public static void main(String[] args) throws Exception {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
  String s = br.readLine();
  int L = s.length();
  String b = s.substring(1) + String.valueOf(s.charAt(0));
  String f = String.valueOf(s.charAt(L - 1)) + s.substring(0, L - 1);
  if (b.equals(f))
   bw.write("1");
  else
   bw.write("0");
  
  bw.flush();
 }
}

2. Python Solution for transform a wrong word

def countTransformation(a, b):
    n = len(a)
    m = len(b)
    if n == m:
        return 0
    if m == 0:
        return 1
    dp = [[0] * (n) for _ in range(m)]
    for i in range(m):
        for j in range(i, n):
            if i == 0:
                if j == 0:
                    if a[j] == b[i]:
                         dp[i][j] = 1
                    else:
                        dp[i][j] = 0
                elif a[j] == b[i]:
                    dp[i][j] = dp[i][j-1]+1
                else:
                    dp[i][j] = dp[i][j-1]
            else:
                if a[j] == b[i]:
                     dp[i][j] = (dp[i][j-1] + dp[i-1][j-1])
                else:
                    dp[i][j] = dp[i][j-1]
    return dp[m-1][n-1]
if __name__ == "__main__":
    a = input()
    b = input()
    print(countTransformation(a,b))

3. C++ Solution for transform a wrong word

def countTransformation(a, b):
    n = len(a)
    m = len(b)
    if n == m:
        return 0
    if m == 0:
        return 1
    dp = [[0] * (n) for _ in range(m)]
    for i in range(m):
        for j in range(i, n):
            if i == 0:
                if j == 0:
                    if a[j] == b[i]:
                         dp[i][j] = 1
                    else:
                        dp[i][j] = 0
                elif a[j] == b[i]:
                    dp[i][j] = dp[i][j-1]+1
                else:
                    dp[i][j] = dp[i][j-1]
            else:
                if a[j] == b[i]:
                     dp[i][j] = (dp[i][j-1] + dp[i-1][j-1])
                else:
                    dp[i][j] = dp[i][j-1]
    return dp[m-1][n-1]
if __name__ == "__main__":
    a = input()
    b = input()
    print(countTransformation(a,b))

All 3 Shifts TCS DRC Exam All Coding Question Complete Solution

Print Roll and Score Coding Solution

awk 'BEGIN{FS="-";count=0}{
 if(($2==$3) && ($3==$4)){
  print $1"-"$2"-"$3"-"$4;
  count += 1;
 }
}
END{
 print "Total: "count;
}'

Program

s1 = input()
s2 = input()

def recursion(m, n):
    
    if m == 0:
        return n 
    
    if n == 0:
        return m 
        
    if s1[m - 1] == s2[ n - 1]:
        return recursion(m - 1, n - 1) 
    return max ( recursion(m - 1, n) , recursion(m, n - 1) ) 
    
x = recursion(len(s1), len(s2)) 
print(x)


PDF download link: Click here

Stay tuned with www.freshersocjob.com to receive more such updates on recruitment. Join our Telegram Channel and Join our WhatsApp Group To get Instant updates for All Recruitment Internships and Off-Campus of 2021 Pass-Out Batch and Other Batch.

Comments