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
class ListNode: | |
def __init__(self, val=0, next=None): | |
self.val = val | |
self.next = next | |
def reverse_list(head): | |
prev = None | |
current = head |
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 remove_duplicates(nums): | |
if not nums: | |
return 0 | |
i = 0 | |
for j in range(1, len(nums)): | |
if nums[j] != nums[i]: | |
i += 1 | |
nums[i] = nums[j] |
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
# Версия "в лоб" - O(n^2) | |
def two_sum_brute(nums, target): | |
for i in range(len(nums)): | |
for j in range(i + 1, len(nums)): | |
if nums[i] + nums[j] == target: | |
return [i, j] | |
return [] | |
# Улучшенная версия с хэш-таблицей - O(n) | |
def two_sum_optimized(nums, target): |
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
import time | |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.head = None |
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
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.head = None | |
self.tail = None | |
self.length = 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; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random random = new Random(); | |
int minRandom = 1; | |
int maxRandom = 100; | |
int baseNumber = 2; |
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
namespace ConsoleApp2 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random random = new Random(); | |
int minN = 10; | |
int maxN = 25; | |
int minRange = 50; |
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; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string correctPassword = "budapesht"; | |
int maxAttempts = 3; | |
int attempts = 0; | |
bool isAuthenticated = false; |
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; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.Write("Введите символ для рамки (например, *, #, %): "); | |
char frameSymbol = Console.ReadLine()[0]; | |
Console.Write("Введите имя: "); |
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; | |
class CurrencyConverter | |
{ | |
static void ShowBalance(double usd, double eur, double gbp) | |
{ | |
Console.WriteLine("\nВаш баланс:"); | |
Console.WriteLine($"Доллары (USD): {usd:F2}"); | |
Console.WriteLine($"Евро (EUR): {eur:F2}"); | |
Console.WriteLine($"Фунты (GBP): {gbp:F2}"); |
NewerOlder