Skip to content

Instantly share code, notes, and snippets.

View namtx's full-sized avatar
🐤
Fullstuck developer

0x6e616d7478 namtx

🐤
Fullstuck developer
View GitHub Profile
package main
import (
"fmt"
)
func main() {
nums := []int{2, 7, 11, 15}
target := 9
fmt.Println(twoSum(nums, target)) // [1, 2]
func binaryGap(N int) int {
count := 0
max := 0
isPreviousOne := false
for N > 0 {
// fmt.Println(N % 2)
if N%2 == 1 {
if count > max {
max = count
}
package main
import (
"fmt"
)
func main() {
s := "leetcode"
fmt.Println(firstUniqChar(s))
}
package main
import (
"fmt"
)
func main() {
str := "hello"
for _, c := range str {
fmt.Println(c)
package main
import (
"fmt"
"sort"
)
func main() {
A := []int{32, 38, 8, 1, 9}
B := []int{68, 92}
@namtx
namtx / package.json
Created September 7, 2018 08:40
Typescript with Webpack
{
"name": "ts-playground",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"run": "webpack --mode development --display none && node dist/bundle.js",
"start": "webpack --mode development",
"build": "webpack --mode production"
},
greet = function(person) {
switch(person,
Nick = {
# fast and smart
Sys.sleep(3); 'Hello!'
},
Yihui = {
# slow and shy
Sys.sleep(15); '你好!'
}
@namtx
namtx / init.el
Last active August 10, 2018 10:29
emacs config
;; Minimal UI
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(add-to-list 'default-frame-alist '(font . "Inconsolata Bold"))
(add-to-list 'default-frame-alist '(height . 24))
(add-to-list 'default-frame-alist '(width . 80))

\nHow Nike Run Club led me to write my first AI project\n\n\n\n\nFor a long time I’ve wanted to start learning how to use AI as part of my code flow. Whereshould I start? Well, I don’t have B.Sc and definitely don’t have the math fundamentals to understand all the equations and calculations behind it. But then, I have came across this amazing article of Jason Brownlee and I’ve started believing again!\n\nAfter reading many times this article and understanding it I can finally tell that I’m fluency with KNN algorithm. Let’s talk about KNN a bit.\n\n# KNN Algorithm\n\nImagine you are in the World Cup. You see three pubs of different fans: England, Sweden and France. You are welsh, whom would you celebrate with? of course England because you are both in Great Britain!\n\nThat is the meaning of KNN: K Nearest Neighbors. \nOur data will be classified to the nearest type in the same dimension:\n

Content: HuyND đã lập trình một con robot. Robot đi theo đường thẳng và có thể nhận lệnh "T" ("quay 180 độ") và "F" ("đi 1 đơn vị về phía trước").

Bạn được cho 1 danh sách các lệnh cho robot. Bạn cần phải đổ chính xác n lệnh từ danh sách (1 lệnh có thể đổi nhiều lần). Vậy Robot có thể đi tối đa bao xa nếu theo đúng thứ tự các lệnh sau khi đã chỉnh sửa ?

Input

Dòng đầu tiên là chuỗi các dòng lệnh ban đầu. Chiều dài từ 1 đến 100 kí tự, bao gồm chỉ 2 lệnh "T" và "F". Dòng thứ 2 là số nguyên n (1 ≤ n ≤ 50) — Số lệnh bạn phải đổi trong danh sách.