This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def climbStairs(self, n: int) -> int: | |
if n==0 or n==1 or n==2: | |
return n | |
m = n+1 | |
step_n = [0] * m | |
step_n[0] = 0 | |
step_n[1] = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func deleteDuplicates(head *ListNode) *ListNode { | |
if head == nil { | |
return head | |
} | |
node:=head | |
next := head.Next | |
for node!=nil && next!=nil{ | |
if node.Val==next.Val{ | |
temp := next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func deleteDuplicates(head *ListNode) *ListNode { | |
if head == nil{ | |
return head | |
} | |
tempNode := &ListNode{Val: head.Val-1, Next:head} | |
node:=tempNode | |
fast := tempNode.Next | |
for node.Next!=nil && fast.Next!=nil{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findAllConcatenatedWordsInADict(words []string) []string { | |
res:= []string{} | |
mp:= make(map[string]int) | |
for _, word := range words { | |
mp[word] = 1 | |
} | |
for _, word := range words { | |
delete(mp, word) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "sort" | |
/** | |
* Definition for an interval. | |
* type Interval struct { | |
* Start int | |
* End int | |
* } | |
*/ | |
func insert(intervals []Interval, newInterval Interval) []Interval { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "sort" | |
func kClosest(points [][]int, K int) [][]int { | |
sort.SliceStable(points,func(i,j int)bool{ | |
point1 := points[i] | |
point2 := points[j] | |
return distance(point1[0],point1[1]) < distance(point2[0],point2[1]) | |
}) | |
return points[:K] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "strings" | |
import "strconv" | |
func solveEquation(equation string) string { | |
eqnSides := strings.Split(equation, "=") | |
leftHandSide, rightHandSide := eqnSides[0], eqnSides[1] | |
lHV,lHx := getSideSum(leftHandSide) | |
rHV,rHx := getSideSum(rightHandSide) | |
if lHx == rHx && lHV == rHV{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reverseVowels(s string) string { | |
//A, E, I, O, and U | |
vowlesMap := map[byte]bool{ | |
'a':true,'A':true, | |
'e': true,'E':true, | |
'i':true,'I':true, | |
'o':true,'O':true, | |
'u':true,'U':true} | |
vowlesValues := []byte{} | |
n:= 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% https://www.hackerrank.com/challenges/common-divisors/submissions/code/13608658 | |
% Enter your code here. Read input from STDIN. Print output to STDOUT | |
% Your class should be named solution | |
-module(solution). | |
-export([main/0]). | |
-compile(export_all). | |
main() -> | |
{ok,[A]}=io:fread("", "~d"), | |
scanner(A). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SLEEP=120 | |
MAX_CONN=20 | |
MY_IP=0.0.0.0 # Configure your IP here | |
while true; do | |
( | |
echo "create table ips (ip string);" | |
echo 'begin transaction;' | |
netstat -an | grep -v ESTABLISHED | grep ${MY_IP}:80 | awk '{print $5}' | cut -f4 -d: | while read IP; do |
NewerOlder