3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「世界で闘うプログラミング力を鍛える本」Pythonコード解答例 - 1.1 重複のない文字列

Last updated at Posted at 2020-01-30

「世界で闘うプログラミング力を鍛える本」Pythonコード解答例 - 1.1 重複のない文字列

#目次
###CHAP1. 配列と文字列

  1. 重複のない文字列
  2. 同じ文字の数を数える
  3. URLify
  4. 回文の順列
  5. 一発変換
  6. 文字列圧縮
  7. 行列の回転
  8. "0"の行列
  9. 文字列の回転

#Pythonコード解答例

import numpy as np

def isUniqueChars(str):

    if len(str)>128:
        return False

    char_set = np.zeros((128))

    for id in range(len(str)):

        val = ord(str[id])
        if char_set[val] == 1:
            return False
        char_set[val] = 1

    return True

input_str = "sentence"
print(isUniqueChars(input_str))
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?