Rust OS
Writing an Operating System in Rust, code can be found here: (https://github.com/Interstellarss/rcore-os). This project is a hands-on way to deepen my understanding of Rust and operating system internals. By building the kernel from scratch, I can explore approaches to limitations encountered in mainstream operating systems and experiment with ideas without the constraints of an established platform. Some ideas I want to explore: CortenMM XSched The materils I used: (https://os.phil-opp.co...
CF 817 E - Choosing The Commander
题目描述E. Choosing The Commander[2000] time limit per test2 secondsmemory limit per test256 megabytesAs you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors. Each warrior is represented by his personality — an integer number pi. Each command...
CF 817 F
题目描述F. MEX Queries[2300] F. MEX Queriestime limit per test2 secondsmemory limit per test256 megabytes You are given a set of integer numbers, initially it is empty. You should perform n queries. There are three different types of queries: 1 l r — Add all missing numbers from the interval [l, r] 2 l r — Remove all present numbers from the interval [l, r] 3 l r — Invert the interval [l, r] — add all missing and remove all present numbers from the interval [l, r]After each query you should outp...
C++ STL Unordered Map and Set
Unordered Map and Setbasically wrapper on top of hash table for unordered_map, pair<Key, Value> is the value_typefor unordered_set, Key is the value_type unordered_map12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#ifndef MY_UNORDERED_MAP#define MY_UNORDERED_MAP#include "my_hashtable.h"namespace mystl {template < typename Key, typename Value, typename Hash = std::hash<Key>, ...
LeetCode 32 Longest Valid Parentheses
32. Longest Valid Parentheses[HARD] 题目描述Given a string containing just the characters ‘(‘ and ‘)’, return the length of the longest valid (well-formed) parentheses substring. Example 1: 123Input: s = "(()"Output: 2Explanation: The longest valid parentheses substring is "()". Example 2: 123Input: s = ")()())"Output: 4Explanation: The longest valid parentheses substring is "()()". Example 3: 12Input: s = ""Output: 0 解题思路 - 1DP,动态规划 我们用一个数组 dp...
CF 2156 C
C. Maximum GCD on Whiteboard题目描述
LeetCode 23 - Merge k Sorted Lists
题目Merge k Sorted Lists[HARD] Given k sorted linked lists, merge them into one sorted linked list and return it. Example 1:Input: lists = [[1,4,5],[1,3,4],[2,6]]Output: [1,1,2,3,4,4,5,6]Explanation: The linked-lists are:[ 1->4->5, 1->3->4, 2->6]merging them into one sorted list:1->1->2->3->4->4->5->6 思路priority queue (min heap) 代码12345678910111213141516171819202122232425262728293031323334353637class Solution {public: struct compare{ ...
LeetCode 42 - Trapping Rain Water
题目Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. 思路代码123456789101112131415161718192021222324252627282930class Solution {public: int ...
CF 1065 C
题目Cutting Towers [1600] There is a toy building consisting of n towers. Each tower consists of several cubes standing on each other. The i-th tower consists of hi cubes, so it has height hi. Let’s define operation slice on some height H as following: for each tower i, if its height is greater than H, then remove some top cubes to make tower’s height equal to H. Cost of one “slice” equals to the total number of removed cubes from all towers. Let’s name slice as good one if its cost is lower or...
LeetCode 3
题目Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without duplicate characters. Example 1:Input: s = “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3. Example 2:Input: s = “bbbbb”Output: 1Explanation: The answer is “b”, with the length of 1. Example 3:Input: s = “pwwkew”Output: 3Explanation: The answer is “wke”, with the length of 3.Notice that the answer must be a substring, “pwke” is a subseque...