CODING SOLUTION - Placement Jobs & Materials
170K subscribers
908 photos
20 files
570 links
πŸŒ€ ” Our Only Aim Is To Let Get Placed To You In A Reputed Company. β€œ

Contact Admin:
instagram.com/offcampusjobsindia_it
Download Telegram
public class CarDistanceCalculator {

public static int totalDistance(int N, int[] A, int X, double S) {
// Minutes ko seconds me convert karo
int T = (int)(S * 60);

// X-th car ki acceleration le lo (0-based index)
int a = A[X];

// Distance = a Γ— T Γ— (T + 1) / 2
int distance = a * T * (T + 1) / 2;

return distance;
}

public static void main(String[] args) {
// Example inputs
int N = 3;
int[] A = {2, 4, 3};
int X = 1;
double S = 0.5;

int result = totalDistance(N, A, X, S);
System.out.println("Distance covered: " + result);
}
}

Input Explanation:
N = 3 cars
Accelerations: [2, 4, 3]
X = 1 means 2nd car (0-based indexing)
S = 0.5 minutes = 30 seconds
// Function to check if the array can be built using subarrays of prefix
public static boolean canBuild(int[] prefix, int[] arr) {
List<Integer> list = new ArrayList<>();
for (int num : prefix) list.add(num);

int i = prefix.length;
while (i < arr.length) {
boolean matched = false;
// Try all subarrays of prefix
for (int start = 0; start < prefix.length; start++) {
for (int end = start + 1; end <= prefix.length; end++) {
List<Integer> sub = list.subList(start, end);
if (i + sub.size() <= arr.length) {
boolean same = true;
for (int j = 0; j < sub.size(); j++) {
if (arr[i + j] != sub.get(j)) {
same = false;
break;
}
}
if (same) {
i += sub.size();
matched = true;
break;
}
}
}
if (matched) break;
}
if (!matched) return false;
}
return true;
}

public static int findMinOriginalLength(int[] arr) {
for (int len = 1; len <= arr.length; len++) {
int[] prefix = Arrays.copyOfRange(arr, 0, len);
if (canBuild(prefix, arr)) {
return len;
}
}
return arr.length;
}

public static void main(String[] args) {
int[] arr = {5, 4, 7, 2, 7, 4, 4, 7, 7, 2};
int result = findMinOriginalLength(arr);
System.out.println(result);
}
}

4
CODING SOLUTION - Placement Jobs & Materials pinned Β«// Function to check if the array can be built using subarrays of prefix public static boolean canBuild(int[] prefix, int[] arr) { List<Integer> list = new ArrayList<>(); for (int num : prefix) list.add(num); int i = prefix.length;…»
πŸ“Œ Here is a Previous Year Coding Question asked in Wipro / Cognizant placement test:




### Question 1: Count Frequency of Words in a Sentence

Problem: 
Write a program that takes a sentence and prints the frequency of each word, sorted alphabetically.

Input: 
"the quick brown fox jumps over the lazy dog"

Expected Output:
brown: 1
dog: 1
fox: 1
jumps: 1
lazy: 1
over: 1
quick: 1
the: 2

Python Code:
def count_word_frequency(sentence):
    # Remove punctuation and convert to lowercase
    sentence = sentence.lower()
   
    # Split the sentence into words
    words = sentence.split()
   
    # Create a dictionary to store frequency
    frequency = {}
   
    for word in words:
        if word in frequency:
            frequency[word] += 1
        else:
            frequency[word] = 1
   
    # Sort dictionary by key (alphabetically)
    for word in sorted(frequency):
        print(f"{word}: {frequency[word]}")

# Example
input_sentence = "the quick brown fox jumps over the lazy dog the"
count_word_frequency(input_sentence)

---

### Question 2: Check if a Matrix is Symmetric

Problem: 
Write a program to check if a square matrix is symmetric (i.e., matrix[i][j] == matrix[j][i]).

Input:
[
[1, 2, 3],
[2, 4, 5],
[3, 5, 6]
]

Output:
The matrix is symmetric.
Python Code:
def is_symmetric(matrix):
    n = len(matrix)
    for i in range(n):
        for j in range(n):
            if matrix[i][j] != matrix[j][i]:
                return False
    return True

# Example matrix
matrix = [
    [1, 2, 3],
    [2, 4, 5],
    [3, 5, 6]
]

if is_symmetric(matrix):
    print("The matrix is symmetric.")
else:
    print("The matrix is not symmetric.")
CODING SOLUTION - Placement Jobs & Materials pinned Β«πŸ“Œ Here is a Previous Year Coding Question asked in Wipro / Cognizant placement test: ### Question 1: Count Frequency of Words in a Sentence Problem:  Write a program that takes a sentence and prints the frequency of each word, sorted alphabetically.…»
from collections import deque

def heat_spread(grid):
    n = len(grid)
    m = len(grid[0])
    new_grid = [row[:] for row in grid]
    directions = [(-1,0), (1,0), (0,-1), (0,1)]

    for i in range(n):
        for j in range(m):
            if grid[i][j] == 'H':
                for dx, dy in directions:
                    ni, nj = i + dx, j + dy
                    if 0 <= ni < n and 0 <= nj < m and grid[ni][nj] == '.':
                        new_grid[ni][nj] = 'H'
    return new_grid

def simulate_heat(grid, start_x, start_y, end_x, end_y):
    n = len(grid)
    m = len(grid[0])
    queue = deque()
    visited = set()
    queue.append((start_x, start_y, 0, grid))
    visited.add((start_x, start_y))

    while queue:
        x, y, days, curr_grid = queue.popleft()
        if (x, y) == (end_x, end_y):
            return days

        next_grid = heat_spread(curr_grid)
        directions = [(-1,0), (1,0), (0,-1), (0,1)]

        for dx, dy in directions:
            nx, ny = x + dx, y + dy
            if 0 <= nx < n and 0 <= ny < m and next_grid[nx][ny] == '.' and (nx, ny) not in visited:
                visited.add((nx, ny))
                queue.append((nx, ny, days + 1, next_grid))
    return -1

