leetcode.com/problems/defanging-an-ip-address/

 

Defanging an IP Address - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

javascript

/**
 * @param {string} address
 * @return {string}
 */
const defangIPaddr = (address) => {
  return address.replace(/\./g, '[.]')
  // address.split('.').join('[.]')
};

typescript

const defangIPaddrTS = (address: string): string => {
  return address.replace(/\./g, '[.]')
  // address.split('.').join('[.]')
};

golang

func defangIPaddr(address string) string {
	return strings.Replace(address, ".", "[.]", -1)
}

'코딩 테스트 > LeetCode' 카테고리의 다른 글

Easy) 1512. Number of Good Pairs  (0) 2020.09.15
Easy) 771. Jewels and Stones  (0) 2020.09.15
Easy) Shuffle the Array  (0) 2020.09.13
Easy) Kids With the Greatest Number of Candies  (0) 2020.09.13
Easy. Running Sum of 1d Array  (0) 2020.07.02

+ Recent posts