setKthDigit(n, k, d)

setKthDigit(n, k, d)

Write the function setKthDigit(n, k, d) that takes three integers -- n, k, and d -- where n is a possibly-negative int, k is a non-negative int, and d is a non-negative single digit (between 0 and 9 inclusive). This function returns the number n with the kth digit replaced with d. Counting starts at 0 and goes right-to-left, so the 0th digit is the rightmost digit. For example:

setKthDigit(468, 0, 1) == 461
setKthDigit(468, 1, 1) == 418
setKthDigit(468, 2, 1) == 168
setKthDigit(468, 3, 1) == 1468

信息

ID
1011
难度
(无)
分类
(无)
标签
(无)
递交数
0
已通过
0
通过率
?
上传者