Tag:Letter

  • JS is sorted according to an attribute of the object in the array

    Time:2021-2-26

    1. Code //Sort the objects in the array are sorted alphabetically Compare(ticked, name) { return function(a, b) { var t1 = a[ticked]; var s1 = a[name]; var t2 = b[ticked]; var s2 = b[name]; if (t1) { if (t2) { return s1.localeCompare(s2); } else { return -1; } } else { if (!t2) { return […]

  • 【leetcode】127. Word Ladder

    Time:2021-2-24

    Main idea: Give a start word beginword and an end word Endword, and then give a word list wordlist. From beginword to Endword, only one letter can be changed at a time, and the word is wordlist. Solutions: In fact, it is a disguised BFS. It looks for the adjacent words that can be transformed […]

  • Leetcode-242 effective letter ectopic words

    Time:2021-2-19

    Give two stringssandt, write a function to judgetIs itsThe letter of heterotopic words. demo01 Input: S =’anagram ‘, t =’nagaram’ Output: true demo02 Input: S = “rat”, t = “car” Output: false explain:You can assume that the string contains only lowercase letters. Explanation of the problem Key words: Map First, judge whether the length of […]

  • Go basic variables and constants

    Time:2021-2-2

    Go language variables and constants Naming rules Go language command rule: a name must be inOne letterorStart with an underline, followed by any number of letters, numbers, or underscores. Uppercase and lowercase letters are different variables keyword Go language has25Keywords can’t be used to declare variables. They can only be used in specific syntax structures. […]

  • Regular expression library

    Time:2021-2-1

    1. Train number /^[GCDZTSPKXLY1-9]\d{1,4}$/ 2. Web address with port number /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/ (1) Ip-v4 [: Port] /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]).){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/ (2) Ip-v6 [: Port] ~~~~/^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5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){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/i (3) MAC address /^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i 3. Subnet mask /^(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(?:\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/ 4. Web address (URL, support port and “? + parameter” and “# + parameter) /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\[email protected]?^=%&/~+#-])?$/ 5. Unified social credit code/^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/6. Unified social credit code loose matching […]

  • Introduction to regular expressions

    Time:2021-1-22

    introduction \b \bIt’s a special code defined by regular expressions (well, some people call it metacharacter), which represents the beginning or end of a word, that is, the boundary between words. Although English words are usually separated by spaces, punctuation marks or newlines, it does not match any of these word separator characters. It only […]

  • C practical exercise topic 6

    Time:2021-1-20

    Title:Use the * sign to output the pattern of the letter C. Program analysis:You can write the letter C on the paper with “*” first, and then output it in line. Source code: #include “stdio.h” int main() { Printf (“use the * sign to output the letter C!”; printf(” ****\n”); printf(” *\n”); printf(” * \n”); […]

  • Shift Cipher

    Time:2021-1-18

    Shift Cipher The Shift Cipher itself is very simple, that is, each letter in plaintext moves a fixed length position in the alphabet. Suppose x, y, K, Z_ If {26}, then\\ From the previous discussion on replacement ciphers, it is not difficult to come to the conclusion that shift ciphers are not secure at all. […]

  • Leetcode elementary algorithm

    Time:2021-1-5

    Leetcode elementary algorithm Note:Click the title to view the corresponding title, this code is usedJavascriptto write. Code is not necessarily the optimal solution, for reference only, if you have a better implementation, welcome to exchange. Invert string Analysis: toIn placeThe second array is swapped, the first array is swapped, the last array is swapped, and […]

  • Collation of common regular expressions

    Time:2021-1-2

    Common regularization Some regularities can’t guarantee the exact match, just for reference. Website URL^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+ phone number0?1[2-8][0-9]{9} mailbox\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14} Domestic phone number[0-9-()()]{7,18} ID number\d{17}[\d|x]|\d{15} date\d{4}(\-|\/|.)\d{1,2}\ Chinese characters[\u4e00-\u9fa5] Chinese characters and symbols[^\x00-\xff] IP address (25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d) Common metacharacters code explain . Matches any character except newline \w Match letters or numbers or underscores \s Matches any white space \d […]

  • Go language specification

    Time:2020-12-31

      1. The hump naming method is recommended for naming golang. It must start with a single letter (Unicode letter) or an underline, and can be followed by any number of letters, numbers or underscores. 2. In golang, the access permission is determined by the case of the first letter. No matter the method name, […]

  • String matching algorithm KMP algorithm

    Time:2020-12-31

    String matching algorithm KMP algorithm1、 Algorithm Introduction:KMP algorithm is an improved string matching algorithm proposed by d.e.knuth, j.h.morris and v.r.pratt, so it is called Knut Morris Pratt operation (KMP algorithm for short).The core of KMP algorithm is to use the information after matching failure to reduce the matching times of pattern string and main string […]