Documentation ¶
Overview ¶
Package p1 LeetCode 0013 Roman to Integer Latin number to integer
Example (RotateRight) ¶
Test rotateRight
list := new(ListNode) head := list list.Val = 1 list.Next = new(ListNode) current := list.Next current.Val = 2 current.Next = new(ListNode) current = current.Next current.Val = 3 current.Next = new(ListNode) current = current.Next current.Val = 4 current.Next = new(ListNode) current = current.Next current.Val = 5 current = head // for current != nil { // fmt.Println(current.Val) // current = current.Next // } // fmt.Printf("%#v\n", head) current = rotateRight(head, 2) // fmt.Printf("%#v\n", current) for current != nil { fmt.Println(current.Val) current = current.Next }
Output: 4 5 1 2 3
Example (TreeTest) ¶
treeTest()
Output: BTree 0 1 2 3 4 [0 1 2 3 4] [0 -10 5 -3 9]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountOdds ¶
CountOdds count odd number in range
Example ¶
fmt.Println(CountOdds(3, 7))
Output: 3
func FizzBuzz ¶
FizzBuzz 3=Fizz 5=Buzz 15=FizzBuzz
Given an integer n, return a string array answer (1-indexed) where: answer[i] == "FizzBuzz" if i is divisible by 3 and 5. answer[i] == "Fizz" if i is divisible by 3. answer[i] == "Buzz" if i is divisible by 5. answer[i] == i (as a string) if none of the above conditions are true.
func IntPow ¶
IntPow calculates n to the mth power. Since the result is an int, it is assumed that m is a positive power
func IsPlaindromeInt ¶
IsPlaindromeInt true if a integer is a palindrome 121==true
Example ¶
inp := 121 fmt.Println(IsPlaindromeInt(inp))
Output: true
func LongestCommonPrefix ¶
LongestCommonPrefix return prefix used in all string
Example ¶
strs := []string{"flower", "flower", "flower", "flower"} fmt.Println(LongestCommonPrefix(strs))
Output: flower
func RomanToInt ¶
RomanToInt convert roman number to int
Example ¶
inp := "MCDLXXVI" fmt.Println(RomanToInt(inp))
Output: 1476
Types ¶
Source Files ¶
- 119pascalTriangleII.go
- 500keyboardRow.go
- ConvertSortedArrayToBinarySearchTree.go
- CountOddNumbersInAnIntervalRange.go
- ExcelSheetColumnNumber.go
- FizzBuzz.go
- LongestCommonPrefix.go
- RemoveDup.go
- findMedianSortedArrays.go
- isStrPalindrom.go
- maxArea.go
- reverse.go
- reverseWord.go
- romanToInt.go
- rotatelist.go
- zeroFilledSubarray.go