Skip to content

Commit

Permalink
Merge pull request #1 from whanyu1212/dev-julia
Browse files Browse the repository at this point in the history
setting up folder directory using placeholders
  • Loading branch information
whanyu1212 authored Jul 9, 2024
2 parents e62d5fd + 1c6c376 commit 294c337
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Empty file added src/kattis/placeholder.py
Empty file.
9 changes: 9 additions & 0 deletions src/leetcode/twoSum.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function twoSum(nums::Vector{Int}, target::Int)
dict = Dict{Int, Int}()
for (i, num) in enumerate(nums)
if haskey(dict, target - num)
return [dict[target - num], i]
end
dict[num] = i
end
end
Empty file.
9 changes: 9 additions & 0 deletions tests/leetcode/testTwoSum.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Test
include("../../src/leetcode/twoSum.jl")


@testset "twoSum" begin
@test twoSum([2, 7, 11, 15], 9) == [1, 2]
@test twoSum([3, 2, 4], 6) == [2, 3]
@test twoSum([3, 3], 6) == [1, 2]
end

0 comments on commit 294c337

Please sign in to comment.