First declare the main text text=”abcd” #this is main text Noe declare the pattern you want to search in the main text patt=”cd” #this is pattern to search for in the main text Now find the difference in length of main text and pattern #first calcualte the difference between main text and pattern diff=len(text)-len(patt) print(diff) […]
Understanding Azure function
azure function is a way to implement serverless computing in azure.This means that the developer is not concerned about things such as managing infrastrcuture,scalling and deployment.Instead developer can focus on business logic. Function is executed when an action occurs.Here action is the event which triggers the function.That is why you need to defined the trigger […]
Run ASP.NET Core application in a docker container
Containers are similar to virtual machines.But they have the following advantages when compared to virtual machines:- They are lightweight since all the containers share the same OS. They have faster start up time. Docker is one of the most popular containerization technologies.Docker can run on different OS such as Windows,Linux and Mac. We can run […]
Finding substring in a string
Following program finds a substring in a string. public static int Find(string text, string pattern) { // ASHI COMPARE A,S,H,I // SHI A==S,S==H for (int i = 0; i <=text.Length – pattern.Length; i++) { int temp = i; for (int j = 0; j < pattern.Length; j++) { temp++; if (text[temp] == pattern[j]) { j++; […]
Program to check valid parenthesis
Program to check valid parenthesis public class Solution { public bool IsValid(string s) { Stack stack=new Stack(); foreach(char ch in s) { if(ch=='(‘ || ch=='{‘ || ch=='[‘) stack.Push(ch); if(ch==’)’ || ch==’}’ || ch==’]’) stack.Pop(); } if(stack.Count==0) return true; else return false; } }