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
private static char[] CheckerHelper() => "programmer".ToCharArray(); | |
//Time: O(n) where n is the length of s | |
//Memory: O(1) using a fixed length char[] checkerHelper | |
static int StringProgrammer(string s) | |
{ | |
var checkerHelper = CheckerHelper(); | |
var lettersFound = 0; | |
for(var i = 0; i < s.Length; i++) |
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
//Time: O(n) where n is weight | |
//Memory: O(1) weights array helper with length . of 26 | |
//In this solution, I am searching in the array of weights from biggest to smallet | |
//comparing values with weight searched. | |
//When find a value in the array that fits the weight being searched | |
//use array index to calculate a char ascii value which represent a | |
//character wight in the result. |
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
//Time: O(n) where n is weight | |
//Memory: O(1) weights helper with 26 key:value pairs | |
//In this solution, I am decreasing weights one by one | |
//and searching its value in the weigths helper. | |
//As bigger the weight is the longer will take to algorithm execute | |
//I wrote a better solution using an array instead of a hashmap as a helper | |
//https://gist.github.com/WennderSantos/2256be4706a4f3cd6121ab322116a918 |
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; | |
using static System.Console; | |
namespace _90graus | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var length = 3; |
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
static void Main(string[] args) | |
{ | |
var input = new int[] { -60, -3, 5, 4, 8, 1, 10, 15, 17 }; | |
(int first, int second, int third) maxValues = (int.MinValue, int.MinValue, int.MinValue); | |
(int first, int second) minValues = (int.MaxValue, int.MaxValue); | |
((int first, int second, int third), (int first, int second)) values = (maxValues, minValues); | |
for (var i = 0; i < input.Length; i++) | |
values = Rearenge(values.Item1, values.Item2, input[i]); |
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 | |
{ | |
static void Main(string[] args) | |
{ | |
var arr1 = new int[] { 10, 12, 5, 6, 3 }; | |
var arr2 = new int[] { 1, 9, 4, 8, 2, 3 }; | |
var arr1Sort = new int[] { 5, 8, 9, 13 }; | |
var arr2Sort = new int[] { 6, 7, 10, 11, 12, 13 }; |
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
static void Main(string[] args) | |
{ | |
var input = new int[] { 1, 4, 3, 5, 6, 7, 8, 1 }; | |
var smallest = input[0]; | |
var secondSmallest = input[1]; | |
if(smallest > secondSmallest) | |
{ | |
var aux = smallest; |
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 Node | |
{ | |
public Node(int data) => Data = data; | |
public int Data { get; } | |
public Node Left { get; set; } | |
public Node Rigth { get; set; } | |
public void Add(int value) | |
{ |
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 Node | |
{ | |
public Node(int data) => Data = data; | |
public int Data { get; } | |
public Node Left { get; set; } | |
public Node Rigth { get; set; } | |
public void Add(int value) | |
{ |
NewerOlder