Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
Programming

Abdulrahman Alotaibi abdulrahmanAlotaibi

🎨
Programming
  • Riyadh, KSA
View GitHub Profile
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / binarySearch.go
Created February 7, 2023 04:23
BinarySearchAlgorithim on sorted array
View binarySearch.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, World!")
arr := []int{1,2,3,4}
View minStack.go
type MinStack struct {
stack [][]int
top int
}
func Constructor() MinStack {
stack := [][]int{}
return MinStack{
stack:stack,
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / ringbuffer.go
Created December 23, 2022 22:47
Ring Buffer / Circular Queue
View ringbuffer.go
type MyCircularQueue struct {
size int
head int
queue []int
}
func Constructor(k int) MyCircularQueue {
queue := make([]int, k)
size := 0
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / isSymmetric.go
Created December 15, 2022 23:36
Tree: Symmetric Tree
View isSymmetric.go
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func isSymmetric(root *TreeNode) bool {
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / maxDepth.go
Created December 15, 2022 23:35
Trees : Maximum Depth of Binary Tree
View maxDepth.go
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
type t struct {
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / hasCycle.go
Created December 15, 2022 23:34
Linkedlists : Linked List Cycle
View hasCycle.go
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func hasCycle(head *ListNode) bool {
dummy := head
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / isPalindrome.go
Created December 15, 2022 23:34
Linkedlist Palindrome Linked List
View isPalindrome.go
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func isPalindrome(head *ListNode) bool {
dummy := &ListNode{
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / reverseList.go
Last active December 15, 2022 23:33
Linkedlist Reverse Linked List
View reverseList.go
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func reverseList(head *ListNode) *ListNode {
dummy := head
var prev *ListNode
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / removeNthFromEnd.go
Created December 15, 2022 23:32
Linkedlist: Remove Nth Node From End of List
View removeNthFromEnd.go
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func removeNthFromEnd(head *ListNode, n int) *ListNode {
dummy := &ListNode{}
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / deleteNode.go
Created December 15, 2022 23:32
Linkedlist: Delete Node in a Linked List
View deleteNode.go
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func deleteNode(node *ListNode) {
node.Val = node.Next.Val
node.Next = node.Next.Next