# Input Format
n = int(input())
grid = []
for _ in range(n):
    grid.append(list(input().strip()))

start_x, start_y = map(int, input().split())
end_x, end_y = map(int, input().split())

print(simulate_heat(grid, start_x, start_y, end_x, end_y))




City Heatwave – Codevita
PYTHON
CODING SOLUTION - Placement Jobs & Materials pinned Β«from collections import deque def heat_spread(grid):     n = len(grid)     m = len(grid[0])     new_grid = [row[:] for row in grid]     directions = [(-1,0), (1,0), (0,-1), (0,1)]     for i in range(n):         for j in range(m):             if grid[i][j]…»
CGI_Coding_Questions_with_Answers (1).pdf
4.2 KB
β­• CGI Interview Experience β­•
Technical Round:

1. Write a program to check palindrome string.

2. Implement a binary search algorithm.

3. Write a code to find the factorial of a number.

4. Find the duplicate elements in an array.

5. Basic SQL queries like:

β€’Find second highest salary

β€’Count number of employees in each department
β­• HCL C++ Interview Experience β­•

1) Introduce Yourself
Brief intro with focus on your technical background, academic projects, and interest in C++.

2) What is the difference between C and C++?
C is procedural, C++ supports both procedural and object-oriented paradigms.

3) What are Classes and Objects in C++?
Class is a user-defined blueprint; Object is an instance of that class.

4) Explain OOPS Concepts with Real-life Examples
Encapsulation, Inheritance, Polymorphism, Abstraction explained with relatable examples like a car, employee hierarchy, etc.

5) What is Function Overloading and Operator Overloading?
Same function/operator behaves differently based on parameters.

6) What is the use of Pointers in C++?
Used for dynamic memory, arrays, and accessing objects directly.

7) Difference between Compile-time and Run-time Polymorphism?
Compile-time: Function Overloading; Run-time: Virtual Functions.

8) Code a Program for Palindrome Number in C++
Simple C++ code using loops and conditions.

9) Basic DSA Questions (Array, String, Sorting)
Reverse an array, Find missing number, Bubble Sort, etc.

10) HR Round: Strengths, Weaknesses, Why HCL, etc.
Prepare personal answers with examples; show enthusiasm for tech & learning.
WhatsApp: https://bit.ly/3tcjxV3
CODING SOLUTION - Placement Jobs & Materials pinned Β«β­• HCL C++ Interview Experience β­• 1) Introduce Yourself Brief intro with focus on your technical background, academic projects, and interest in C++. 2) What is the difference between C and C++? C is procedural, C++ supports both procedural and object-oriented…»
β­• COGNIZANT React JS Interview Experience β­•
1. Introduce Yourself**

2. What is React JS? Explain its core features.

3. What are Functional Components and Class Components in React? Difference?

4. Explain React JS Lifecycle Methods.

5. What is JSX in React?

6. What are Props and State in React? Differences?

7. Explain useState and useEffect hooks with examples.

8. What is Redux? Why do we use it in React?

9. Explain REST API and how to consume it in React.

10. Code a program to reverse a string in JavaScript.

11. Code: Find the largest number in an array using JavaScript.

12. Explain any UI/UX improvement you made in a past project.

13. Explain Git – basic commands like clone, commit, push.

14. What is the difference between SQL and NoSQL databases?

15. How do you optimize performance in React apps?

16. What is TypeScript? Advantages over JavaScript?

17. Basic DSA Questions: Stack operations, Queue implementation.

18. Debugging: How do you handle errors in a React application?

19. How do you manage code versioning in a team?

20. HR Round: Strengths, Weaknesses, Why Cognizant, Future Goals?


WhatsApp - https://whatsapp.com/channel/0029Va9upVdL2AU4AJeTCY3B
CODING SOLUTION - Placement Jobs & Materials pinned Β«β­• COGNIZANT React JS Interview Experience β­• 1. Introduce Yourself** 2. What is React JS? Explain its core features. 3. What are Functional Components and Class Components in React? Difference? 4. Explain React JS Lifecycle Methods. 5. What is JSX in React?…»
Forwarded from OFF CAMPUS JOBS INDIA
TCS off Campus Drive


Job Profile: Back office Operations


πŸŽ– Eligibility : BCom/BAF/BBI/BCA/BBM/BMS/BA/B.SC


πŸŽ–Batch- 2023, 2024 & 2025

  

Youtube - https://youtube.com/@offcampusjobsindia?si=i0EsNHXL-OlG3GuL


WhatsApp -  https://whatsapp.com/channel/0029Va9upVdL2AU4AJeTCY3B


Instagram   - https://www.instagram.com/offcampusjobsindia_it


πŸ”—Apply Link
       https://www.linkedin.com/posts/satish-shukla-a88203135_dear-associates-greetings-from-the-tcs-talent-activity-7340676759836680192-875R
Forwarded from OFF CAMPUS JOBS INDIA
MountBlue off Campus Drive


Job Profile: Software Development Engineer


πŸŽ– Eligibility : Any Graduate


πŸŽ–Batch- 2023, 2024 & 2025

  

Youtube - https://youtube.com/@offcampusjobsindia?si=i0EsNHXL-OlG3GuL


WhatsApp -  https://whatsapp.com/channel/0029Va9upVdL2AU4AJeTCY3B


Instagram   - https://www.instagram.com/offcampusjobsindia_it


πŸ”—Apply Link
       https://careers.mountblue.io/trainee/