Skip to content

Instantly share code, notes, and snippets.

View gokhanakkurt's full-sized avatar
:shipit:

Gokhan Akkurt gokhanakkurt

:shipit:
View GitHub Profile
@gokhanakkurt
gokhanakkurt / nested.swift
Created October 18, 2019 08:57
Determine whether given string of parentheses is properly nested in Swift
func isNestedString(_ S : String) -> Bool {
if S.isEmpty {
return true
}
var stack: [Character] = [Character]()
for elem in S {
if elem == "(" {
stack.append(elem)
@gokhanakkurt
gokhanakkurt / prefix.swift
Created October 18, 2019 08:50
Find longest common prefix string in an array - (swift implementation, slicing method)
func longestCommonPrefix(_ strs: [String]) -> String {
// base case
if strs.isEmpty {
return ""
}
if var prefixStr = strs.first {
for index in 1..<strs.count {
let str = strs[index]
@gokhanakkurt
gokhanakkurt / fish.swift
Created October 18, 2019 08:44
N voracious fish are moving along a river. Calculate how many fish are alive.
func calculateAliveFish(_ A : inout [Int], _ B : inout [Int]) -> Int {
if A.isEmpty {
return 0 // base case
}
var stack: [Int] = [Int]()
var survivals: Int = 0
for (index,elem) in A.enumerated() {
if B[index] == 0 {
@gokhanakkurt
gokhanakkurt / converter.swift
Last active July 30, 2023 18:08
Currency Converter in Swift
struct ServiceResources {
static let exchangeUri = "https://api.exchangeratesapi.io/latest"
}
enum Currency: String {
case euro = "EUR"
case pound = "GBP"
case dollar = "USD"
case turkishLira = "TRY"
@gokhanakkurt
gokhanakkurt / elasticsearch.sh
Last active October 9, 2020 06:45
Commands for installing Elasticsearch on Centos 6
#install Java JDK
sudo yum install java-1.8.0-openjdk.x86_64
#download signing key
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
#create repo file
sudo vi /etc/yum.repos.d/elasticsearch.repo
#paste repo configurations
{
"Seti_tabs_small": true,
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"fade_fold_buttons": false,
"find_selected_text": true,
"fold_buttons": true,