Skip to content

Commit 73c3c16

Browse files
committed
Encode
1 parent 2701eb6 commit 73c3c16

8 files changed

Lines changed: 915 additions & 32 deletions

File tree

secretary/bloomfilter.md

Lines changed: 751 additions & 0 deletions
Large diffs are not rendered by default.

secretary/intersect.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
Yes! You can use a merge-sort-like divide-and-conquer approach to efficiently find the intersection of n arrays.
2+
3+
Approach: Divide & Conquer (Log₂(n) Steps)
4+
5+
✅ Uses recursion, reducing the number of comparisons
6+
✅ More efficient for large n
7+
✅ Works for both sorted and unsorted arrays
8+
9+
Implementation in Go
10+
11+
package main
12+
13+
import (
14+
"fmt"
15+
"sort"
16+
)
17+
18+
// Recursive function to compute intersection of multiple arrays
19+
func IntersectArrays(arrays [][]int) []int {
20+
n := len(arrays)
21+
if n == 0 {
22+
return []int{}
23+
}
24+
if n == 1 {
25+
return arrays[0]
26+
}
27+
// Divide into two halves and recursively intersect them
28+
mid := n / 2
29+
left := IntersectArrays(arrays[:mid])
30+
right := IntersectArrays(arrays[mid:])
31+
32+
return IntersectTwoSortedArrays(left, right)
33+
}
34+
35+
// Helper function to find the intersection of two sorted arrays using two-pointer approach
36+
func IntersectTwoSortedArrays(a, b []int) []int {
37+
i, j := 0, 0
38+
result := []int{}
39+
40+
for i < len(a) && j < len(b) {
41+
if a[i] < b[j] {
42+
i++
43+
} else if a[i] > b[j] {
44+
j++
45+
} else { // Match found
46+
result = append(result, a[i])
47+
i++
48+
j++
49+
}
50+
}
51+
return result
52+
}
53+
54+
// Main function to handle both sorted & unsorted input
55+
func IntersectArraysWithSort(arrays [][]int) []int {
56+
// Sort each array first (if not already sorted)
57+
for i := range arrays {
58+
sort.Ints(arrays[i])
59+
}
60+
return IntersectArrays(arrays)
61+
}
62+
63+
func main() {
64+
arrays := [][]int{
65+
{7, 3, 4, 1, 2},
66+
{4, 3, 8, 2, 5},
67+
{9, 3, 4, 6, 2},
68+
{2, 3, 4, 10, 11},
69+
}
70+
71+
result := IntersectArraysWithSort(arrays)
72+
fmt.Println("Intersection:", result) // Output: [2 3 4]
73+
}
74+
75+
How It Works
76+
1. Divide: Split n arrays into two halves recursively.
77+
2. Sort Each Array: Ensures we can use a fast two-pointer method.
78+
3. Merge: Intersect the two halves using the two-pointer technique.
79+
4. Repeat Until 1 Array Left.
80+
81+
Time Complexity Analysis
82+
• Sorting each array: O(K log K) for N arrays → O(N K log K)
83+
• Merge (intersection of two sorted arrays): O(K)
84+
• Logarithmic recursion depth: O(log N)
85+
• Overall Complexity: O(N K log K) + O(K log N)
86+
87+
🚀 Faster than naive O(NK) when N is large!
88+
89+
Example Run
90+
91+
Input:
92+
93+
arrays := [][]int{
94+
{7, 3, 4, 1, 2},
95+
{4, 3, 8, 2, 5},
96+
{9, 3, 4, 6, 2},
97+
{2, 3, 4, 10, 11},
98+
}
99+
100+
Sorted Arrays:
101+
102+
[1, 2, 3, 4, 7]
103+
[2, 3, 4, 5, 8]
104+
[2, 3, 4, 6, 9]
105+
[2, 3, 4, 10, 11]
106+
107+
Merging Step-by-Step
108+
109+
Step 1: [2, 3, 4] (intersection of first two)
110+
Step 2: [2, 3, 4] (intersection of next two)
111+
Step 3: [2, 3, 4] (final merge)
112+
113+
Final Output
114+
115+
Intersection: [2, 3, 4]
116+
117+
Why Use This Approach?
118+
119+
Method Time Complexity Best Use Case
120+
Hash Map O(NK) Small N, unsorted
121+
Two-Pointer O(NK) Small N, sorted
122+
Divide & Conquer O(N K log K) Large N & large K
123+
124+
🚀 Ideal for n large (hundreds of arrays)!
125+
Let me know if you need tweaks! 🔥

