Skip to content

Instantly share code, notes, and snippets.

View alex-bezverkhniy's full-sized avatar

Alexander Bezverkhniy alex-bezverkhniy

View GitHub Profile
@alex-bezverkhniy
alex-bezverkhniy / two_sum.rs
Last active August 2, 2021 14:15 — forked from rust-play/playground.rs
Code shared from the Rust Playground
struct Solution;
impl Solution {
// [2, 7, 11, 15] t = 9
// [3, 4, 2] t = 6
fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut j = 0;
for (i, &num) in nums.iter().enumerate() {
if i > 0 {