Skip to content

Instantly share code, notes, and snippets.

lbvf50mobile

Block or report user

Report or block lbvf50mobile

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View isSymmetric.go
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
https://leetcode.com/problems/symmetric-tree/
Runtime: 0 ms, faster than 100.00% of Go online submissions for Symmetric Tree.
Memory Usage: 3 MB, less than 25.00% of Go online submissions for Symmetric Tree.
View move-hero.sch
#lang racket
;;; https://www.codewars.com/kata/grasshopper-terminal-game-move-function/train/racket
(provide move-hero)
(define (move-hero position roll)
(+ position (* 2 roll)))
View isSameTree.go
/**
https://leetcode.com/problems/same-tree/submissions/
BFS
Runtime: 0 ms, faster than 100.00% of Go online submissions for Same Tree.
Memory Usage: 2.2 MB, less than 50.00% of Go online submissions for Same Tree
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
View pendulum.go
package kata
import "sort"
// https://www.codewars.com/kata/the-poet-and-the-pendulum/train/go
func Pendulum(values []int) []int {
srt := append([]int{},values...)
answer := make([]int,0,0)
sort.Ints(srt)
for key, value := range srt {
if 0 == key%2 {
answer = append([]int{value}, answer...)
View merge-sorted-array.go
import "sort"
// https://tour.golang.org/moretypes/7
// https://gobyexample.com/sorting
/*
Runtime: 0 ms, faster than 100.00% of Go online submissions for Merge Sorted Array.
Memory Usage: 3.6 MB, less than 66.67% of Go online submissions for Merge Sorted Array
https://leetcode.com/problems/merge-sorted-array/submissions/
*/
func merge(a []int, m int, b []int, n int) {
x := append(a[0:m],b[0:n]...)
View swapHeadAndTail.js
// https://www.codewars.com/kata/swap-the-head-and-the-tail/train/javascript
function swapHeadAndTail(a) {
if(1 >= a.length) return a;
j = a.length%2 ? Math.trunc(a.length/2) + 1 : Math.trunc(a.length/2)
for( var i = 0; i < Math.trunc(a.length/2) ; i += 1, j+=1){
[a[i],a[j]] = [a[j],a[i]]
}
return a
}
View sicp.md

sicp next: 1.1.4 Compound Procedures 43

View deleteDuplicates.go
/**
https://leetcode.com/problems/remove-duplicates-from-sorted-list/submissions/
Runtime: 4 ms, faster than 90.10% of Go online submissions for Remove Duplicates from Sorted List.
Memory Usage: 3.1 MB, less than 50.00% of Go online submissions for Remove Duplicates from Sorted List.
*/
func deleteDuplicates(head *ListNode) *ListNode {
var pointer, pointer2 * ListNode
pointer = head
for ; pointer != nil ; {
pointer2 = pointer.Next
View longest-vowel-chain.js
// https://www.codewars.com/kata/longest-vowel-chain/train/javascript
const solve = x => Math.max(...x.split(/[^aoeiu]/i).map(x => x.length))
View climbStairs.go
// https://leetcode.com/problems/climbing-stairs/
// Time limit exceed
func climbStairs(n int) int {
counter := 0
// https://gobyexample.com/closures
// https://github.com/golang/go/issues/226
var recursion func(input int)
recursion = func (input int){
if 0 == input {
counter += 1
You can’t perform that action at this time.