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 IList<IList<int>> RemoveInterval(int[][] intervals, int[] toBeRemoved) { | |
var list = new List<IList<int>>(); | |
for (int i = 0; i < intervals.Length; 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.Text; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static void Reverse(StringBuilder sb, int start, int end) { | |
while (start < end) { | |
char temp = sb[start]; | |
sb[start] = sb[end]; |
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 MaxDepth(string s) { | |
int depth = 0; | |
int curDepth = 0; | |
for (int i = 0; i < s.Length; 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 HotPotato(int n, int time) { | |
int full = time / (n - 1); | |
int extra = time % (n - 1); | |
int direction = full % 2 == 0 ? 1 : -1; | |
return direction == 1 ? extra + 1 : n - extra; |
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 class TreeNode | |
{ | |
public int val; | |
public TreeNode left; | |
public TreeNode right; | |
public TreeNode(int val, TreeNode left=null, TreeNode right=null) |
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 FindMaxDepth(string s) { | |
int depth = 0; | |
int curDepth = 0; | |
for (int i = 0; i < s.Length; i++) | |
{ | |
if (s[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; | |
public class Program | |
{ | |
public static long CountSubArrays(int[] nums, int k) { | |
int len = nums.Length; | |
int max = nums.Max(); | |
int start = 0; | |
long res = 0; int maxCountInWindow = 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.Linq; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static int FindMinNumOfUniqueIntegers(int[] arr, int k) { | |
var map = new Dictionary<int, int>(); | |
for (int i = 0; i < arr.Length; 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.Collections.Generic; | |
public class Program | |
{ | |
public static int FindMaxLengthBetweenEqualCharacters(string s) { | |
int maxLen = -1; | |
var map = new Dictionary<char, int>(); | |
for (int i = 0; i < s.Length; i++) | |
{ |
NewerOlder