Friday, 7 March 2025

L&T interview

1:Remove duplicates and spaces L&T 
2:fetch and pull
3:types of memories
4:try catch implimentations
5:var and nvarchar
6:entity ado major difference
7:localization in sql(for lanaguage specific  save)
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{

public static void Main()

{

var data = "Hello world";

Console.WriteLine(data.Replace(" ","").ToCharArray().Distinct().ToArray());

2.git fetch and pull difference


using System; using System.Collections.Generic; class Program { static void Main() { string data = "Hello world"; HashSet<char> seen = new HashSet<char>(); string result = ""; foreach (char c in data) { if (c != ' ' && !seen.Contains(c)) // Ignore spaces and duplicates { seen.Add(c); result += c; } } Console.WriteLine(result); // Output: Helowrd } }

Explanation

  1. Use a HashSet<char> to store unique characters.
  2. Loop through each character in the string.
  3. Skip spaces (c != ' ') and only add characters if they haven’t been seen before (!seen.Contains(c)).
  4. Build the result string without duplicates.

Why Use HashSet?

  • Faster lookup (O(1) time complexity for checking if a character is already seen).
  • Efficient way to remove duplicates compared to nested loops.


Difference Between git fetch and git pull

Both git fetch and git pull are used to get updates from a remote repository, but they work differently.

Featuregit fetchgit pull
OperationDownloads changes from the remote repository but does not merge themDownloads changes and automatically merges them into the current branch
MergingNo merging; updates only the remote-tracking branchesMerges remote changes into the current branch
Use CaseWhen you want to check for updates before mergingWhen you want to update your local branch immediately
RiskNo risk; does not change the working directoryPotential conflicts if changes clash with local work
Command Examplegit fetch origingit pull origin main

No comments:

Post a Comment

Car pooling app

 I'll create a car pooling app with real-time vehicle tracking, pickup/drop time estimates, and a list of onboard users. Since we don...