Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
0523 - SecvEgale
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Explicație rezolvare== Funcția validare primește numărul de elemente n și vectorul v și returnează True dacă acestea corespund restricțiilor impuse și False în caz contrar. Mai precis, verifică dacă n este între 1 și 1000 și dacă toate elementele din v sunt numere naturale mai mici decât 1000. Funcția rezolvare primește numărul de elemente n și vectorul v și returnează lungimea celei mai lungi secvențe de elemente egale din vector. Mai precis, parcurge vectorul de la dreapta la stânga și pentru fiecare element verifică cât de lungă este secvența de elemente egale care începe cu el. Dacă lungimea acestei secvențe este mai mare decât lungimea celei mai lungi secvențe găsite până acum, atunci actualizează variabila maxim și variabila poz care reține poziția primei apariții a celei mai lungi secvențe de elemente egale. În funcția rezolvare se folosește și funcția validare pentru a verifica dacă datele de intrare sunt corecte. În funcția rezolvare se consideră că dacă în vector există mai multe secvențe de elemente egale de lungime maximă, atunci se determină cea mai din dreapta. În funcția rezolvare se folosește funcția isinstance pentru a verifica dacă rezultatul este un șir de caractere (adică mesajul de eroare) sau un număr (adică lungimea celei mai lungi secvențe de elemente egale). Citirea datelor de intrare și afișarea rezultatului se fac în funcția main.
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width