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
Explanation
- Use a
HashSet<char>
to store unique characters. - Loop through each character in the string.
- Skip spaces (
c != ' '
) and only add characters if they haven’t been seen before (!seen.Contains(c)
). - 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.
Feature | git fetch | git pull |
---|---|---|
Operation | Downloads changes from the remote repository but does not merge them | Downloads changes and automatically merges them into the current branch |
Merging | No merging; updates only the remote-tracking branches | Merges remote changes into the current branch |
Use Case | When you want to check for updates before merging | When you want to update your local branch immediately |
Risk | No risk; does not change the working directory | Potential conflicts if changes clash with local work |
Command Example | git fetch origin | git pull origin main |
No comments:
Post a Comment