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" | |
) | |
func rotationalCipher(input string, rotationFactor int) string { | |
b := []uint8(input) | |
for i:=0; i < len(input); i++ { |
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 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 |
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 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 |
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 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. |
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 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. |
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 Part_4 | |
import ( | |
"fmt" | |
"math/rand" | |
"testing" | |
"time" | |
) | |
/* |
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 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. |
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 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. |
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
/* | |
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 | |
*/ | |
/* | |
Создайте алгоритм и напишите код поиска первого общего предка двух узлов бинарного дерева. Постарайтесь избежать | |
хранения дополнительных узлов в структуре данных. |
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 Google | |
import "testing" | |
// Find max number of connected colors in grid | |
// https://proglib.io/p/google-interview-task/?fbclid=IwAR2PXn_XqXQx97U3FLSFssVfDa1-m2P-T3yAJELEJoOWpNfcQjfyesOegpY | |
type si struct { | |
r int | |
c int |
NewerOlder