Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
Programming

Abdulrahman Alotaibi abdulrahmanAlotaibi

🎨
Programming
  • Riyadh, KSA
View GitHub Profile
View minStack.go
type MinStack struct {
stack [][]int
top int
}
func Constructor() MinStack {
stack := [][]int{}
return MinStack{
stack:stack,
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / ringbuffer.go
Created Dec 23, 2022
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
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 Dec 15, 2022
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 Dec 15, 2022
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 Dec 15, 2022
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 Dec 15, 2022
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 Dec 15, 2022
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 Dec 15, 2022
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
View isAnagram.go
func isAnagram(s string, t string) bool {
var message Text
json.Unmarshal(data, &message)
if len(s) != len(t) && len(t) > int(math.Pow(10, 4) * 5) || len(s) < 1 {
return false
}
for i := 0 ; i < len(s) ; i++{
isChExsist := false