W

@Webdev

Save

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { //User input fileds for row and colums for row and column Console.WriteLine("Enter number of rows:"); int rows = int.Parse(Console.ReadLine()); Console.WriteLine("Enter number of columns:");

Print below pattern - Number of lines should be input from user.

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int rowNumber = 5; trianglePattern(rowNumber); } static void trianglePattern(int rowVal){

Reverse individual words Given a string and then sort the complete sentence in increasing order of l

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { string str = "This is dotnet interview"; string reverse = reverseStr(str); //Split words for string into array string[] words = SplitWords(reverse);

Random Questions

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { // printFibonacci(10); // Console.WriteLine(isPallendrome(111)); countMonthEvenOddDays(34); }

Pattern Questions Practice

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { // pattern1(4); // pattern2(5); // pattern3(5); // pattern4(5); // pattern5(5);

Find the Target Element In Rotated Sorted Array using BS

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { string myStr = "A man, a plan, a canal: Panama"; string str = myStr; string check = string.Empty; str = str.Replace(" ", string.Empty); str = str.Replace(",", string.Empty);

Find the target element in sorted infinite array.

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int[] myArr = {1,2,5,7,11,12,15,19,20,22,34,45,67,89,99,100,101}; int target = 89; Console.WriteLine("Index of target element is : "+answer(myArr,target)); }

Find the First and Last Position of element in sorted array

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int[] myArr = {5,7,7,8,8,10}; int target = 8; int[] ans = binarySearch(myArr,target); Console.WriteLine("Element found at index: ["+ ans[0] + "," + ans[1]+"]"); }

Ceiling & Floor Number For Target in Sorted Array

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { char[] arr = {'c','f','g','h'};//{1,2,4,5,7,11,14,16}; char target = 'd'; Console.WriteLine("Ceiling nearest to target at index : "+ceilingNumber(arr,target)); // Console.WriteLine("Floor nearest to target at index : "+floorNumber(arr,target)); }

Binary Search Example Algo

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int[] myArr = {1,2,3,4,5,6,7,8,9,11,13,14}; int[] newArr = {14,11,9,8,7,6,5,4,3,2,1}; int target = 12; Console.WriteLine("Normal Binary Search : Index Of Target Element => " +SearchNumber(myArr,target));

Even Number of Digits

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int[] number = {12, 1, 567, 3425, 10, 988}; Console.WriteLine("Number of Even Digits: "+findNumbers(number)); Console.WriteLine(digits2(19292)); } static int findNumbers(int[] num){

Linear Search Basic Questions

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { // Best Case Time Complexity : O(1) because element can find at first index. // worst case Time Complexity : O(N). int[] myArr = {1,4,10,12,19,20}; int target = 34; string name = "Bharat";

Check Input is pallendrome or not

TypeScript
3 years ago
const message:string = "353"; const newMessage:string = "NeveR Odd or b Even"; //With Predefined Functions function checkPalindromes(str){ //Regex to remove unwanted symbols or spaces var re = /[\W_]/g; //convert to lowercase for each checking var lowerStr = str.toLowerCase().replace(re,''); //reverse string

Three ways to repeat a string in JavaScript

TypeScript
3 years ago
const message:string = "Baby"; //Using While Loop function repeatStringWithWhile(str,times){ let myString = ""; while(times>0){ myString +=str; times--; } return myString;

Reverse String

TypeScript
3 years ago
const message:string = "helloworld"; //one way with built in functions function reverseStringBuildIn(str){ var mystr = str.split("").reverse().join(""); return mystr; } function reverseStringWithLoop(str){

To calculate the number of combinations to climb a certain number of steps

TypeScript
3 years ago
const num = 5; function combinationsStairs(num){ if(num<=2){ return num; } let prev = 1; let current = 2;

Encode alphabet to Number

TypeScript
3 years ago
let str = "Bha785-900#"; function charCountNumber(str){ const encodestr = []; for(let i =0;i<=str.length;i++){ const char = str.charAt(i).toUpperCase(); if(char >='A' && char<='Z'){ const encodedValue = char.charCodeAt(0) - 64;

Quick sort Without Inbuilt Typescript function

TypeScript
3 years ago
function swapNumber(arr,i,j){ var temp = arr[i]; arr[i]=arr[j]; arr[j]=temp; } function mergeNumber(arr,low,high){ const pivot = arr[high]; let i = low-1;

Quick Sort (Based On Divide and Conquer Rule same as merge sort) using additional array

TypeScript
3 years ago
// Take a last element of array as Pivot element. //Place at the right position in array and divide smaller element to left and greater //to right side of the pivot. //Based on recursive calling. function quickSort(array:number[]):number[]{ if(array.length<1) return array;

Insertion Sorting

TypeScript
3 years ago
function InsertionSort(arr,n){ let i,j,key; for(i=1;i<n;i++){ key = arr[i]; j=i-1; //traverse key with remaining element of the array //and swap with one position ahed while(j>=0 && arr[j]>key){ arr[j+1]=arr[j]; j=j-1;