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
const calculateTotal = () => { | |
// Assume this your cart. | |
let cartArr = [ | |
{ | |
'price': 1000, | |
'quantity': 12 | |
}, | |
{ | |
'price': 2000, | |
'quantity': 22 |
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
FROM golang:1.16.5 | |
ADD ./ /go/src/app | |
WORKDIR /go/src/app | |
RUN go get ./ | |
RUN go build -o ./.build/sortika main.go |
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
build: | |
docker: | |
web: Dockerfile | |
run: | |
web: ./.build/sortika |
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 Stack: | |
def __init__(self): | |
self.STACK = [] | |
def push(self, element): | |
self.STACK.append(element) | |
return self.STACK | |
def check_empty(self): | |
return len(self.STACK) == 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
package main | |
import "fmt" | |
type Stack []string | |
// IsEmpty: check if stack is empty | |
func (s *Stack) IsEmpty() bool { | |
return len(*s) == 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
def solve_n_queens(n): | |
def is_safe(board, row, col): | |
# Check if a queen can be placed at the given position without conflicting | |
# with any other queens on the board | |
for i in range(row): | |
if board[i] == col or \ | |
board[i] - i == col - row or \ | |
board[i] + i == col + row: | |
return False | |
return True |
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 Queue: | |
def __init__(self): | |
self.items = [] | |
def enqueue(self, item): | |
self.items.append(item) | |
def dequeue(self): | |
if not self.is_empty(): | |
return self.items.pop(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
package main | |
import "fmt" | |
type Queue struct { | |
items []interface{} | |
} | |
func (q *Queue) Enqueue(item interface{}) { | |
q.items = append(q.items, item) |
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 CircularQueue: | |
def __init__(self, k): | |
self.queue = [None] * k | |
self.head = self.tail = -1 | |
self.size = 0 | |
def enqueue(self, item): | |
if self.is_full(): | |
return False | |
if self.is_empty(): |
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
package main | |
type CircularQueue struct { | |
items []interface{} | |
head int | |
tail int | |
size int | |
} | |
func NewCircularQueue(k int) *CircularQueue { |