LintCode: Char to Integer

Char to Integer



Similar Problems:


Description

Convert a char to an integer. You can assume the char is in ASCII code (See Definition, so the value of the char should be in 0~255.

Example
Given a, return 97.

Given %, return 37.

Github: code.dennyzhang.com]]

Credits To: lintcode.com

Leave me comments, if you have better ways to solve.


  • Solution:
// Blog link: https://code.dennyzhang.com/char-to-integer
// Basic Ideas:
// Complexity: Time O(1), Space O(1)
/**
 * @param character: a character
 * @return: An integer
 */
func charToInteger (character byte) int {
    return int(character)
}
linkedin
github
slack

Original URL: https://code.dennyzhang.com/char-to-integer

Connect with Denny In LinkedIn Or Slack

Share It, If You Like It.

Leave a Reply

Your email address will not be published.