This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var matrix = new int[] { 2, 5, 8, 7, 6, 1 }; | |
| var loopLength = matrix.Length - 1; | |
| var firstSmallElementIndex = -1; | |
| //1. Find the index where there's small element on left hand side |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var arrival = new int[] { 900, 940, 950, 1100, 1500, 1800 }; | |
| var departure = new int[] { 910, 1200, 1120, 1130, 1900, 2000 }; | |
| Array.Sort(arrival); | |
| Array.Sort(departure); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| There are N children standing in a line with some rating value. You want to distribute a minimum number of candies to these children such that: | |
| Each child must have at least one candy. | |
| The children with higher ratings will have more candies than their neighbors. | |
| You need to write a program to calculate the minimum candies you must give. | |
| class Program | |
| { | |
| public static void Main(string[] args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace ConsoleApp1 | |
| { | |
| class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var matrix = new int[,] { | |
| { 1, 2, 3, 4,5}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array of length n having integers 1 to n with some elements being repeated. | |
| Count frequencies of all elements from 1 to n in Time Complexity O(n) and Space Complexity O(1) | |
| class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var matrix = new int[] { 5, 2, 7, 7, 5, 5, 2 }; | |
| var someUniqueNumberGreaterThan = matrix.Max() + 1; |
OlderNewer