String Processing in Python: String to Integer



In this video, we will be solving the following problem:

You are given some numeric string as input. Convert the string you are
given to an integer. Do not make use of the built-in “int” function.
Example:
“123” : 123
“-12332” : -12332
“554” : 554
etc.

This video is part of a series on string processing and, specifically, on how these problems tend to show up in the context of a technical interview:

This video is also part of an “Algorithm” series. For more algorithm tutorials:

The software written in this video is available at:

Do you like the development environment I’m using in this video? It’s a customized version of vim that’s enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:

If you’ve found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:

Nguồn: https://benjaminjcohen.com/

Xem thêm bài viết khác: https://benjaminjcohen.com/cong-nghe/

14 Comments

  1. Finished all your algorithms and data structure videos, just wanna thank you for all the hard work you paid in! These are totally amazing!!!

  2. Another awsome series have been done ^-^ thanx
    for your efforts

  3. Hi, first of all great content. Also, are you planning to expand algorithm topic going foward?

  4. Its unfair: we are still cheating .we do not use int built in function but so easily use 2 built in functions instead:ord and char!
    What do i offer? Break it down to the molecular level and create a dictionary of 10 first digits with corresponding number keys .thus you really break it d down.

  5. crystal clear explanation ,thank you so much

  6. num="123"
    num=list(num)
    def strtoint(num,s):
    if s==len(num):
    return int(num[s-1])
    else:
    num[s]=int(num[s])
    strtoint(num,s+1)
    for m in range(len(num)):
    num[m]=str(num[m])
    return int("".join(num))
    print(strtoint(num,0))
    Can i solve it using recursion(i made use of built-in functions in this code, sr about that)

  7. Thanks for the clear explanation

  8. how to convert 'W1234' into int. number should be extracted.

  9. Sir we want more data structure videos…..like which are useful in programming interview….
    Thanks your videos are amazing….

  10. This process is too complicated. Please input the correct display type.

  11. this work in python 2.7?

  12. I saved it offline to do it practically …
    Explained very nicely

  13. Hi "Lucid Programming " what is your email.? Our is dsrudy.liveedu@gmail.com

  14. Please keep up the content, I am learning so much from these videos!

Leave a Reply

Your email address will not be published. Required fields are marked *