solved a leetcode

This commit is contained in:
Fitz1987
2021-07-21 11:03:56 -05:00
parent 5dc3605fa1
commit c0df7230fd
5 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
-lib kiss
-cp src
--main leet_code.Main
-dce full
--python main.py
-cmd python3 main.py

View File

@@ -0,0 +1,17 @@
{
"main": "leet_code.Main",
"name": "leet-code",
"description": "",
"classPath": "src/",
"dependencies": {
"kiss": ""
},
"url": "https://github.com/NQNStudios/kisslang.git",
"contributors": [
"amelia, nat"
],
"version": "0.0.0",
"releasenote": "",
"tags": [],
"license": "LGPL"
}

View File

@@ -0,0 +1,7 @@
package leet_code;
import kiss.Kiss;
import kiss.Prelude;
@:build(kiss.Kiss.build())
class Main {}

View File

@@ -0,0 +1,20 @@
(defun :Void main []
(defun :Array<Int> twosum [:Array<Int> numbers target]
(let [di (new Map<Int,Int>)]
(doFor [i num] (zip (collect (range numbers.length)) numbers Throw)
(print "$i $num" )
(if (di.exists (- target num))
(return [( + 1 (dictGet di (- target num) )) ( + i 1)])
)
(dictSet di num i)
)
)
(return null)
)
(print (twosum [1 2 3 4 5 6 ] 5) )
)

3
projects/leet-code/test.sh Executable file
View File

@@ -0,0 +1,3 @@
#! /bin/bash
haxe build.hxml