[GO] Two Solutions Faster than 90%| | SPEED: 23 ms || MEMORY: 6.5 mb |
Hey,mate! This is my quick solution\n# \nFIRST \n\n\tfunc countGoodRectangles(rectangles [][]int) int {\n\t\tarray := make(map[int]int,0)\n\t\tfor ,rectangle :=
# Hey,mate! This is my quick solution\n# \nFIRST \n\n\tfunc countGoodRectangles(rectangles [][]int) int {\n\t\tarray := make(map[int]int,0)\n\t\tfor _,rectangle := range rectangles {\n\t\t\tk := rectangle[0]\n\t\t\tif k > rectangle[1]{\n\t\t\t   k = rectangle[1]\n\t\t\t}\n\t\t\tarray[k]++\n\t\t}\n\t\tmax :=0 \n\t\tfor key, _ := range array {\n\t\t\tif max < key {\n\t\t\t\tmax = key\n\t\t\t}\n\t\t}\n\t\treturn array[max]\n\t}\n\t\nSECOND \n\n\t\tfunc countGoodRectangles(rectangles [][]int) int {\n\t\t\tsum,maxLen := 0,0\n\t\t\tfor _,rectangle := range rectangles {\n\t\t\t\tk := rectangle[0]\n\t\t\t\tif k > rectangle[1]{\n\t\t\t\t   k = rectangle[1]\n\t\t\t\t}\n\t\t\t\tif maxLen < k {\n\t\t\t\t\tsum = 1 \n\t\t\t\t\tmaxLen = k\n\t\t\t\t} else if maxLen == k{\n\t\t\t\t\tsum++\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn sum\n\t\t}\n\t\n# if you like it ,please, push arrow to lift up solution to the top ,thanks!
['Go']