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.Collections; | |
| using UnityEngine; | |
| public class SafeCoroutine | |
| { | |
| private Coroutine _coroutine; | |
| private IEnumerator _routine; | |
| private MonoBehaviour _owner; | |
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
| /** | |
| * Problem Statement: | |
| * ------------------- | |
| * Given an array of integers and two distinct integers x and y, | |
| * the task is to find the minimum distance between any occurrence of x and y in the array. | |
| * The distance between two positions is defined as the absolute difference of their indexes. | |
| * | |
| * Example: | |
| * --------- | |
| * Input: |
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
| /* | |
| Problem Statement: | |
| Given two strings s and t, count the number of subsequences of s (including the | |
| empty subsequence) such that the lexicographical order of the subsequence is | |
| strictly greater than string t. | |
| - You can choose any subsequence of s by deleting zero or more characters. | |
| - For comparison, if the chosen subsequence is shorter than t, pad it with | |
| characters to compare as necessary. | |
| - Return the count modulo 1e9 + 7. |
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 luhn(s: str) -> bool: | |
| sum = 0 | |
| for i in range(len(s) - 1, -1, -2): | |
| sum += int(s[i]) | |
| if i != 0: | |
| dd = int(s[i-1]) * 2 | |
| if dd > 9: | |
| dd -= 9 | |
| sum += dd |
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
| #include <algorithm> | |
| #include <climits> | |
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| int min_total_risk_cost(vector<int> &scores, int k) { | |
| int n = scores.size(); |
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
| #include <algorithm> | |
| #include <cstdlib> | |
| #include <ctime> | |
| #include <iostream> | |
| #include <map> | |
| #include <random> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; |
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
| from collections import defaultdict | |
| from itertools import chain | |
| class Graph: | |
| def __init__(self, vertices: list[str]): | |
| self._graph = defaultdict(list) | |
| self._V = vertices | |
| def add_edge(self, u: str, v: str): |
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
| #include <math.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int *sieve_of_eratosthenes(const int n) { | |
| int *primes = (int *)malloc(sizeof(int) * (n + 1)); | |
| for (int i = 0; i < n + 1; i++) { | |
| primes[i] = 1; | |
| } |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define TABLE_SIZE 10000 | |
| typedef struct entry_t { | |
| char *key; | |
| char *value; | |
| struct entry_t *next; |
NewerOlder