Skip to content

Instantly share code, notes, and snippets.

View slzdevsnp's full-sized avatar

sviatoslav zimine slzdevsnp

  • UK
View GitHub Profile
@slzdevsnp
slzdevsnp / al_stacks_ap_impl_queue_with_2stacks_problem.md
Last active December 12, 2019 12:58
[al_stacks_ap_impl_queue_with_2stacks] #algo #stacks #aproblem #mkqueuewithstacks

Problem

Given the Stack class below, implement a Queue class using two stacks! Note, this is a "classic" interview problem. Use a Python list data structure as your Stack.

common interview problem

@slzdevsnp
slzdevsnp / al_stacks_ap_brackets_balanced_problem.md
Last active December 11, 2019 17:08
[al_stacks_ap_brackets_balanced] #algo #stacks #aproblem #bracketsbalancedcheck

Problem

Given a string of opening and closing parentheses, check whether it’s balanced. We have 3 types of parentheses: round brackets: (), square brackets: [], and curly brackets: {}. Assume that the string doesn’t contain any other character than these, no spaces words or numbers. As a reminder, balanced parentheses require every opening parenthesis to be closed in the reverse order opened. For example ‘([])’ is balanced but ‘([)]’ is not.

You can assume the input string has no spaces.

@slzdevsnp
slzdevsnp / al_arrays_sequences_readme.md
Last active December 11, 2019 17:12
[al_arrays] #algo #cs #arrays #datastructure

arrays in python

list, tuple string

ss='abc' ss[0] yields 'a'

arrays low level

@slzdevsnp
slzdevsnp / al_arrays_ap_string_compression_problem.md
Created December 11, 2019 16:29
[al_arrays_ap_string_compression] #algo #arrays #aproblem #stringcompression

Problem

Given a string in the form 'AAAABBBBCCCCCDDEEEE' compress it to become 'A4B4C5D2E4'. For this problem, you can falsely "compress" strings of single or double letters. For instance, it is okay for 'AAB' to return 'A2B1' even though this technically takes more space.

The function should also be case sensitive, so that a string 'AAAaaa' returns 'A3a3'.

@slzdevsnp
slzdevsnp / al_arrays_ap_sentence_reversal_problem.md
Created December 11, 2019 16:25
[al_arrays_ap_sentence_reversal] #algo #arrays #aproblem #sentencereversal

Problem

Given a string of words, reverse all the words.

Example:

Given:

'This is the best' Return: 'best the is This'

@slzdevsnp
slzdevsnp / al_arrays_ap_find_largest_continuous_sum_problem.md
Last active December 11, 2019 16:21
[al_arrays_ap_find_largest_continuous_sum] #algo #arrays #aproblem #findlargestcontinuoussum

Problem

Given an array of integers (positive and negative) find the largest continuous sum.

i.e. find subarray in array whos elements make a largest sum

large_cont_sum([1,2,-1,3,4,10,10,-10,-1]) is 29 large_cont_sum[1,2,-1,3,4,-1]),9

@slzdevsnp
slzdevsnp / ap_arrays_find_missed_element_problem.md
Last active December 11, 2019 16:13
[ap_arrays_find_missed_element] #algo #arrays #aproblem #findmissedelement

Problem

Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first array and deleting a random element. Given these two arrays, find which element is missing in the second array.

Here is an example input, the first array is shuffled and the number 5 is removed to construct the second array.

Input:

finder([1,2,3,4,5,6,7],[3,7,2,1,4,6])

@slzdevsnp
slzdevsnp / ap_array_pair_sum_problem.md
Last active December 11, 2019 16:07
[al_arrays_ap_array_pair_sum] #algo #arrays #aproblem #arraypairsum

Problem

Given an integer array, output all the unique pairs that sum up to a specific value k.

So the input:

pair_sum([1,3,2,2],4) would return 2 pairs:

(1,3)

@slzdevsnp
slzdevsnp / ap_anagram_problem.md
Last active December 11, 2019 15:59
[al_arrays_ap_anagram] #algo #arrays #aproblem #anagram

Problem

Given two strings, check to see if they are anagrams. An anagram is when the two strings can be written using the exact same letters (so you can just rearrange the letters to get a different phrase or word).

Example:

"public relations" is an anagram of "crap built on lies."

"clint eastwood" is an anagram of "old west action" Note: Ignore spaces and capitalization. So "d go" is an anagram of "God" and "dog" and "o d g".

@slzdevsnp
slzdevsnp / automate_bare_ubuntu_droplet.md
Last active December 6, 2019 19:21
[digital_ocean] #cloud #vm #digitalocean

automating droplet creation of vm in digital ocean

plan

  • prepare scripts setup.sh and install.sh
  • create a droplet on Digital Ocean site
  • run scripted packages installation

scripts

Create scripts install.sh and setup.sh in folder e.g. /../cor/infra/digitalocean/bare-ubuntu-droplet