Toggle Challenge Solution in Java Tcs Codevita Zone 2 Round 1 Coding Questions and Answers Tcs

preview_player
Показать описание
🚀 **Welcome to Technical Study Ajay!** 🚀

Toggle Challenge Solution in Java Tcs Codevita Zone 2 Round 1 Coding Questions and Answers Tcs

Embark on an exhilarating journey from "0 to Hero Software Engineer" with this transformative tutorial! Whether you're a programming novice or aspiring to enhance your skills, this video is designed to provide invaluable insights, guiding you towards becoming a proficient software engineer.

🔍 **Key Highlights:**
- **Foundations of Software Engineering:** Grasp essential concepts and principles laying the groundwork for a successful software engineering career.
- **Learning Paths and Resources:** Explore effective strategies and resources to expedite your learning and development.
- **Coding Tips and Best Practices:** Acquire practical tips and best practices for writing clean, efficient code.
- **Career Guidance:** Navigate the landscape of software engineering careers with advice on interviews, portfolio building, and continuous improvement.

🌐 **Connect with me:**

🔍" Some Other Topic "

📺 **Check out my other channel:**

📧 **For business inquiries and collaborations:**

👍 **Don't forget to like, share, and subscribe for more valuable insights on your journey to becoming a software engineer!**

🔔 **Turn on notifications to stay updated with the latest content and tutorials.**

Thank you for joining us on this exciting adventure towards software engineering mastery! 💻🌟
Рекомендации по теме
Комментарии
Автор

Block Extraction-2
Problem Description
Chintu is playing with Lego blocks arranged in a matrix. Each block is a different colour and can only be placed straight, either horizontally or vertically, in a matrix arrangement.

The given matrix contains integers, where each colour of the blocks is represented by a number which is called as colour code of that block. If two or more adjacent cells have the same number, it means one block is occupying all those cells. There will be only one block of each colour.

Given the front view of the matrix, Chintu can only remove blocks from the right side, taking out one whole block at a time. If there is a barrier in front of a block, he must remove the barrier first to access the block he wants.

A block will remain in place even if it has support from just one adjacent cell. Otherwise, it will fall due to gravity.

Can you help Chintu calculate the number of blocks he needs to remove to extract the desired block?

Constraints
1 <= N, M <= 50

1 <= colour code <= 100

Input
First line consists of two space separated integers N, M denoting the number of rows and columns in the matrix.

The next N lines contain M space-separated integers that represent the colour codes of the blocks and the cells each block occupies.

Last line consists of an integer denoting the colour code of the block which Chintu wanted to extract.

Output
Print a single number indicating how many blocks Chintu needs to remove to access the specified block.

Time Limit (secs)
1

Examples
Example 1

Input

5 5

15 12 23 13 13

15 12 14 8 10

5 11 11 8 9

5 6 6 7 7

1 1 2 3 4

1

Output

8

Explanation

The size of the matrix is 5 rows and 5 columns. It comprises of blocks numbered {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 and 23}. Chintu wishes to extract block 1.

To extract the blocks with colour code 1, Chintu can do the following.

First, he will remove the block with colour code 4, followed by the block with colour code 3 and 2 respectively. After that only blocks with colour code 1 can be removed. So, 3 blocks will need to be removed in row 5.
In the process, block with colour code 7 in row 4 will fall due to gravity, so those must be removed too. So, 1 block will be removed in row 4.
This chain reaction will cause blocks 8, 9, 10, and 13 to fall as well, requiring their removal too. So, 4 blocks will be removed in rows 1, 2 and 3.
Thus, in total, Chintu will have to remove 8 blocks (3 + 1 + 4) before he can extract the block with colour code 1.
Example 2

Input

6 4

1 2 3 4

5 5 6 6

7 8 8 9

10 12 13 15

10 12 13 15

11 12 14 15

12

Output

4

Explanation

The size of the matrix is 6 rows and 4 columns. It comprises of blocks numbered {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 and 15}. Chintu wishes to extract block 12.

To extract the blocks with colour code 12, Chintu can do the following.

First, he will remove the block with colour code 15 in rows 4, 5 and 6. So, this is 1 block.
The block with colour code 9 in row 3 will fall due to gravity, so he must also remove that block.
Next, he will remove the block with colour code 14 followed by 13 and 9 in rows 3, 4, 5 and 6. So, this is 3 blocks.
Thus, in total, Chintu will have to remove 4 blocks (1 + 3) before he can extract the block with colour code 12.

PriyanshuGohanYadav
Автор

passed public test cases but failed in private test cases,
import java.util.*;
public class SevenSegmentDisplay {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] digitSegments = new int[10][9];
for (int i = 0; i < 3; i++) {
String line = sc.nextLine();
for (int j = 0; j < 10; j++) {
for (int k = 0; k < 3; k++) {
digitSegments[j][i * 3 + k] = line.charAt(j * 3 + k) - '0';
}
}
}
String[] faultyLines = new String[3];
for (int i = 0; i < 3; i++) {
faultyLines[i] = sc.nextLine();
}
int n = faultyLines[0].length() / 3;
int[][] faultyDigits = new int[n][9];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
faultyDigits[i][j * 3 + k] = faultyLines[j].charAt(i * 3 + k) - '0';
}
}
}
List<List<Integer>> possibleDigits = new ArrayList<>();
for (int[] faultyDigit : faultyDigits) {
List<Integer> currentPossible = new ArrayList<>();
for (int digit = 0; digit < 10; digit++) {
int diffCount = 0;
for (int i = 0; i < 9; i++) {
if (faultyDigit[i] != digitSegments[digit][i]) {
diffCount++;
}
}
if (diffCount <= 1) {
currentPossible.add(digit);
}
}
if (currentPossible.isEmpty()) {
System.out.print("Invalid");
return;
}

}

long totalSum = calculateTotalSum(possibleDigits, 0, 0);
System.out.print(totalSum);
}

private static long possibleDigits, int index, long currentNumber) {
if (index == possibleDigits.size()) {
return currentNumber;
}

long sum = 0;
for (int digit : possibleDigits.get(index)) {
sum += calculateTotalSum(possibleDigits, index + 1, currentNumber * 10 + digit);
}
return sum;
}
}

helpingzone
Автор

bhai ye wala kar do jaldi
me khareed loongacode

PriyanshuGohanYadav
Автор

bhaiiii chahiye ho toh comment ka reply krna

sanatani
Автор

14 Segment
Folded Area
Gravity and Lifts

inme se dedo koi

nomorelivin
join shbcf.ru