secretary/search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* [The Art of Searching](https://www.youtube.com/watch?v=yst6VQ7Lwpo)
2+
* [Algorithms & data-structures that power Lucene & ElasticSearch](https://www.youtube.com/watch?v=eQ-rXP-D80U)
3+
4+
* [How do Spell Checkers work? Levenshtein Edit Distance](https://www.youtube.com/watch?v=Cu7Tl7FGigQ)
5+
* [The Algorithm Behind Spell Checkers](https://www.youtube.com/watch?v=d-Eq6x1yssU)

secretary/utils/encode/freq_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
)
2929

3030
const (
31-
freq FreqType = S32
31+
freq FreqType = S16
3232
SERVER = false
3333
)
3434

@@ -113,7 +113,7 @@ func sortedMap() map[string]int {
113113

114114
// Convert map to slice for sorting
115115
type kv struct {
116-
Char string
116+
Group string
117117
Count int
118118
}
119119
var sortedFreq []kv
@@ -126,13 +126,13 @@ func sortedMap() map[string]int {
126126

127127
for groupkey, groupcount := range groupfreq {
128128

129-
mmm := utils.Map(SECKEYMAP[groupkey].keys, func(a byte) string {
129+
keyfreq := utils.Map(SECKEYMAP[groupkey].keys, func(a byte) string {
130130
return fmt.Sprintf("%q,%d,%d", a, 100*charfreq[a]/groupcount, 100*charfreq[a]/totalChar)
131131
})
132132

133133
sortedFreq = append(sortedFreq,
134134
kv{
135-
Char: fmt.Sprintf("%8d %4d %8v", groupcount, groupkey, mmm),
135+
Group: fmt.Sprintf("%8d %4q %8v", groupcount, SECKEYMAP[groupkey].sec, keyfreq),
136136
Count: groupcount,
137137
})
138138
}
@@ -147,11 +147,11 @@ func sortedMap() map[string]int {
147147

148148
charCount := 0
149149
for i, kv := range sortedFreq {
150-
sortedMap[kv.Char] = kv.Count
150+
sortedMap[kv.Group] = kv.Count
151151

152152
charCount += kv.Count
153153

154-
fmt.Printf("%4d %4d %4d %10v \n", i, 100*charCount/totalChar, 100*kv.Count/totalChar, kv.Char)
154+
fmt.Printf("%4d %4d %4d %10v \n", i, 100*charCount/totalChar, 100*kv.Count/totalChar, kv.Group)
155155
}
156156
return sortedMap
157157
}

secretary/utils/encode/sec16.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
var SEC16KeyMap = [16]SECKEY{
1010
/*00*/ {'-', []byte{'-'}},
1111
/*01*/ {'a', []byte{'a', 'A', 'h', 'H'}},
12-
/*02*/ {'b', []byte{'b', 'B', 'p', 'P'}},
12+
/*02*/ {'p', []byte{'p', 'P', 'b', 'B'}},
1313
/*03*/ {'c', []byte{'c', 'C', 'k', 'K', 'q', 'Q'}},
14-
/*04*/ {'d', []byte{'d', 'D', 't', 'T'}},
14+
/*04*/ {'t', []byte{'t', 'T', 'd', 'D'}},
1515
/*05*/ {'e', []byte{'e', 'E', 'i', 'I'}},
1616
/*06*/ {'f', []byte{'f', 'F'}},
1717
/*07*/ {'g', []byte{'g', 'G', 'j', 'J', 'z', 'Z'}},
@@ -20,17 +20,17 @@ var SEC16KeyMap = [16]SECKEY{
2020
/*10*/ {'o', []byte{'o', 'O', 'u', 'U'}},
2121
/*11*/ {'r', []byte{'r', 'R'}},
2222
/*12*/ {'s', []byte{'s', 'S', 'x', 'X'}},
23-
/*13*/ {'v', []byte{'v', 'V', 'y', 'Y', 'w', 'W'}},
23+
/*13*/ {'y', []byte{'y', 'Y', 'v', 'V', 'w', 'W'}},
2424
/*14*/ {'0', []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}},
2525
/*15*/ {'_', []byte{'_', '.', ',', ';', ' ', '\n', '"', '\'', '`', ':'}},
2626
}
2727

2828
var (
29-
ASCII16 = [16]byte{45, 97, 98, 99, 100, 101, 102, 103, 108, 110, 111, 114, 115, 118, 48, 95}
30-
SEC16 = [16]byte{45, 97, 98, 99, 100, 101, 102, 103, 108, 110, 111, 114, 115, 118, 48, 95}
29+
ASCII16 = [16]byte{45, 97, 112, 99, 116, 101, 102, 103, 108, 110, 111, 114, 115, 121, 48, 95}
30+
SEC16 = [16]byte{45, 97, 112, 99, 116, 101, 102, 103, 108, 110, 111, 114, 115, 121, 48, 95}
3131

3232
ASCII16Index = [256]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
3434
)
3535

3636
// func init() {
@@ -39,15 +39,15 @@ var (
3939
// SEC16Index[i] = 0
4040
// }
4141
// for index, chars := range SEC16KeyMap {
42-
// ASCII16[index] = chars.asc[0]
42+
// ASCII16[index] = chars.keys[0]
4343
// SEC16[index] = chars.sec
4444
// SEC16Index[SEC16[index]] = byte(index)
45-
// for _, c := range chars.asc {
45+
// for _, c := range chars.keys {
4646
// ASCII16Index[c] = byte(index)
4747
// }
4848
// }
4949

50-
// fmt.Println(utils.Map(ASCII16[:], func(a byte) string { return fmt.Sprint(a, ",") }))
50+
// fmt.Println(utils.Map(SEC16Index[:], func(a byte) string { return fmt.Sprint(a, ",") }))
5151
// }
5252

5353
func StringToSec16(str string) string {

secretary/utils/encode/sec16_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestEncodingDecoding16(t *testing.T) {
1919
{"| +\n_", "-_-__", "-_-__"},
2020
{
2121
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
22-
"abcdefgaegclnnobcrsdovvsvg",
23-
"abcdefgaegclnnobcrsdovvsvg",
22+
"apctefgaegclnnopcrstoyysyg",
23+
"apctefgaegclnnopcrstoyysyg",
2424
},
2525
{
2626
"0123456789",
@@ -34,8 +34,8 @@ func TestEncodingDecoding16(t *testing.T) {
3434
},
3535
{
3636
"abcdefghijklmnopqrstuvwxyz",
37-
"abcdefgaegclnnobcrsdovvsvg",
38-
"abcdefgaegclnnobcrsdovvsvg",
37+
"apctefgaegclnnopcrstoyysyg",
38+
"apctefgaegclnnopcrstoyysyg",
3939
},
4040
{
4141
"~`|",

secretary/utils/encode/sec32.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type SECKEY struct {
1414
var SEC32KeyMap = [32]SECKEY{
1515
/*00*/ {'-', []byte{'~'}},
1616
/*01*/ {'a', []byte{'a', 'A', '@'}},
17-
/*02*/ {'b', []byte{'b', 'B', 'p', 'P', '+'}},
17+
/*02*/ {'p', []byte{'p', 'P', 'b', 'B', '+'}},
1818
/*03*/ {'c', []byte{'c', 'C', 'k', 'K', 'q', 'Q'}},
1919
/*04*/ {'d', []byte{'d', 'D', '/'}},
2020
/*05*/ {'e', []byte{'e', 'E', '='}},
@@ -47,11 +47,11 @@ var SEC32KeyMap = [32]SECKEY{
4747
}
4848

4949
var (
50-
ASCII32 = [32]byte{126, 97, 98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 114, 115, 116, 118, 121, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 40, 41, 95}
51-
SEC32 = [32]byte{45, 97, 98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 114, 115, 116, 118, 121, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 81, 82, 95}
50+
ASCII32 = [32]byte{126, 97, 112, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 114, 115, 116, 118, 121, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 40, 41, 95}
51+
SEC32 = [32]byte{45, 97, 112, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 114, 115, 116, 118, 121, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 81, 82, 95}
5252

5353
ASCII32Index = [256]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 9, 31, 8, 6, 18, 18, 31, 29, 30, 11, 2, 31, 12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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
5555
)
5656

5757
// func init() {
@@ -60,13 +60,15 @@ var (
6060
// SEC32Index[i] = 0
6161
// }
6262
// for index, chars := range SEC32KeyMap {
63-
// ASCII32[index] = chars.asc[0]
63+
// ASCII32[index] = chars.keys[0]
6464
// SEC32[index] = chars.sec
6565
// SEC32Index[SEC32[index]] = byte(index)
66-
// for _, c := range chars.asc {
66+
// for _, c := range chars.keys {
6767
// ASCII32Index[c] = byte(index)
6868
// }
6969
// }
70+
71+
// fmt.Println(utils.Map(SEC32[:], func(a byte) string { return fmt.Sprint(a, ",") }))
7072
// }
7173

7274
func StringToSec32(str string) string {

secretary/utils/encode/sec32_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func TestEncodingDecoding32(t *testing.T) {
1616
asc32 string
1717
}{
1818
{"", "", ""},
19-
{"| +\n_", "-_b__", "~_b__"},
19+
{"| +\n_", "-_p__", "~_p__"},
2020
{
2121
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
22-
"abcdefghigclmnobcrstovvsyg",
23-
"abcdefghigclmnobcrstovvsyg",
22+
"apcdefghigclmnopcrstovvsyg",
23+
"apcdefghigclmnopcrstovvsyg",
2424
},
2525
{
2626
"0123456789",
@@ -29,13 +29,13 @@ func TestEncodingDecoding32(t *testing.T) {
2929
},
3030
{
3131
`=+-*/\%^<>!?@#$&(),;:'"_. `,
32-
`ebnmd-ylQRiiahfyQR________`,
33-
`ebnmd~yl()iiahfy()________`,
32+
`epnmd-ylQRiiahfyQR________`,
33+
`epnmd~yl()iiahfy()________`,
3434
},
3535
{
3636
"abcdefghijklmnopqrstuvwxyz",
37-
"abcdefghigclmnobcrstovvsyg",
38-
"abcdefghigclmnobcrstovvsyg",
37+
"apcdefghigclmnopcrstovvsyg",
38+
"apcdefghigclmnopcrstovvsyg",
3939
},
4040
{
4141
"~`|",

0 commit comments

Comments
 (0)