This file contains hidden or 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
def maximumBags(capacity, rocks, additionalRocks): | |
# Вычитаем текущее количество камней из ёмкости | |
capacity = [c - r for c, r in zip(capacity, rocks)] | |
# Сортируем по возрастанию оставшегося места | |
capacity.sort() | |
result = 0 | |
for space in capacity: | |
if space > 0 and additionalRocks == 0: |
This file contains hidden or 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 MaxBags(int[] capacity, int[] rocks, int additionalRocks) { | |
for (int i = 0; i < capacity.Length; i++) | |
{ | |
capacity[i] -= rocks[i]; | |
} |
This file contains hidden or 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[] DefuseBomb(int[] arr, int k) { | |
int N = arr.Length; | |
var res = new int[N]; | |
if (k == 0) { | |
return res; | |
} |
This file contains hidden or 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; | |
public class Program | |
{ | |
public static string CompressedStr(string str) { | |
var res = new StringBuilder(); | |
int index = 0; | |
while (index < str.Length) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |
NewerOlder