Skip to content

Instantly share code, notes, and snippets.

:electron:
Overthinking

Ahmad M ElShareif Ahmah2009

:electron:
Overthinking
Block or report user

Report or block Ahmah2009

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
@Ahmah2009
Ahmah2009 / deleteDuplicates.go
Created Apr 6, 2019
83. Remove Duplicates from Sorted List leetcode
View deleteDuplicates.go
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
@Ahmah2009
Ahmah2009 / deleteDuplicates.go
Created Apr 6, 2019
82. Remove Duplicates from Sorted List II leetcode
View deleteDuplicates.go
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{
@Ahmah2009
Ahmah2009 / findAllConcatenatedWordsInADict.go
Created Apr 4, 2019
472. Concatenated Words leetcode
View findAllConcatenatedWordsInADict.go
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)
@Ahmah2009
Ahmah2009 / insert.go
Created Apr 4, 2019
57. Insert Interval leetcode
View insert.go
import "sort"
/**
* Definition for an interval.
* type Interval struct {
* Start int
* End int
* }
*/
func insert(intervals []Interval, newInterval Interval) []Interval {
@Ahmah2009
Ahmah2009 / kClosest.go
Created Apr 4, 2019
973. K Closest Points to Origin leetcode
View kClosest.go
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]
}
@Ahmah2009
Ahmah2009 / solveEquation.go
Created Apr 4, 2019
640. Solve the Equation Leetcode
View solveEquation.go
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{
@Ahmah2009
Ahmah2009 / reverseVowels.go
Created Apr 4, 2019
345. Reverse Vowels of a String leetCode
View reverseVowels.go
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
@Ahmah2009
Ahmah2009 / common-divisors.erl
Last active Mar 27, 2019
Hacker Rank problems solve by Erlang @Ahmah2009
View common-divisors.erl
%% 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).
@Ahmah2009
Ahmah2009 / gist:e09d72ed6b2280b5c45e5eb568f1a743
Created Nov 8, 2018 — forked from dmytro/gist:7887843
Shell script for SYN flood DOS attacks prevention. Use sqlite3 to filter IP's
View gist:e09d72ed6b2280b5c45e5eb568f1a743
#!/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
View firewall-olto
#!/bin/bash
# Script iptables by olto
# Réinitialisation
iptables -F
echo - Réinitialisation... : [OK]
# Suppression des chaînes utilisateurs
You can’t perform that action at this time.