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]; |
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 string FindLarge3DigitNum(string num) | |
{ | |
string result = ""; | |
for (int i = 0; i < num.Length - 2; 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 string ConvertNumToBinaryString(int num, int length) | |
{ | |
string binary = Convert.ToString(num, 2); | |
// добавляем ведущие нули до размера 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
using System; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public class SeatReserver | |
{ | |
private int N; | |
private PriorityQueue<int, int> availableSeats; | |
public SeatReserver(int n) { |
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[] FindOriginArray(int[] pref) | |
{ | |
int[] res = new int[pref.Length]; | |
res[0] = pref[0]; | |
for (int i = 1; i < pref.Length; i++) | |
{ |
NewerOlder