Skip to main content

Posts

TCS Digital 2021 Day 1 Slot 1 : Question 1

  // TCS Digital 2021 Day 1 Slot 1 : Question 1   import java.util.*; class Solution {     public static boolean isPalindrome (String s)     {                 if (s.length () == 1)             return true;         StringBuilder sb = new StringBuilder (s);         sb = sb.reverse ();         String rev = new String (sb);         return s.equals (rev);     }       public static void main (String[]args)     {         Scanner sc = new Scanner (System.in);         String str = sc.next ();          ...
Recent posts

TCS Java Coding Question Day 2 Slot 1 : Property Painting

  // TCS Java Coding Question Day 2 Slot 1 : Property Painting   import java.util.Scanner; class Prop_paint {     public static void main(String[] args) {        int ni, ne, i = 0;        float intP = 18, extP = 12, cost = 0, temp;        Scanner sc = new Scanner(System.in);        System.out.printf("Number of Interior Walls : ");        ni = sc.nextInt();        System.out.printf("\nNumber of Exterior Walls : ");        ne = sc.nextInt();        if(ni < 0 || ne < 0) {            System.out.print("INVALID INPUT");        } else if(ni == 0 && ne == 0) {         ...

TCS Java Coding Question - Jar of Candies

  // TCS Java Coding Question - Jar of Candies   import java.util.Scanner; class Main{     public static void main(String[] args) {               int n = 10, k = 5;               int num;               Scanner sc = new Scanner(System.in);               num = sc.nextInt();               if(num >= 1 && num <= 5) {                           System.out.println("NUMBER OF CANDIES SOLD : " + num);                           System.out.pri...

WeCP Python Coding Question 8 : Lazy String

  WeCP   Python Coding Question 8 : Lazy String Problem Statement-:   Anish is the laziest person you can ever see. He is tasked to write the name of the winner in a game where two people take part. And he just writes the longest common subsequence over there, so that with minimum chane or no backspace he can edit the name to the winner’s name. For two given names, you have to predict what Anish will write in his computer before the start of the name. If there are more than two longest subsequences possible,write the one with less lexicographic value.   Input Format: Two lines including two strings of name(All with capital letters)   Output Format: A single line with the lexicographically smallest possible longest common subsequence.   Sample Input: ABCD BACD Sample Output: ACD   Explanation: ACD and BCD these are the two possible biggest substring   Program :   # WeCP Python Coding Question 8 : Laz...

WeCP Python Coding Question 7 : Momentum LinkedList

  WeCP   Python Coding Question 7 : Momentum LinkedList Problem Statement -:   Ratul made a linked list, a list made of n nodes, where every node has two variables, the velocity and the mass of a particle. Since all the particles have the velocity in the same direction, find the total momentum of the entity made by the particles from the linked list. Constraints : 1<=n<=10000 1<=m,v<=100   Input format: First line containing n, number of nodes Then n lines containing the mass and the velocity space separated.   Output Format: Single integer denoting the momentum   Sample Input: 4 1 3 2 4 2 3 4 5   Sample Output: 37   Program :   # WeCP Python Coding Question 7 : Momentum LinkedList   n=int(input()) s=0 for i in range(n):     m,v=map(int,input().split())     s+=(m*v) print(s)   For Output Check the Video :

WeCP Python Coding Question 6 : Help of Prepsters

  WeCP   Python Coding Question 6 : Help of Prepsters Problem Statement-: Arnab has given me a challenge. I have to calculate the number of numbers which are less than a certain value n, and have exactly k set bits in its binary form. As you are a Prepster like me, help me write a code that will take input for n and k and give the expected output.   Constraints : 1<=n<=10000 1<=k<=10   Input Format : First line containing n and k space separated Output Format : Number of numbers present in a single line   Sample Input: 7 2   Sample Output: 3   Explanation: 011,110,101 -> These three numbers.   Program : # WeCP Python Coding Question 6 :    Help of Prepsters   ans=0 n,k=map(int,input().split()) l=len(bin(n)[2:]) def func(i,s,L):     global l     global ans     if(L>l):       ...

WeCP Python Coding Question 5 : Corona for Computer

  WeCP   Python Coding Question 5 : Corona for Computer Problem Statement-: Every decimal number can be changed into its binary form. Suppose your computer has it’s own CoronaVirus, that eats binary digits from the right side of a number. Suppose a virus has 6 spikes, it will eat up 6 LSB binary digits in your numbers. You will have a bunch of numbers, and your machine will have a virus with n spikes, you have to calculate what will be the final situation of the final numbers.   Input Format: First line, a single Integer N Second line N space separated integers of the bunch of values as array V Third line a single integer n, the number of spikes in Corona for Computer   Output Format: Single N space separated integers denoting the final situation with the array v.   Sample Input: 5 1 2 3 4 5 2   Sample Output: 0 0 0 1 1   Explanation: 5 is 101 in binary, when you cut the last two binary digits, its 1. ...