diff --git a/Pipfile b/Pipfile index 9387b55..43cad16 100644 --- a/Pipfile +++ b/Pipfile @@ -6,6 +6,8 @@ name = "pypi" [packages] pytest = "*" pytest-django = "*" +numpy = "*" +qiskit = "*" [dev-packages] flake8 = "*" diff --git a/Pipfile.lock b/Pipfile.lock index a4f3a6d..52266ed 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "dbace3ed0df8317e26ffe46d5537f14a3ff2e578c4575e0866a7c3e66bd5ed39" + "sha256": "15e26300d593471dc466ae717b3205da4084ae1453fa6ea7345aef45378d9574" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,14 @@ ] }, "default": { + "dill": { + "hashes": [ + "sha256:0633f1d2df477324f53a895b02c901fb961bdbf65a17122586ea7019292cbcf0", + "sha256:44f54bf6412c2c8464c14e8243eb163690a9800dbe2c367330883b19c7561049" + ], + "markers": "python_version >= '3.8'", + "version": "==0.4.0" + }, "exceptiongroup": { "hashes": [ "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10", @@ -32,6 +40,68 @@ "markers": "python_version >= '3.8'", "version": "==2.1.0" }, + "numpy": { + "hashes": [ + "sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff", + "sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47", + "sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84", + "sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad62762c3e3d", + "sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6", + "sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f", + "sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b", + "sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49", + "sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163", + "sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571", + "sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42", + "sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff", + "sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491", + "sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4", + "sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566", + "sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf", + "sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a54d475b7e40", + "sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd", + "sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06", + "sha256:71594f7c51a18e728451bb50cc60a3ce4e6538822731b2933209a1f3614e9282", + "sha256:74d4531beb257d2c3f4b261bfb0fc09e0f9ebb8842d82a7b4209415896adc680", + "sha256:7befc596a7dc9da8a337f79802ee8adb30a552a94f792b9c9d18c840055907db", + "sha256:894b3a42502226a1cac872f840030665f33326fc3dac8e57c607905773cdcde3", + "sha256:8e41fd67c52b86603a91c1a505ebaef50b3314de0213461c7a6e99c9a3beff90", + "sha256:8e9ace4a37db23421249ed236fdcdd457d671e25146786dfc96835cd951aa7c1", + "sha256:8fc377d995680230e83241d8a96def29f204b5782f371c532579b4f20607a289", + "sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab", + "sha256:b0544343a702fa80c95ad5d3d608ea3599dd54d4632df855e4c8d24eb6ecfa1c", + "sha256:b093dd74e50a8cba3e873868d9e93a85b78e0daf2e98c6797566ad8044e8363d", + "sha256:b412caa66f72040e6d268491a59f2c43bf03eb6c96dd8f0307829feb7fa2b6fb", + "sha256:b4f13750ce79751586ae2eb824ba7e1e8dba64784086c98cdbbcc6a42112ce0d", + "sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a", + "sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf", + "sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1", + "sha256:c1f9540be57940698ed329904db803cf7a402f3fc200bfe599334c9bd84a40b2", + "sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a", + "sha256:ce47521a4754c8f4593837384bd3424880629f718d87c5d44f8ed763edd63543", + "sha256:d042d24c90c41b54fd506da306759e06e568864df8ec17ccc17e9e884634fd00", + "sha256:de749064336d37e340f640b05f24e9e3dd678c57318c7289d222a8a2f543e90c", + "sha256:e1dda9c7e08dc141e0247a5b8f49cf05984955246a327d4c48bda16821947b2f", + "sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd", + "sha256:e3143e4451880bed956e706a3220b4e5cf6172ef05fcc397f6f36a550b1dd868", + "sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303", + "sha256:efd28d4e9cd7d7a8d39074a4d44c63eda73401580c5c76acda2ce969e0a38e83", + "sha256:f0fd6321b839904e15c46e0d257fdd101dd7f530fe03fd6359c1ea63738703f3", + "sha256:f1372f041402e37e5e633e586f62aa53de2eac8d98cbfb822806ce4bbefcb74d", + "sha256:f2618db89be1b4e05f7a1a847a9c1c0abd63e63a1607d892dd54668dd92faf87", + "sha256:f447e6acb680fd307f40d3da4852208af94afdfab89cf850986c3ca00562f4fa", + "sha256:f92729c95468a2f4f15e9bb94c432a9229d0d50de67304399627a943201baa2f", + "sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae", + "sha256:fc0c5673685c508a142ca65209b4e79ed6740a4ed6b2267dbba90f34b0b3cfda", + "sha256:fc7b73d02efb0e18c000e9ad8b83480dfcd5dfd11065997ed4c6747470ae8915", + "sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249", + "sha256:fe27749d33bb772c80dcd84ae7e8df2adc920ae8297400dabec45f0dedb3f6de", + "sha256:fee4236c876c4e8369388054d02d0e9bb84821feb1a64dd59e137e6511a551f8" + ], + "index": "pypi", + "markers": "python_version >= '3.10'", + "version": "==2.2.6" + }, "packaging": { "hashes": [ "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", @@ -74,6 +144,98 @@ "markers": "python_version >= '3.8'", "version": "==4.11.1" }, + "qiskit": { + "hashes": [ + "sha256:10467a0a76f073b16c31aa8d69c3292f672fd6d215904e717c850e3cd0c90973", + "sha256:110b96340accf243023efe32b72e78d9a8781cf43190e60adabbd8f208b424cc", + "sha256:72ccf39aed112bfc8a7924b26cb9e5202541421b32e0ad16b020eb8618a868f0", + "sha256:8c1b3dd2ecea5f2c7878e9ab1b3337f79f2ef0b50e580f6d374cc6ac783e03ba", + "sha256:c751ffaeec861086280c3a2f69527429bdeb851c6bf5fc620d8a9ebd4f168adc", + "sha256:ce66d6a3db73f4d1dd546fa13062c2e7fd8120720247426d6c637f6dcf73fa87", + "sha256:fc8ff9cba25e59f8f6663a603558af2d45aa2793f4e93766c84bc1a21d9e8a69", + "sha256:fd3fe5b212053e18aea66b3903face62e25d7ba0aebd0aa68ea1fb4f14b220e3" + ], + "index": "pypi", + "markers": "python_version >= '3.9'", + "version": "==2.1.2" + }, + "rustworkx": { + "hashes": [ + "sha256:246cc252053f89e36209535b9c58755960197e6ae08d48d3973760141c62ac95", + "sha256:42170075d8a7319e89ff63062c2f1d1116ced37b6f044f3bf36d10b60a107aa4", + "sha256:48784a673cf8d04f3cd246fa6b53fd1ccc4d83304503463bd561c153517bccc1", + "sha256:4ef8e327dadf6500edd76fedb83f6d888b9266c58bcdbffd5a40c33835c9dd26", + "sha256:5b809e0aa2927c68574b196f993233e269980918101b0dd235289c4f3ddb2115", + "sha256:5dbc567833ff0a8ad4580a4fe4bde92c186d36b4c45fca755fb1792e4fafe9b5", + "sha256:65cba97fa95470239e2d65eb4db1613f78e4396af9f790ff771b0e5476bfd887", + "sha256:c08fb8db041db052da404839b064ebfb47dcce04ba9a3e2eb79d0c65ab011da4", + "sha256:c10d25e9f0e87d6a273d1ea390b636b4fb3fede2094bf0cb3fe565d696a91b48", + "sha256:c7e82c46a92fb0fd478b7372e15ca524c287485fdecaed37b8bb68f4df2720f2", + "sha256:d0a48fb62adabd549f9f02927c3a159b51bf654c7388a12fc16d45452d5703ea" + ], + "markers": "python_version >= '3.9'", + "version": "==0.17.1" + }, + "scipy": { + "hashes": [ + "sha256:05dc6abcd105e1a29f95eada46d4a3f251743cfd7d3ae8ddb4088047f24ea477", + "sha256:06efcba926324df1696931a57a176c80848ccd67ce6ad020c810736bfd58eb1c", + "sha256:0a769105537aa07a69468a0eefcd121be52006db61cdd8cac8a0e68980bbb723", + "sha256:0bdd905264c0c9cfa74a4772cdb2070171790381a5c4d312c973382fc6eaf730", + "sha256:0ff17c0bb1cb32952c09217d8d1eed9b53d1463e5f1dd6052c7857f83127d539", + "sha256:14ed70039d182f411ffc74789a16df3835e05dc469b898233a245cdfd7f162cb", + "sha256:185cd3d6d05ca4b44a8f1595af87f9c372bb6acf9c808e99aa3e9aa03bd98cf6", + "sha256:18aaacb735ab38b38db42cb01f6b92a2d0d4b6aabefeb07f02849e47f8fb3594", + "sha256:1c832e1bd78dea67d5c16f786681b28dd695a8cb1fb90af2e27580d3d0967e92", + "sha256:263961f658ce2165bbd7b99fa5135195c3a12d9bef045345016b8b50c315cb82", + "sha256:271e3713e645149ea5ea3e97b57fdab61ce61333f97cfae392c28ba786f9bb49", + "sha256:2c620736bcc334782e24d173c0fdbb7590a0a436d2fdf39310a8902505008759", + "sha256:34716e281f181a02341ddeaad584205bd2fd3c242063bd3423d61ac259ca7eba", + "sha256:39cb9c62e471b1bb3750066ecc3a3f3052b37751c7c3dfd0fd7e48900ed52982", + "sha256:3ac07623267feb3ae308487c260ac684b32ea35fd81e12845039952f558047b8", + "sha256:3b0334816afb8b91dab859281b1b9786934392aa3d527cd847e41bb6f45bee65", + "sha256:40e54d5c7e7ebf1aa596c374c49fa3135f04648a0caabcb66c52884b943f02b4", + "sha256:50f9e62461c95d933d5c5ef4a1f2ebf9a2b4e83b0db374cb3f1de104d935922e", + "sha256:52092bc0472cfd17df49ff17e70624345efece4e1a12b23783a1ac59a1b728ed", + "sha256:5380741e53df2c566f4d234b100a484b420af85deb39ea35a1cc1be84ff53a5c", + "sha256:5e721fed53187e71d0ccf382b6bf977644c533e506c4d33c3fb24de89f5c3ed5", + "sha256:6487aa99c2a3d509a5227d9a5e889ff05830a06b2ce08ec30df6d79db5fcd5c5", + "sha256:6ac6310fdbfb7aa6612408bd2f07295bcbd3fda00d2d702178434751fe48e019", + "sha256:6cfd56fc1a8e53f6e89ba3a7a7251f7396412d655bca2aa5611c8ec9a6784a1e", + "sha256:6db907c7368e3092e24919b5e31c76998b0ce1684d51a90943cb0ed1b4ffd6c1", + "sha256:721d6b4ef5dc82ca8968c25b111e307083d7ca9091bc38163fb89243e85e3889", + "sha256:76ad1fb5f8752eabf0fa02e4cc0336b4e8f021e2d5f061ed37d6d264db35e3ca", + "sha256:79167bba085c31f38603e11a267d862957cbb3ce018d8b38f79ac043bc92d825", + "sha256:795c46999bae845966368a3c013e0e00947932d68e235702b5c3f6ea799aa8c9", + "sha256:7e11270a000969409d37ed399585ee530b9ef6aa99d50c019de4cb01e8e54e62", + "sha256:8c9ed3ba2c8a2ce098163a9bdb26f891746d02136995df25227a20e71c396ebb", + "sha256:993439ce220d25e3696d1b23b233dd010169b62f6456488567e830654ee37a6b", + "sha256:9d61e97b186a57350f6d6fd72640f9e99d5a4a2b8fbf4b9ee9a841eab327dc13", + "sha256:9db984639887e3dffb3928d118145ffe40eff2fa40cb241a306ec57c219ebbbb", + "sha256:9e2abc762b0811e09a0d3258abee2d98e0c703eee49464ce0069590846f31d40", + "sha256:a345928c86d535060c9c2b25e71e87c39ab2f22fc96e9636bd74d1dbf9de448c", + "sha256:ad3432cb0f9ed87477a8d97f03b763fd1d57709f1bbde3c9369b1dff5503b253", + "sha256:ae48a786a28412d744c62fd7816a4118ef97e5be0bee968ce8f0a2fba7acf3bb", + "sha256:aef683a9ae6eb00728a542b796f52a5477b78252edede72b8327a886ab63293f", + "sha256:b90ab29d0c37ec9bf55424c064312930ca5f4bde15ee8619ee44e69319aab163", + "sha256:c05045d8b9bfd807ee1b9f38761993297b10b245f012b11b13b91ba8945f7e45", + "sha256:c9deabd6d547aee2c9a81dee6cc96c6d7e9a9b1953f74850c179f91fdc729cb7", + "sha256:dde4fc32993071ac0c7dd2d82569e544f0bdaff66269cb475e0f369adad13f11", + "sha256:eae3cf522bc7df64b42cad3925c876e1b0b6c35c1337c93e12c0f366f55b0eaf", + "sha256:ed7284b21a7a0c8f1b6e5977ac05396c0d008b89e05498c8b7e8f4a1423bba0e", + "sha256:f77f853d584e72e874d87357ad70f44b437331507d1c311457bed8ed2b956126" + ], + "markers": "python_version >= '3.10'", + "version": "==1.15.3" + }, + "stevedore": { + "hashes": [ + "sha256:18363d4d268181e8e8452e71a38cd77630f345b2ef6b4a8d5614dac5ee0d18cf", + "sha256:d31496a4f4df9825e1a1e4f1f74d19abb0154aff311c3b376fcc89dae8fccd73" + ], + "markers": "python_version >= '3.9'", + "version": "==5.5.0" + }, "tomli": { "hashes": [ "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6", @@ -114,11 +276,11 @@ }, "typing-extensions": { "hashes": [ - "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36", - "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76" + "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", + "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548" ], "markers": "python_version >= '3.9'", - "version": "==4.14.1" + "version": "==4.15.0" } }, "develop": { diff --git a/algorithms_project/algorithms/arrays/first_uni_char.py b/algorithms_project/algorithms/arrays/first_uni_char.py deleted file mode 100644 index 08b9f05..0000000 --- a/algorithms_project/algorithms/arrays/first_uni_char.py +++ /dev/null @@ -1,21 +0,0 @@ -class Solution: - def firstUniqChar(self, s: str) -> int: - d = {} - for idx, ch in enumerate(s): - if not d.get(ch): - d[ch] = [idx, 1] - else: - d[ch][1] += 1 - - for ch, val in d.items(): - if val[1] == 1: - return val[0] - return -1 - - -solution = Solution() -print(solution.firstUniqChar("leetcode")) - - -solution = Solution() -print(solution.firstUniqChar("loveleetcode")) diff --git a/algorithms_project/algorithms/arrays/binary_search.py b/algorithms_project/algorithms/binary_search/binary_search.py similarity index 100% rename from algorithms_project/algorithms/arrays/binary_search.py rename to algorithms_project/algorithms/binary_search/binary_search.py diff --git a/algorithms_project/algorithms/arrays/exponential_search.py b/algorithms_project/algorithms/binary_search/exponential_search.py similarity index 99% rename from algorithms_project/algorithms/arrays/exponential_search.py rename to algorithms_project/algorithms/binary_search/exponential_search.py index e85d39e..1d8372f 100644 --- a/algorithms_project/algorithms/arrays/exponential_search.py +++ b/algorithms_project/algorithms/binary_search/exponential_search.py @@ -10,6 +10,7 @@ muito grande caso o índice acessado esteja fora do limite. """ + # Simula o ArrayReader do LeetCode class ArrayReader: def __init__(self, arr): @@ -105,3 +106,4 @@ def search(self, reader: ArrayReader, target: int) -> int: # Target não encontrado return -1 + diff --git a/algorithms_project/algorithms/hashing/first_uni_char.py b/algorithms_project/algorithms/hashing/first_uni_char.py new file mode 100644 index 0000000..1cf933b --- /dev/null +++ b/algorithms_project/algorithms/hashing/first_uni_char.py @@ -0,0 +1,35 @@ +class Solution: + # Define uma classe chamada Solution (estrutura comum usada no LeetCode) + def firstUniqChar(self, s: str) -> int: + # Método que recebe uma string 's' e retorna o índice do primeiro caractere único + # (que aparece apenas uma vez). Se não houver, retorna -1. + + d = {} + # Cria um dicionário vazio 'd' que vai armazenar cada caractere da string + # como chave, e como valor uma lista [índice, contagem]. + + for idx, ch in enumerate(s): + # Percorre cada caractere 'ch' da string 's', junto com seu índice 'idx'. + + if not d.get(ch): + # Se o caractere ainda não existe no dicionário... + + d[ch] = [idx, 1] + # Adiciona o caractere no dicionário com: + # [índice da primeira ocorrência, contagem inicial 1]. + + else: + d[ch][1] += 1 + # Caso o caractere já esteja no dicionário, incrementa a contagem em +1. + + for ch, val in d.items(): + # Percorre os pares (caractere, [índice, contagem]) armazenados no dicionário. + + if val[1] == 1: + # Se a contagem (val[1]) for igual a 1, significa que o caractere é único. + + return val[0] + # Retorna o índice (val[0]) da primeira ocorrência desse caractere único. + + return -1 + # Se não encontrar nenhum caractere único, retorna -1. diff --git a/algorithms_project/algorithms/sliding_window/contains_duplicate.py b/algorithms_project/algorithms/sliding_window/contains_duplicate.py index 7a43d11..1b0e397 100644 --- a/algorithms_project/algorithms/sliding_window/contains_duplicate.py +++ b/algorithms_project/algorithms/sliding_window/contains_duplicate.py @@ -1,23 +1,34 @@ class Numsolution(object): def containnumsNearbyDuplicate(self, nums, k): """ + Verifica se existe algum par de elementos duplicados na lista 'nums' + tal que os índices desses elementos estejam a no máximo 'k' posições de distância. + :type nums: List[int] :type k: int :rtype: bool """ + # Começamos com o primeiro índice da lista i = 0 + # Loop externo percorre cada elemento da lista como possível "primeiro duplicado" while i < len(nums): + # 'j' começa logo após 'i' e vai até 'i + k' ou até o final da lista j = i + 1 while j <= i + k and j < len(nums): + # Imprime quais elementos estão sendo comparados (útil para depuração) print(f'Comparando nums[{i}] = {nums[i]} com nums[{j}] = {nums[j]}') + + # Se encontrar duplicata dentro da janela de tamanho k, retorna True if nums[i] == nums[j]: return True + + # Avança o segundo índice j += 1 + + # Avança o primeiro índice i += 1 + + # Se percorreu toda a lista e não encontrou duplicatas próximas, retorna False return False - - -numsolution = Numsolution() -print(numsolution.containnumsNearbyDuplicate([1, 2, 3, 1], 3)) diff --git a/algorithms_project/tests/test_arrays/test_exponential_search.py b/algorithms_project/tests/test_arrays/test_exponential_search.py index 423e9d9..768d5f9 100644 --- a/algorithms_project/tests/test_arrays/test_exponential_search.py +++ b/algorithms_project/tests/test_arrays/test_exponential_search.py @@ -1,5 +1,5 @@ import pytest -from algorithms_project.algorithms.arrays.exponential_search import Solution, ArrayReader +from algorithms_project.algorithms.binary_search.exponential_search import Solution, ArrayReader @pytest.mark.parametrize("array,target,expected", [ diff --git a/algorithms_project/tests/test_binary_search/test_binarysearch.py b/algorithms_project/tests/test_binary_search/test_binarysearch.py index 0930bcc..5ef5d29 100644 --- a/algorithms_project/tests/test_binary_search/test_binarysearch.py +++ b/algorithms_project/tests/test_binary_search/test_binarysearch.py @@ -1,5 +1,5 @@ import pytest -from algorithms.arrays.binary_search import Binary +from algorithms_project.algorithms.binary_search.binary_search import Binary @pytest.mark.parametrize("array,target,expected", [ diff --git a/algorithms_project/tests/test_hashing/test_contains_duplicated.py b/algorithms_project/tests/test_hashing/test_contains_duplicated.py new file mode 100644 index 0000000..fd97008 --- /dev/null +++ b/algorithms_project/tests/test_hashing/test_contains_duplicated.py @@ -0,0 +1,13 @@ +import pytest +from algorithms_project.algorithms.sliding_window.contains_duplicate import Numsolution + + +array = [1, 2, 3, 1] +k = 3 +result = Numsolution().containnumsNearbyDuplicate(array,k) + +@pytest.mark.parametrize("array,k,expected", [ + (array,k,result), +]) +def test_contains_duplicated(array, k, expected): + assert Numsolution().containnumsNearbyDuplicate(array,k) == expected diff --git a/algorithms_project/tests/test_hashing/test_first_uni_char.py b/algorithms_project/tests/test_hashing/test_first_uni_char.py new file mode 100644 index 0000000..870c872 --- /dev/null +++ b/algorithms_project/tests/test_hashing/test_first_uni_char.py @@ -0,0 +1,21 @@ +import pytest +from algorithms_project.algorithms.hashing.first_uni_char import Solution + + +st = "leetcode" +ex = Solution().firstUniqChar("leetcode") + +@pytest.mark.parametrize("string,expected", [ + (st, ex), +]) +def test_exponential_search(string, expected): + assert Solution().firstUniqChar(string) == expected + +st = "loveleetcode" +ex = Solution().firstUniqChar("loveleetcode") + +@pytest.mark.parametrize("string,expected", [ + (st, ex), +]) +def test_exponential_search1(string, expected): + assert Solution().firstUniqChar(string) == expected