Interview KOCH - suniladhya/Advantage GitHub Wiki
- GitLab pipeline
- App settings
- Asyn Await when there is blocking sequence of tasks
- Authorization authentication in Web API
- Fetch pull difference
- Merge Rebase differenc
- Generic & collection
- repository pattern
- Solid Principle
- Docker command
- Docker image vs container
- Docker vm vs normal vm
- Can Net4.5 be hosted in the docker
- Problem statement
Given an array of integers (unorder array) find the length of the longest subsequence such that elements in the subsequence are consecutive integers. The consecutive numbers can be in any order.
Input: arr[] = {12, 121, 30, 36, 41, 56, 13, 55, 35, 44, 33, 34, 92, 43, 32, 42}
Output: 5
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6
Output: [0,1]
Write a generic function where
return type : generic list
parameter : generic type
and the genric type must be a class with a parameterless constructor
Problem statement
using System;
public class MergeNames
{
public static string[] UniqueNames(string[] names1, string[] names2)
{
throw new NotImplementedException();
}
public static void Main(string[] args)
{
string[] names1 = new string[] {"Ava", "Emma", "Olivia"};
string[] names2 = new string[] {"Olivia", "Sophia", "Emma"};
Console.WriteLine(string.Join(", ", MergeNames.UniqueNames(names1, names2))); // should print Ava, Emma, Olivia, Sophia
}
}
Problem statement
/*The following program maps PersonDTO to Person class.
As you could see, the IsMinor property of Person is not set.
Please add configuration to Automapper to set IsMinor to true if age <= 18 and set false otherwise.*/
using AutoMapper;
using System;
class Program
{
static void Main()
{
// Setup AutoMapper configuration
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<PersonDto, Person>().ForMember(dest => dest.IsMinor,
opt => opt.MapFrom
(src => src.Age >= 18? false: true));
});
// Create mapper instance
var mapper = new Mapper(config);
// Create a person DTO
var personDto = new PersonDto { Name = "John Doe", Age = 20 };
// Map the person DTO to a person object
var person = mapper.Map<PersonDto, Person>(personDto);
// Print the mapped person details
Console.WriteLine("Name: {0}", person.Name);
Console.WriteLine("Age: {0}", person.Age);
Console.WriteLine("Is Minor: {0}", person.IsMinor);
}
}
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public bool IsMinor { get; set; }
}
class PersonDto
{
public string Name { get; set; }
public int Age { get; set; }
}
-
Angular - subject behaviour
-
Angular - Parent child communication
-
Angular - component to component communication
-
Angular - Promises and observables
-
inheritance - parent reference child object -> inherited method invoked
-
network layer authentication -> How the credentials are protected
-
JWT authentication works - (How, )
-
Open API
// https://dotnetfiddle.net/8F5ioR
/*The following program prints Odd Numbers followed by Even numbers.
Modify the program to make them run in parellel so that output has odd and even numbers interleaved(mixed). */
using System;
using System.Threading.Tasks;
public class Program
{
public static void Main()
{
//await
//.Wait();
//await PrintEvenNumbers().Wait();
// The below code is added to
Task.Run(async () =>
{
PrintOddNumbers();
PrintEvenNumbers();
// Do any async anything you need here without worry
}).GetAwaiter().GetResult();
}
public static async Task PrintEvenNumbers()
{
for(int i=0;i<10;i+=2)
{
Console.WriteLine(i);
await Task.Delay(0);
}
}
public static async Task PrintOddNumbers()
{
for(int i=1;i<10;i+=2)
{
Console.WriteLine(i);
await Task.Delay(0);
}
}
}
Q2.
/*The following program maps PersonDTO to Person class.
As you could see, the IsMinor property of Person is not set.
Please add configuration to Automapper to set IsMinor to true if age <= 18 and set false otherwise.*/
using AutoMapper;
using System;
class Program
{
static void Main()
{
// Setup AutoMapper configuration
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<PersonDto, Person>().ForMember(dest => dest.IsMinor,
opt => opt.MapFrom
(src => src.Age >= 18? false: true));
});
// Create mapper instance
var mapper = new Mapper(config);
// Create a person DTO
var personDto = new PersonDto { Name = "John Doe", Age = 20 };
// Map the person DTO to a person object
var person = mapper.Map<PersonDto, Person>(personDto);
// Print the mapped person details
Console.WriteLine("Name: {0}", person.Name);
Console.WriteLine("Age: {0}", person.Age);
Console.WriteLine("Is Minor: {0}", person.IsMinor);
}
}
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public bool IsMinor { get; set; }
}
class PersonDto
{
public string Name { get; set; }
public int Age { get; set; }
}