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 class TreeNode | |
{ | |
public int val; | |
public TreeNode left; | |
public TreeNode right; |
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 bool CheckWordSquare(List<string> words) | |
{ | |
int len = words.Count; | |
for(int i = 0; i < len; i++) |
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.Linq; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static int[] ApplyDiscounts(int[] prices) | |
{ | |
int len = prices.Length; | |
var stack = new Stack<int>(); |
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.Linq; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public class StockSpan | |
{ | |
private readonly Stack<(int price, int num)> stack; | |
public StockSpan() { |
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; | |
public class Program | |
{ | |
public static int FindMissingItem(int[] nums, int k) { | |
int len = nums.Length; | |
if (len == 1) | |
return nums[0] + k; | |
for (int i = 1; i < len; i++) |
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; | |
public class Program | |
{ | |
public static int MinSubArrayLen(int target, int[] nums) | |
{ | |
int len = nums.Length; | |
int left = 0; | |
int sum = 0; | |
int res = int.MaxValue; |
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; | |
public class Program | |
{ | |
public static int GetSingleNumber(int[] nums) { | |
int single = 0; | |
int twice = 0; | |
foreach (int num in nums) | |
{ |
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; | |
public class Program | |
{ | |
public static int FindMarioWay(int[][] matrix) | |
{ | |
int rows = matrix.Length; | |
int cols = matrix[0].Length; | |
int[,] d = new int[rows, cols]; | |
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; | |
public class Program | |
{ | |
public static void DuplicateZeros(int[] arr) | |
{ | |
int len = arr.Length; | |
for(int i = 0; i < len; i++) | |
{ | |
if (arr[i] == 0) |
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 IList<int> ArraysIntersection(int[] arr1, int[] arr2, int[] arr3) | |
{ | |
int p1 = 0, p2 = 0, p3 = 0; | |
var result = new List<int>(); |