Skip to content

Instantly share code, notes, and snippets.

@respander1
respander1 / gist:b5659719c54c74322fc7a26f4453ac2c
Created October 1, 2025 17:09
3. Reverse Linked List (LeetCode #206):
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def reverse_list(head):
prev = None
current = head
@respander1
respander1 / gist:8f61140e6fc374638138f676c10b68cf
Created October 1, 2025 17:03
2. Remove Duplicates from Sorted Array (LeetCode #26
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]
@respander1
respander1 / gist:878adc8f1e8d10befa9e84aebe9b01b5
Last active October 1, 2025 17:08
1. Two Sum (LeetCode #1)
# Версия "в лоб" - 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):
@respander1
respander1 / gist:214b549ab3c3dbae59f275c1835bcfcf
Created October 1, 2025 16:53
Сравнение производительности
import time
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
@respander1
respander1 / gist:d29bddb61ef9c7b4621e35ea6294f809
Created October 1, 2025 16:46
: Реализация односвязного списка
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
using System;
class Program
{
static void Main(string[] args)
{
Random random = new Random();
int minRandom = 1;
int maxRandom = 100;
int baseNumber = 2;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
Random random = new Random();
int minN = 10;
int maxN = 25;
int minRange = 50;
using System;
class Program
{
static void Main(string[] args)
{
string correctPassword = "budapesht";
int maxAttempts = 3;
int attempts = 0;
bool isAuthenticated = false;
using System;
class Program
{
static void Main(string[] args)
{
Console.Write("Введите символ для рамки (например, *, #, %): ");
char frameSymbol = Console.ReadLine()[0];
Console.Write("Введите имя: ");
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}");