Skip to content

Instantly share code, notes, and snippets.

💭
Building a dream...

Valentyn Ponomarenko P-A-R-U-S

💭
Building a dream...
View GitHub Profile
@P-A-R-U-S
P-A-R-U-S / Rotational_Cipher.go
Last active Jun 18, 2020
Facebook: Rotational Cipher
View Rotational_Cipher.go
package main
import (
"fmt"
)
func rotationalCipher(input string, rotationFactor int) string {
b := []uint8(input)
for i:=0; i < len(input); i++ {
@P-A-R-U-S
P-A-R-U-S / Contiguous_Subarrays.go
Created Jun 18, 2020
Facebook: Contiguous Subarrays
View Contiguous_Subarrays.go
package Facebook
import "testing"
/*
Contiguous Subarrays
You are given an array a of N integers. For each index i, you are required to determine the number of contiguous
subarrays that fulfills the following conditions:
The value at index i must be the maximum element in the contiguous subarrays, and
@P-A-R-U-S
P-A-R-U-S / Passing_Yearbooks.go
Last active Jun 18, 2020
Facebook: Passing Yearbooks
View Passing_Yearbooks.go
package Facebook
import "testing"
/*
Passing Yearbooks
There are n students, numbered from 1 to n, each with their own yearbook.
They would like to pass their yearbooks around and get them signed by other students.
You're given a list of n integers arr[1..n], which is guaranteed to be a permutation of 1..n
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_5-3_test.go
Created Jun 16, 2020
Flip Bit to Win: Flip one bit to get longest sequence of 1s
View Cracking_the_Coding_Interview_5-3_test.go
package Part_5
import (
"testing"
)
/*
Flip Bit to Win: You have an integer and you can flip exactly one bit from a 13 to a 1.Write code to find the length of
the longest sequence of ls you could create.
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_5-1_test.go
Last active Jun 15, 2020
Insertion M into N from bit "i" to "j"
View Cracking_the_Coding_Interview_5-1_test.go
package Part_5
import "testing"
/*
Insertion: You are given two 32-bit numbers, N and M, and two bit positions, i and j.
Write a method to insert M into N such that M starts at bit j and ends at bit i.
You can assume that the bits j through i have enough space to fit all of M.
That is, if M= 10011, you can assume that there are at least 5 bits between j and i.
You would not, for example, have j = 3 and i = 2, because M could not fully fit between bit 3 and bit 2.
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_4-11_test.go
Created Jun 15, 2020
Cracking the Coding Interview - Task - 4.11 - Random Node, Insert Node, Delete Node
View Cracking_the_Coding_Interview_4-11_test.go
package Part_4
import (
"fmt"
"math/rand"
"testing"
"time"
)
/*
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_4-12_test.go
Last active Jun 15, 2020
Cracking the Coding Interview - Task - 4.12 - Find path equal K in binary tree
View Cracking_the_Coding_Interview_4-12_test.go
package Part_4
import (
"testing"
)
/*
Paths with Sum: You are given a binary tree in which each node contains an integer value (which might be positive or negative).
Design an algorithm to count the number of paths that sum to a given value.
@P-A-R-U-S
P-A-R-U-S / Cut_Film_into_Scenes.go
Last active Jun 13, 2020
Cut Film into Scenes
View Cut_Film_into_Scenes.go
package Amazon
import "testing"
/*
You are working on a project for Amazon Video and need to cut films into scenes.
To help streamline the creation of the final films, the team needs to develop an automated way of
breaking up individual shorts (short sequence from a particular camera angle) in a film into
scenes (a sequence of shorts). There is already an algorithm than breaks the film up into shorts
and label then with letter. Identical shorts are labelled with same letter.
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_4-9_test.go
Last active Jun 1, 2020
Cracking the Coding Interview - Task - 4.9
View Cracking_the_Coding_Interview_4-9_test.go
package Part_4
import (
"fmt"
"testing"
)
/*
BST Sequences: A binary search tree was created by traversing through an array from left to right and inserting each element.
Given a binary search tree with distinct elements, print all possible arrays that could have led to this tree.
@P-A-R-U-S
P-A-R-U-S / Cracking_the_Coding_Interview_4-8_test.go
Last active May 31, 2020
Cracking the Coding Interview - Task - 4.8
View Cracking_the_Coding_Interview_4-8_test.go
/*
First Common Ancestor: Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree.
Avoid storing additional nodes in a data structure.
NOTE: This is not necessarily a binary search tree.
Hints: # 10, #16, #28, #36, #46, #70, #80, #96
*/
/*
Создайте алгоритм и напишите код поиска первого общего предка двух узлов бинарного дерева. Постарайтесь избежать
хранения дополнительных узлов в структуре данных.
You can’t perform that action at this time.