This file contains 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
public class Solution { | |
public int CompareVersion(string version1, string version2) { | |
return Compare(version1, version2); | |
} | |
public int Compare(string versionA, string versionB) | |
{ | |
// Null checks added for completeness | |
if (versionA is null && versionB is null) return 0; | |
if (versionA is null) return -1; | |
if (versionB is null) return 1; |
This file contains 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
let zoom = 1; | |
let panX = 0; | |
let panY = 0; | |
let tool = "pencil"; | |
let matrix = []; | |
const canvasWidth = 600; | |
const canvasHeight = 600; | |
let cellSize = 50; | |
let showGrid = true; | |
let strokeWeigth = 1; |
This file contains 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.Text; | |
static void Visit(TreeNode node, StringBuilder sb) => sb.Append(node.Id); | |
static TreeNode? Step(TreeNode node, HashSet<TreeNode> visited, Stack<TreeNode> stack, StringBuilder sb) | |
{ | |
if (node.Left is not null && !visited.Contains(node.Left)) | |
{ | |
stack.Push(node); | |
return node.Left; |
This file contains 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
# webserver: | |
# image: nginx:latest | |
# ports: | |
# - 80:80 | |
# - 443:443 | |
# restart: always | |
# volumes: | |
# - ./prod/nginx/www/:/var/www/html:ro | |
# - ./prod/nginx/conf/:/etc/nginx/conf.d/:ro | |
# networks: |
This file contains 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 System.Collections.Generic; | |
public class Program { | |
public static void Main(string[] args) { | |
var K = 3; | |
var A = new[]{8, 7, 5, 6, 10}; | |
//var A = new[]{9, 6}; | |
var res = Sol.Solution(A, K); |
This file contains 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
public class Solution { | |
public IList<int> FindAnagrams(string s, string p) { | |
var pFreq = new int[26]; | |
var sIndex = 0; | |
var ans = new List<int>(); | |
foreach(var letter in p) | |
pFreq[letter - 'a']++; | |
while(sIndex < s.Length){ |
This file contains 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
public class Solution { | |
public bool CheckInclusion(string s1, string s2) { | |
if(s1.Length > s2.Length) | |
return false; | |
var s2Index = 0; | |
var s1Freq = new int[26]; | |
foreach(var letter in s1) | |
s1Freq[letter - 'a']++; | |
while(s2Index < s2.Length){ |
This file contains 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
public class Solution { | |
public IList<IList<int>> FindWinners(int[][] matches) { | |
var winnerDict = new Dictionary<int, int>(); | |
var loserDict = new Dictionary<int, int>(); | |
foreach(var m in matches){ | |
var winner = m[0]; | |
var loser = m[1]; | |
if(!winnerDict.ContainsKey(winner)) | |
winnerDict.Add(winner, 0); | |
if(!loserDict.ContainsKey(loser)) |
This file contains 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
public class Solution { | |
public int RemoveDuplicates(int[] nums) { | |
var i = 1; | |
var j = 1; | |
var k = 1; | |
var last = nums[0]; | |
while(i < nums.Length){ | |
while(i < nums.Length && nums[i] <= last) | |
i++; | |
if(i == nums.Length) |
This file contains 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
public class Solution { | |
public int DepthSum(IList<NestedInteger> nestedList) { | |
int Traverse(in IList<NestedInteger> list, in int depth = 1){ | |
var sum = 0; | |
foreach(var e in list){ | |
if(e.IsInteger()){ | |
sum += e.GetInteger() * depth; | |
continue; | |
} | |
sum += Traverse(e.GetList(), depth + 1); |
NewerOlder