S

@SSR17

(Use LeetCode) Copy the input array in reverse order for incoming n number of times

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { int[] inputArray = {40,50,60}; int copyTimes =2; //int lastElement = inputArray.Length; //int[] inputArray = Array.reverse(inputArrayReverse); Reverse(inputArray, 0, inputArray.Length);

Subset Sum

C#
2 years ago
using System; using System.Collections.Generic; namespace MyCompiler { class Program { public static void Main(string[] args) { //Not the correct solution //int[] arr = {2,3}; int[] arr = {2, 4, 5}; List<int> listSubset = new List<int>();

Find the length of largest subarray with 0 sum

C#
2 years ago
using System; using System.Collections.Generic; namespace MyCompiler { class Program { public static void Main(string[] args) { //=======================START=============================// //For above code below is the time and space complexity //Time Complexity: O(N2) //Auxiliary Space: O(1)

Group Anagram

C#
2 years ago
using System; using System.Collections.Generic; using System.Text; namespace MyCompiler { class Program { public static IList<IList<string>> GroupAnagrams(string[] strs) { var result = new List<IList<string>>(); var seen = new Dictionary<string, List<string>>();

Malware Analysis

C#
2 years ago
using System; namespace MyCompiler { class Program { public static int[] detectMalware(int[] elements){ int left = 3; int right =4; int[] newElements = new int[elements.Length]; elements.CopyTo(newElements,0); for(int i=0;i<elements.Length; i++){

Class with static variables and concrete methods

C#
2 years ago
using System; namespace MyCompiler { public class TestStatic { public static int TestValue; public TestStatic() { if (TestValue == 0)

write code to calculate the circumference of the circle, without modifying the Circle class itself.

C#
2 years ago
using System; namespace MyCompiler { public sealed class Circle { private double radius; public double Calculate(Func<double, double> op) { return op(radius); } }

Class with static class and same name class

C#
2 years ago
using System; namespace MyCompiler { static class ProgramStatic{ public static void print() { Console.WriteLine("in Static application"); } } class Program { Console.WriteLine("Hello world!");

LINQ

C#
2 years ago
using System; using System.Collections.Generic; using System.Linq; namespace MyCompiler { class Student{ public int StudentID; public string StudentName; public int Age; }

"#G@$OOD" To "#D@$OOG"

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); string input = "#G@$OOD"; char[] inputChar = input.ToCharArray(); char[] output = new char[inputChar.Length]; for(int i =0 ; i < input.Length; i++){

Remove Element from array and put in a separate array

C#
2 years ago
using System; using System.Collections.Generic; using System.Linq; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); int[] numbers = {1,3,6,7,3,5}; //Creating list for storing the removed element

Count each word length

C#
2 years ago
using System; using System.Linq; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); string input = "this is apple"; string[] inputarry = input.Split(" "); foreach(var ele in inputarry){

Daily Tempatures using Stack

C#
2 years ago
using System; using System.Collections.Generic; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); // Stack used to save the array index of each item int[] temperatures = {73,74,75,71,69,72,76,73}; var stack = new Stack<int>();

Daily Temperature

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); int[] inputTemps= {73,74,75,71,69,72,76,73}; //int[] inputTemps= {73,74,75,71,76,72,77,73}; int[] answer = new int[inputTemps.Length]; bool noTempGreater = false;

Print second largest from unsorted array in one loop

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); int firstLargest = 0; int secondLargest = 0; int[] arr={4,3,3,4}; for (int i=0; i<arr.Length;i++){

Print sum of individual numbers

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); int number = 168; int result = 0 ; //find sum while(number>0){

Prime Numbers

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); //--My code--// //Concerncs --> this will run the loop for even numbers as well //To avoid that check whether it is divisble for 2.

Left Rotation of elements

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); int[] arr = {2,1}; int firstElement = arr[0]; int i=0; for(i=0; i< arr.Length-1 ; i++){

Print Combination of Strings

C#
2 years ago
using System; using System.Text; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); //--Tried but failed-start-// string input = "abcd"; string result = "";

Remove Duplicates

C#
2 years ago
using System; namespace MyCompiler { class Program { public static void Main(string[] args) { Console.WriteLine("Hello world!"); string result = ""; string input = "aabbcc"; foreach(var character in input){ if(!result.Contains(character)){