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++) | |
{ |
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 | |
{ | |
private static int Target; | |
public static IList<IList<int>> Output; | |
public static IList<IList<int>> CombinationSum(int[] candidates, int target) { |
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 string DestinationCity(IList<IList<string>> paths) { | |
int len = paths.Count; | |
// частный случай | |
if (len == 1) { | |
return paths[0][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; | |
public class Program | |
{ | |
public static int FindFreqNumber(int[] arr) | |
{ | |
int len = arr.Length; | |
if (len < 3) | |
{ | |
return arr[0]; |
NewerOlder