benchmarks.wiki / Public workspace
..... .··:-=++*******+++=========================================++++++++==--::··.........··:--=++*****+=-:··.
.. ...··:::------::::::::::::::----====++++++====--:::·············:······.... ...··:::-----:--:·..
......................·····:::::::::::::···.... ...... ........::-::·..
..::-:··..
..:·::··..
..··:··..
..·····..
..·.··...
..·.··...
............................ ..........................··....... ...·.·....
..··:::---::::------------::·.. ..··:::----:::::·······::::--------:::···...........·······.·...
.·:--=++*#******########*++=-:·. .·:--=++*****+++===------===++******+++=--:::·······:::::::::··...
.....······::::::----------===++**###%%%@@@@@@@@@@@@%%%%###******+++++++++===--::········::--=++*#########**+==-::·.
.......·······················:::---==+++*************+++==---::::::::::·····..... ...···::---=====----::--::·.
.............. ....····:::::::::::::::···................ ......······...::-::··.
..··:···..
..·.··...
......
. .
......···············.... ..............
...··::---==+++*****+++=--:·.. ....················::::-----:::··... .....··.....
..·::-=+*##%@@@@@@@@@@%#*+=-:·. ..··::--======-----------==++*****++==-:··.. ...···::::::::··..
..··:::--::::····......···::-==++**###%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#**+=--::······:-=+*#%@@@@@@@@@%##**+++==--::·.
...··::::::::····..............···:::---=====++++====================---::··.... ...··:--=++*****+++==-----:=--::·.
....······...... .....···········.............····...... ...····:::::······..::--::·..
..:·:::··.
..·.···...
.....
....·····::::::::·····.... .........
...·::-==++*******++==--::··.........·········.... ..···:::::::··. ..........
.··-==+*#%@@@@@@@@%#**+==--:::::---==+++++++==--:··... ...··:-==+++++=-:··. ..···:::::····...
.··:--==---::····.....····::::------:::::::::::::::--=++*#%@@@@@@@@@@%#*+=-::····::-=+*#%@@@@@@@@%##*++++++++==--:·.
..·::--==----:::···.................................···::--==++*****++=--:··......··::-=++******+++==--------+=--:·.
...···::::·····.... ....····::::····.... ....···::::::::·········-:==-::·.
..::--::·.
..··:··..
.....
......·············.........·······..... .........
.··::---======----:::::::::---=======--:··. .··::::::··.. .... ...
..·:-==+++*++++===--------=++*##%%@@@@%#*+=-·. .·::-====--:··. .....···············...
..·::-==++=====---==========---::··... .·:-=+#%@@@@@@@@%#*=--:······::--=++*******+++++++++**#**++=-:·.
.··:--=+++=====-----::::·····...... .··:-==+*****++=--:···.....···::----===-----------=====*+=-:·.
...···:::::::····...... ..····:::::····.... ......···················=-++=-·.
··--=--:·.
..:·::·..
..·...
..
.................····::::::::···.. .............. ......
...····::·············::--==++*****++=-:·.. ..··:::::::····............... ...·::··.
.·::--====---::···....···:-=+*#%@@@@@@@%*+=:·. .·::--===---::····.......................··::----::·.
..·::--=+++++****####%%####*++=--:·.. .·:-=++*****++=--::·················::::::--==++*##%@%#*+=-:.
.··::-=============------:::::····... .··::--------:::···....................····:::--==+++=*+=-:.
...···:::······...................... ....·······........ ......·····==*+-:·.
··--=-:·..
..:·:··..
......
....
......
.····.
.....····::::::::::···... ...................····....... ..::::··.
..··::::::::····........··::-==+*******++=-::··... .....····:::::::::::::-------::::··... ..···:---::·.
.·:-=+#####*++=-::·........·:-=+*#%@@@@@@@%#*+=-:··.......···::::---------=====+++++++===--::::···::::--=+===--:·.
..··:::-====+++***########**++==-:··. ...···:::::----------:::··.. ..·::-=+*##%%##*=-:·.
..··:::---:::::::::::::::::::::····... ......················... ..··:--====-+=-:·.
............. .............. .............. .....··--=-:·.
..:·::·..
·.··..
......
.......
..·····.
··--::·..
.......................·····:::::::::::·····......... .....·····:::::::····.... ...::==--:·.
.··:-==+====--:::········::--==+++******++++===---::::·····........···::--==+++****+++==--:::········::-----+==-:·
.·:-+*#%@@@@@%#*+=--::::::::-==+*##%%@@@@@@@%%%##***++===--:::·········::-==+**#%%@@@@@%%###**++++++++****##**+=-:·.
...···::::-----======+======--::··... ..·:-=+*###%%##*+=-:·. ..·::--==--::·..
...····························..... ..··::--=====--:··. ...···:··:··..
...... ..... ....······.... ...····..
..·.·..
.....
..·...
..··:···..
..::--::·.
··=-+=-:·.
....····..........······························.... ...··::::::::::::····.........·····:+=*+=-:.
.··:-==++====-----------=======+===========+++++===--::··.. ..·::-==++******+++==----------===+++*+=*+=-:.
.·-=+*#%@@@%%#***+++++++***#############%%%%%@@@@@@%%#*++=-:·... ...·::-=+**##%%%%%###****++++****###%%%@%#*+-:·.
...···:::----========---:::··...........········... .·:-=+#%@@@@@@@@@%#+=-:·. ........
....····················.... .......... ..·:-==+*****++=--:·.. ..........
..···········... ......·...
..·.·.
..:···.
··:::··.
··--=-:·.
··==+=-:·.
::+=*+=:·.
.............·············..............······.... ...··············..........·····::::+=*+=-·.
..··:::---::-----===++++++===--::::::::::--=======--::·.. ..··::---====---:::··········::--==++**+=*+=-·.
.·:-=++***++++++**##%%@@@@@%%#**++======++*##%%@@@@%%#*+=-:··........··::--======---::····...····::-=++*#%%@%#*+=:·.
..··:-==++*******++=--:··.......··:--==++++==-:··.......·:-=+#%@@@@@@@@@@@%#*+=-:··... ......······...
...···:::--------::···... ...··::::::::··.. ..·:--=++*****++==-::··... ...···::::::::::·.·..
................. .......... ...··········.... ....······:······:···.
··-::·..
:·-:-··.
:·=--:·..
:·=-=-:·.
::=-+-:·..
::==+=-:·.
.....·········.... ............ .......·...... ...······==+=-:·.
......·······::--=======--::··........··::--------::···.... ....···:::-----:::··.. ..··:--==+==+=-:·.
.··::::::::---=++*##%%%%##*+=--:······::-=++*#######**++==-------===++++++++=--:·.. ..·:-=+**#**+=-:·.
.·:==+*##%%%%##*++=-:::····::--=++****++=--:···....··::-=+**##%%%%###**++===----------===+++********+++=-:··..
..·::--=========--::···....···:::-------::···.........···::----------:::····.....···::-==++*********++=-:-:·..
....··········..... ......·····..... .............. ....··::::::::::::::::=-=:·..
::=-=:·..
:·=:-:·..
··-:-:·..
··::-:·..
..::::·..
..:·::·..
.............. .............. .....··········.... .....:·::·..
.....···:::----:::···.........···:::::-:::::········:::--==+++***+++=--:·. ..····:··::··..
........····::--=++++++==-::·········::-==+++++++++++++++++*##%%@@@@@@@@@%#*+=-:·. ..··::---:::··..
.·:==+**####***++==----------------:::··.........··:::--======----::::·······:::--==+*##%@@@@@@@@@@@@@@%*+=-:·.
..·:---=======---::::::::::::::::::····............····:::::::····... ...·::-=++***************+=*=-:·.
....············....................... ............ ...··:::::::::::::::::+=+=-:·.
:·=-+=-:·.
··-:--:··.
..:·::··..
..·.····..
..·.....
.....
.........................·······....... .....····:::::::::::···.. .....
......·····::::::·········:::::--------:::··········::--=++***********+=-::·.. ..
.....····::::--------::::::::---===+++++++====--------==+*#%%@@@@@@@@@@@%#*+=-:·..
..·:::--------:::----------::··.. ..··:::------:::···...... .....··::-==+**##%%%%@@@@@@@@@%#*+=-:·.
...··:::::::::····:::::::::::···... ...···:::::::····... ...··::--==++++++++++****+=*+=-:·.
............................... ............... ....················::+=*+=-:·.
··==*+=-:·.
..--++=-:·.
..::==--:·.
.·:::::·.
.··:··..
.····.
....····..............·····::::::::·····..... .....····::::::::::···.... .....
..··::-----:::::·····:::---==++++**+++==--::···......···:--==+++****++==--::··..... ....
..·::-=++++===---::::::--==++*##%%%%%%##*++=--::·····:::-==++**#####***+==--::···.......·····... ...
....... ..·::--==---:·.. ..···:::::::::::::··············:::::------------==++*#%@@%#*+=-:·.
........ ..···::::::··.. ..···:::::::::::···.............····::::::::···::::--=++*+=*+=-:·.
.... ............ .....·······...... ......................···:+=*+=-:·.
··+=*+=-:·.
.·==*+=-:·.
..--*+=-:·.
.:-++=-:·.
·:===-:·.
.·----:·.
...···:···...........···::::::::::::::···..... .......·········........ ............ .:::::·.
.··:-==+++=--:········::-==+**********+==-::··........···:::--------:::···..........·········.. ··::··.
·:-=+*#%@%#*+=-:::::::--=+*#%%@@@@@@%%#*+=--:····.····::---=======---::··.........··::------::·. ..···.
.... .·:-=++*++=-:·.. ...····::::------=================--:::··.......··:-=*#%@%#*+=-:.
... .··::----::··. ..···:::::::::::::::·····::::::::::::···.... ...··:-=+++=*+=-:·
....··..... ....·········............................ ...··:+=*+=-:·.
··+=*+=-:·.
··+=*+=-:·.
.·==*+=-:·.
.·==*+=-:·.
..--*+=-:·.
..:-++=-:·.
...·····.. ...····:::::::::::···...... .................. .....·······... .::===-:·.
.··:-==++=-:··.....···:--==++****++==--::··..........··::::----::::··.... ...··:::------::··. ..··----:·.
.·:-=+*#%@%#+=-:::·:::--==+***##***+==-:··... ...··::-==+++++++=--::·... ..··:-=+++**++=-:·. .·:::::··.
... .·:-=+*#####*+=--:·... .....····::::----====++++++*****+++==-::·.. ..·:-=+*###*+=-:·.
.. .·::--===---::··... ...····:::::---:::::::······::::::::::::···... ..·::-===-+=-:·.
.....···...... .....············..... ............... ....··=-+=-:·.
··--+=-:·.
.·--+=-:·.
.·--+=-:·.
.·--+=-:·.
..--==-:·.
..::==-:·.
......... .....·········..... ................ .....·········.... ...::=--:·.
.··:-==---:·········:::-------:::··.. ..··::--------::···.......···::--======--::··... ...··:::--::·.
.·:-=+*#%%#*+==------========--:··. .·:-==+**###**++=--::·······::-=++**###**+==-:··.......··::--:::··.
██╗ ██╗██╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗██████╗ ███████╗███╗ ██╗ ██████╗██╗ ██╗
██║ ██║██║ ██║██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗██╔════╝████╗ ██║██╔════╝██║ ██║
██║ ██║██║ ██║█████╗ ██║ ██║ ██║██║ ██║█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ███████║
██║ ██║╚██╗ ██╔╝██╔══╝ ██║ ██║ ██║██║ ██║██╔══╝ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██╔══██║
███████╗██║ ╚████╔╝ ███████╗╚██████╗╚██████╔╝██████╔╝███████╗██████╔╝███████╗██║ ╚████║╚██████╗██║ ██║
╚══════╝╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝$ open /benchmarks/livecodebench/tasks/release~5fv1--te…▌ posts · files
LiveCodeBench / 2755 / extra-characters-in-a-string
Problem
Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.
question title
extra-characters-in-a-string
question content
You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings. Return the minimum number of extra characters left over if you break up s optimally. Example 1: Input: s = "leetscode", dictionary = ["leet","code","leetcode"] Output: 1 Explanation: We can break s in two substrings: "leet" from index 0 to 3 and "code" from index 5 to 8. There is only 1 unused character (at index 4), so we return 1. Example 2: Input: s = "sayhelloworld", dictionary = ["hello","world"] Output: 3 Explanation: We can break s in two substrings: "hello" from index 3 to 7 and "world" from index 8 to 12. The characters at indices 0, 1, 2 are not used in any substring and thus are considered as extra characters. Hence, we return 3. Constraints: 1 <= s.length <= 50 1 <= dictionary.length <= 50 1 <= dictionary[i].length <= 50 dictionary[i] and s consists of only lowercase English letters dictionary contains distinct words
starter code
Code
class Solution:
def minExtraChar(self, s: str, dictionary: List[str]) -> int:
contest date
2023-05-27T00:00:00
contest id
biweekly-contest-105
difficulty
medium
platform
leetcode
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See how this is scored Scored by the benchmark’s own harness
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
- upstream_id / Original problem ID
- 2755
- task_id
70640610-934c-5d7b-a161-4dace90b2785- task_key
release~5fv1--test--2755- task_revision_id
- 4
- config / split
- release_v1 / test
initial import