Password checking

A password is considered strong if below conditions are all met:

It has at least 6 characters and at most 20 characters.

It must contain at least one lowercase letter, at least one uppercase letter, and at least one digit.

It must NOT contain three repeating characters in a row ("...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).

Write a function strongPasswordChecker(s), that takes a string s as input, and return the MINIMUM change required to make s a strong password. If s is already strong, return 0.

Insertion, deletion or replace of any one character are all considered as one change.

花了一個小時用了一種特別蠢的方法hard code了這道題。

結(jié)果看了一下discussion的post。。。有點心碎

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,048評論 0 23
  • 不知何時,小城也悄悄出現(xiàn)了右腦開發(fā)機構(gòu)。早教機構(gòu)往往把右腦開發(fā)做為課程推出,培訓(xùn)班也擎出右腦開發(fā)的大旗,很多家長被...
    踏雪尋梅_2457閱讀 571評論 0 0
  • 我和羅先生在一起一周年了。開始時多吵鬧,到現(xiàn)在是多包容。 我問羅先生,如果要把我們的故事講給別人聽,你覺得我們的故...
    青梔閱讀 248評論 0 0
  • 阿里云有一個安全組規(guī)則,其中限制了外部網(wǎng)絡(luò)設(shè)備對阿里云實例服務(wù)器的訪問權(quán)限。 默認打開了 SSH 連接的 22 端...
    南波閱讀 3,684評論 3 4
  • 對于吃慣了肉的人來說,全吃素菜可能會覺得差點兒味兒。所以即便是炒個白菜什么的,也通常會多少放些肉,提提味兒。現(xiàn)在開...
    金黃魚閱讀 277評論 0 0

友情鏈接更多精彩內(nèi)容