Golang is strange

in #golang5 years ago

I don't like these syntax - so weird. Performing the operations to array/stack/queue is so unfriendly.

func longestValidParentheses(s string) int {
    var ans = 0
    var st = []int {-1}
    for i, c := range s {
        if c == '(' {
            st = append(st, i)
            continue
        }
        st = st[:len(st)-1]
        if len(st) == 0 {
            st = append(st, i)
        } else {
            var t = i - st[len(st)-1]
            if t > ans {
                ans = t
            }
        }
    }
    return ans
}

1a57c5c227ec904c211657d2f233656.png

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^

NEW! Following my Trail (Upvote or/and Downvote)

Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com

My contributions

Delegation Service

Important Update of Delegation Service!

  • Delegate 1000 to justyy: Link
  • Delegate 5000 to justyy: Link
  • Delegate 10000 to justyy: Link

Support me

If you like my work, please:

  1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
  2. Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
  3. Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
    Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses

Sort:  

I support you dear your work is good

Hi @justyy.. I have added my delegate to 2,008,335 SP and I am using you as voting proxy. I hope to get more upvotes from you. Thank you for your attention, Sir.

IMG_20210818_215349.jpg

IMG_20210818_215701.jpg

But you still gotta love the speed of Go when compared to several OO Languages. Go would be my go-to language for AWS lambda functions or any other serverless functions.

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.081
BTC 59524.83
ETH 1569.75
USDT 1.00
SBD 0.42