This file contains hidden or 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
| upstream gitlab { | |
| server 172.17.42.1:10080 fail_timeout=0; | |
| } | |
| # let gitlab deal with the redirection | |
| server { | |
| listen 80; | |
| server_name git.example.com; | |
| server_tokens off; | |
| root /dev/null; |
This file contains hidden or 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
| func findComplement(num int) int { | |
| u := uint32(num) | |
| mask := uint32(0xffffffff) | |
| for u & mask != 0 { | |
| mask <<= 1 | |
| } | |
| return int(^(u | mask)) | |
| } |
This file contains hidden or 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
| func findWords(words []string) []string { | |
| var row1 string = "qwertyuiop" | |
| var row2 string = "asdfghjkl" | |
| var row3 string = "zxcvbnm" | |
| var result []string | |
| var startrow1, startrow2, startrow3 int | |
| for _, res := range words { | |
| reslow := strings.ToLower(res) | |
| for _, y := range reslow { | |
| if strings.Contains(row1, string(y)) == true { |
This file contains hidden or 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
| func distributeCandies(candies []int) int { | |
| uniqCount := 0 | |
| uniq := make(map[int]bool, 0) | |
| for _,v := range(candies) { | |
| if (uniq[v] == false) { | |
| uniq[v]=true | |
| uniqCount++ | |
| } | |
| if (uniqCount >= len(candies)/2) { | |
| break |
This file contains hidden or 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
| func nextGreaterElement(findNums []int, nums []int) []int { | |
| table := map[int]int{} | |
| stack := []int{} | |
| for _, n := range nums { | |
| size := len(stack) | |
| for size != 0 && stack[size-1] < n { | |
| table[stack[size-1]] = n | |
| stack = stack[:size-1] | |
| size-- |
This file contains hidden or 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
| func singleNumber(nums []int) int { | |
| result := 0 | |
| for _, x := range nums { | |
| result ^= x | |
| } | |
| return result | |
| } |
This file contains hidden or 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
| //write by myself | |
| func singleNumber(nums []int) int { | |
| temp :=map[int]int{} | |
| var single int | |
| for _ , n := range nums { | |
| if _, ok := temp[n] ; ok { | |
| temp[n] = temp[n]+1 | |
| } else { | |
| temp[n] =0 | |
| } |
This file contains hidden or 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
| func findMaxConsecutiveOnes(nums []int) int { | |
| count :=0 | |
| Max :=0 | |
| for _, i := range nums { | |
| if i== 1 { | |
| count+=1 | |
| if count >Max { | |
| Max = count | |
| } | |
| } else { |
This file contains hidden or 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
| func getSum(a int, b int) int { | |
| for b != 0 { | |
| c := a & b | |
| a ^=b | |
| b = c<<1 | |
| } | |
| return a | |
| } |
This file contains hidden or 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
| func findTheDifference(s string, t string) byte { | |
| var ans int32 | |
| ans = 0 | |
| for _, cs := range s { | |
| ans ^= cs | |
| } | |
| for _, ct := range t { | |
| ans ^= ct | |
| } | |
| return byte(ans) |
OlderNewer