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
/* | |
* C++20 Standard Required | |
* Author: Sicheng He | |
* Date: 2024-02-06 | |
*/ | |
#include<iostream> | |
#include<queue> | |
#include<vector> | |
#include<concepts> | |
#include<optional> |
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
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
class Solution { | |
private static boolean withBounds(int x, int y, int m, int n) { | |
return x >= 0 && x < m && y >= 0 && y < n; | |
} | |
private static int flatten(int x, int y, int m, 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
import java.util.*; | |
import java.util.function.Consumer; | |
/** | |
* An enhanced ArrayDeque enabling indexed access and modification via {@code get(int index)} and {@code set(int index, E e)} methods. | |
* The majority of this implementation is directly borrowed from the official ArrayDeque. | |
* | |
* @param <E> the type of elements held in this collection | |
*/ | |
public class MyArrayDeque<E> extends AbstractCollection<E> implements Deque<E> { |
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
#include<iostream> | |
#include<vector> | |
#include<set> | |
// we assume that for the same elements, the iteration order is always the same | |
// which is not the case for unordered_map | |
void _topological_ordering(std::set<int>& s, | |
std::vector<int>& v, |