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
| #![feature(async_await, await_macro, futures_api)] | |
| use futures::task::SpawnExt; | |
| use futures::io::{AsyncReadExt, AsyncWriteExt, AllowStdIo}; | |
| use romio::TcpStream; | |
| async fn send_and_receive_request(id: i32) { | |
| eprintln!("BEGIN send_and_receive_request #{}", id); |
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
| #[derive(Debug, Clone)] | |
| struct AutoRc<T>(pub std::rc::Rc<T>); | |
| impl<T: Clone> std::ops::Not for &AutoRc<T> { | |
| type Output = AutoRc<T>; | |
| fn not(self) -> Self::Output { | |
| AutoRc(self.0.clone()) | |
| } | |
| } |
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
| // Simple | |
| fun arrayManipulation(n: Int, queries: Array<Array<Int>>): Long { | |
| val checkpoints = Array<Long>(n, { 0 }) | |
| for ((start, end, value) in queries) { | |
| checkpoints[start - 1] += value.toLong() | |
| if (end < n) { | |
| checkpoints[end] -= value.toLong() | |
| } | |
| } |
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
| // Simple | |
| fn array_manipulation_simple(n: usize, queries: &[(usize, usize, isize)]) -> isize { | |
| let mut checkpoints = vec![0; n]; | |
| for &(start, end, value) in queries { | |
| checkpoints[start - 1] += value; | |
| if end < n { | |
| checkpoints[end] -= value; | |
| } | |
| } |
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
| /// This is a direct line-by-line translation from C++ solution: | |
| /// https://github.com/LyashenkoGS/cpluplus_study/blob/master/test/Solution.cpp | |
| /// | |
| /// The point is to show that Rust can save your ass. | |
| struct Solution {} | |
| impl Solution { | |
| fn processParenthesis(stack1: &mut Vec<char>, item: char, openSign: char, closingSign: char) { | |
| if item == openSign { |
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
| //! https://leetcode.com/problems/container-with-most-water/ | |
| //! | |
| //! Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, | |
| //! ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). | |
| //! Find two lines, which together with x-axis forms a container, such that the container contains | |
| //! the most water. | |
| //! | |
| //! Note: You may not slant the container and n is at least 2. | |
| fn max_area_brute_force(height: Vec<i32>) -> i32 { |
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
| //[dependencies] | |
| //serde_json = "1.0" | |
| use serde_json::Value; | |
| use std::collections::{HashMap, HashSet}; | |
| const FILE_BUFFER_SIZE: usize = 50000; | |
| //source data | |
| #[derive(Default)] |
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
| SELECT COUNT(*) FROM dots.`2018_users`; | |
| SELECT COUNT(*) FROM dots.`2018_problems`; | |
| SELECT COUNT(*) FROM dots.`2018_solutions`; | |
| SELECT COUNT(*) FROM dots.`2018_messages`; | |
| SELECT * FROM dots.`2018_problems` WHERE complexity > 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
| $ ./scripts/start_localnet.py | |
| **************************************************** | |
| * Running NEAR validator node for Local TestNet * | |
| **************************************************** | |
| Using default tag: latest | |
| latest: Pulling from nearprotocol/nearcore | |
| c64513b74145: Pull complete | |
| 01b8b12bad90: Pull complete | |
| c5d85cf7a05f: Pull complete |
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 { context, storage, logging, ContractPromise, util } from "near-runtime-ts"; | |
| export class AddArgs { | |
| a: i32; | |
| b: i32; | |
| }; | |
| export class MultiplyByArgs { | |
| x: i32; | |
| }; |
OlderNewer