{{ message }}

Instantly share code, notes, and snippets.

coding

# Selim Ozturkselimslab

coding
Last active Sep 25, 2020 — forked from leoloobeek/get_gists.py
View get_gists.py
 import sys from subprocess import call import json import os import requests def download_gists(gists: list): for gist in gists: call(["git", "clone", gist["git_pull_url"]])
Last active Jun 13, 2020
View Channels.go
 Channels are a typed conduit through which you can send and receive values with the channel operator, <-. ch <- v // Send v to channel ch. v := <-ch // Receive from ch, and // assign value to v. (The data flows in the direction of the arrow.) Like maps and slices, channels must be created before use:
Created Jun 7, 2020
View plusOne.go
 func plusOne(digits []int) []int { /* Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. You may assume the integer does not contain any leading zero, except the number 0 itself. Example 1:
Created Jun 7, 2020
View reverseBits.go
 func reverseBits(num uint32) uint32 { /* Input: 00000010100101000001111010011100 Output: 00111001011110000010100101000000 */ res := uint32(0) power := uint32(31) for num != 0 { res += (num & 1) << power num = num >> 1
Last active Jun 7, 2020
View sortedArrayToBST.py
 def sortedArrayToBST(self, nums: List[int]) -> TreeNode: """ Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. Example: Given the sorted array: [-10,-3,0,5,9],
Created Jun 7, 2020
View removeDuplicates1.py
 def removeDuplicates(self, S: str) -> str: """ Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make duplicate removals on S until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique. Example 1:
Created Jun 7, 2020
View heap.py
 class KthLargest: """ Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Your KthLargest class will have a constructor which accepts an integer k and an integer array nums, which contains initial elements from the stream. For each call to the method KthLargest.add, return the element representing the kth largest element in the stream. Example: int k = 3; int[] arr = [4,5,8,2];
Created Jun 6, 2020
View minCostClimbingStairs.go
 func minCostClimbingStairs(cost []int) int { c1,c2 := cost[0], cost[1] var min = func(a int,b int) int { if a
Created Jun 6, 2020