-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmain.go
77 lines (66 loc) · 2.88 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"ProgrammingInGo/KidsWithGreatestCandies"
"ProgrammingInGo/MergeAlternately"
"ProgrammingInGo/MinMovesToSeatEveryone"
"ProgrammingInGo/ReverseWords"
"ProgrammingInGo/canplaceflowers"
"ProgrammingInGo/dataengineering/removeduplicates"
"ProgrammingInGo/dataengineering/secondlargestelement"
"ProgrammingInGo/gcd"
"ProgrammingInGo/increasingtriplets"
"ProgrammingInGo/productofelements"
"fmt"
)
func main() {
// test the function
// Use Exported Types to have visibility into functions from different package
fmt.Println(MinMovesToSeatEveryone.MinMovesToSeat([]int{3, 1, 5}, []int{2, 7, 4}))
fmt.Println(MinMovesToSeatEveryone.MinMovesToSeat([]int{4, 1, 5, 9}, []int{1, 3, 2, 6}))
fmt.Println(MinMovesToSeatEveryone.MinMovesToSeat([]int{2, 2, 6, 6}, []int{1, 3, 2, 6}))
// test the function
fmt.Printf("\n")
fmt.Println(MergeAlternately.MergeAlternate("abc", "pqr"))
fmt.Println(MergeAlternately.MergeAlternate("ab", "pqrs"))
fmt.Println(MergeAlternately.MergeAlternate("abcd", "pq"))
// test the function
fmt.Printf("\n")
fmt.Println(gcd.GCDofStrings("ABCABC", "ABC"))
fmt.Println(gcd.GCDofStrings("ABABAB", "ABAB"))
fmt.Println(gcd.GCDofStrings("LEET", "CODE"))
// test the function
fmt.Printf("\n")
fmt.Println(KidsWithGreatestCandies.KidsWithCandies([]int{2, 3, 5, 1, 3}, 3))
fmt.Println(KidsWithGreatestCandies.KidsWithCandies([]int{4, 2, 1, 1, 2}, 1))
// test the function
fmt.Printf("\n")
fmt.Println(ReverseWords.ReverseTokens("the sky is blue"))
fmt.Println(ReverseWords.ReverseTokens(" hello world "))
fmt.Println(ReverseWords.ReverseTokens("a good example"))
// test the function
fmt.Printf("\n")
fmt.Println(productofelements.ProductExceptSelf([]int{1, 2, 3, 4}))
fmt.Println(productofelements.ProductExceptSelf([]int{-1, 1, 0, -3, 3}))
fmt.Println(productofelements.ProductExceptSelf_Optimized([]int{1, 2, 3, 4}))
fmt.Println(productofelements.ProductExceptSelf_Optimized([]int{-1, 1, 0, -3, 3}))
// test the function
fmt.Printf("\n")
fmt.Println(secondlargestelement.FindSecondLargestElement([]int{3, 2, 1, 5, 6, 4}))
fmt.Println(secondlargestelement.FindSecondLargestElement([]int{5, 7, 8, 8, 6, 4, 7}))
// test the function
fmt.Printf("\n")
arr := []int{1, 1, 2, 3, 3, 4}
var k int = removeduplicates.RemoveDuplicates(arr)
fmt.Printf("The array now is: %v\n", arr)
fmt.Printf("The number of unique elements is: %d\n", k)
fmt.Printf("Array of unique elements is: %v\n", arr[:k])
// test the function
fmt.Printf("\n")
fmt.Println(canplaceflowers.CanPlaceFlowers([]int{1, 0, 0, 0, 1}, 1))
fmt.Println(canplaceflowers.CanPlaceFlowers([]int{1, 0, 0, 0, 1}, 2))
// test the function
fmt.Printf("\n")
fmt.Println(increasingtriplets.IncreasingTripletOptimal([]int{1, 2, 3, 4, 5}))
fmt.Println(increasingtriplets.IncreasingTripletOptimal([]int{5, 4, 3, 2, 1}))
fmt.Println(increasingtriplets.IncreasingTripletOptimal([]int{2, 1, 5, 0, 4, 6}))
}