Compress large Integers into smallest possible string

后端 未结 6 1601
夕颜
夕颜 2020-12-08 21:04

I have a bunch of 10 digit integers that I\'m passing in a URL. Something like: \"4294965286\", \"2292964213\". They will always be positive and always be 10 digits.

6条回答
  •  眼角桃花
    2020-12-08 21:25

    In addition to changing the base of the encoding (pst and I had the same thought around the same time), since all your numbers are 10 decimal digits, you can subtract the smallest 10 digit number (10E9) from each number before you encode it, and then add that back in after decoding. This will shift your encoded numbers into the range of 0 - 8999999999, thus allowing for smaller strings after the base change.

提交回复
热议问题