From 165d1cd6fe72e42767fb50bb38dbc7b7524e29db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sun, 27 Mar 2022 18:43:57 +0800 Subject: [PATCH] add problems --- 算法题/add-two-numbers.html | 35 ++++ 算法题/add-two-numbers.json | 185 ++++++++++++++++++ 算法题/longest-palindromic-substring.html | 25 +++ 算法题/longest-palindromic-substring.json | 176 +++++++++++++++++ ...t-substring-without-repeating-characters.html | 35 ++++ ...t-substring-without-repeating-characters.json | 178 +++++++++++++++++ 算法题/median-of-two-sorted-arrays.html | 32 +++ 算法题/median-of-two-sorted-arrays.json | 171 ++++++++++++++++ 算法题/palindrome-number.html | 42 ++++ 算法题/palindrome-number.json | 168 ++++++++++++++++ 算法题/regular-expression-matching.html | 44 +++++ 算法题/regular-expression-matching.json | 178 +++++++++++++++++ 算法题/reverse-integer.html | 32 +++ 算法题/reverse-integer.json | 166 ++++++++++++++++ 算法题/string-to-integer-atoi.html | 76 +++++++ 算法题/string-to-integer-atoi.json | 173 ++++++++++++++++ 算法题/two-sum.html | 41 ++++ 算法题/two-sum.json | 176 +++++++++++++++++ 算法题/zigzag-conversion.html | 51 +++++ 算法题/zigzag-conversion.json | 166 ++++++++++++++++ 20 files changed, 2150 insertions(+) create mode 100644 算法题/add-two-numbers.html create mode 100644 算法题/add-two-numbers.json create mode 100644 算法题/longest-palindromic-substring.html create mode 100644 算法题/longest-palindromic-substring.json create mode 100644 算法题/longest-substring-without-repeating-characters.html create mode 100644 算法题/longest-substring-without-repeating-characters.json create mode 100644 算法题/median-of-two-sorted-arrays.html create mode 100644 算法题/median-of-two-sorted-arrays.json create mode 100644 算法题/palindrome-number.html create mode 100644 算法题/palindrome-number.json create mode 100644 算法题/regular-expression-matching.html create mode 100644 算法题/regular-expression-matching.json create mode 100644 算法题/reverse-integer.html create mode 100644 算法题/reverse-integer.json create mode 100644 算法题/string-to-integer-atoi.html create mode 100644 算法题/string-to-integer-atoi.json create mode 100644 算法题/two-sum.html create mode 100644 算法题/two-sum.json create mode 100644 算法题/zigzag-conversion.html create mode 100644 算法题/zigzag-conversion.json diff --git a/算法题/add-two-numbers.html b/算法题/add-two-numbers.html new file mode 100644 index 00000000..460c80a4 --- /dev/null +++ b/算法题/add-two-numbers.html @@ -0,0 +1,35 @@ +

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

+ +

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

+ +

 

+

Example 1:

+ +
+Input: l1 = [2,4,3], l2 = [5,6,4]
+Output: [7,0,8]
+Explanation: 342 + 465 = 807.
+
+ +

Example 2:

+ +
+Input: l1 = [0], l2 = [0]
+Output: [0]
+
+ +

Example 3:

+ +
+Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
+Output: [8,9,9,9,0,0,0,1]
+
+ +

 

+

Constraints:

+ + diff --git a/算法题/add-two-numbers.json b/算法题/add-two-numbers.json new file mode 100644 index 00000000..98f073ea --- /dev/null +++ b/算法题/add-two-numbers.json @@ -0,0 +1,185 @@ +{ + "data": { + "question": { + "questionId": "2", + "questionFrontendId": "2", + "boundTopicId": null, + "title": "Add Two Numbers", + "titleSlug": "add-two-numbers", + "content": "

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

\n\n

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

\n\n

 

\n

Example 1:

\n\"\"\n
\nInput: l1 = [2,4,3], l2 = [5,6,4]\nOutput: [7,0,8]\nExplanation: 342 + 465 = 807.\n
\n\n

Example 2:

\n\n
\nInput: l1 = [0], l2 = [0]\nOutput: [0]\n
\n\n

Example 3:

\n\n
\nInput: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]\nOutput: [8,9,9,9,0,0,0,1]\n
\n\n

 

\n

Constraints:

\n\n\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 17484, + "dislikes": 3629, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Multiply Strings\", \"titleSlug\": \"multiply-strings\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Add Binary\", \"titleSlug\": \"add-binary\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Sum of Two Integers\", \"titleSlug\": \"sum-of-two-integers\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Add Strings\", \"titleSlug\": \"add-strings\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Add Two Numbers II\", \"titleSlug\": \"add-two-numbers-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Add to Array-Form of Integer\", \"titleSlug\": \"add-to-array-form-of-integer\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Add Two Polynomials Represented as Linked Lists\", \"titleSlug\": \"add-two-polynomials-represented-as-linked-lists\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", + "exampleTestcases": "[2,4,3]\n[5,6,4]\n[0]\n[0]\n[9,9,9,9,9,9,9]\n[9,9,9,9]", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Linked List", + "slug": "linked-list", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Math", + "slug": "math", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Recursion", + "slug": "recursion", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListNode(int val) { this.val = val; }\n * ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n public ListNode addTwoNumbers(ListNode l1, ListNode l2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "# Definition for singly-linked list.\n# class ListNode(object):\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution(object):\n def addTwoNumbers(self, l1, l2):\n \"\"\"\n :type l1: ListNode\n :type l2: ListNode\n :rtype: ListNode\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * struct ListNode *next;\n * };\n */\n\n\nstruct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public int val;\n * public ListNode next;\n * public ListNode(int val=0, ListNode next=null) {\n * this.val = val;\n * this.next = next;\n * }\n * }\n */\npublic class Solution {\n public ListNode AddTwoNumbers(ListNode l1, ListNode l2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param {ListNode} l1\n * @param {ListNode} l2\n * @return {ListNode}\n */\nvar addTwoNumbers = function(l1, l2) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# Definition for singly-linked list.\n# class ListNode\n# attr_accessor :val, :next\n# def initialize(val = 0, _next = nil)\n# @val = val\n# @next = _next\n# end\n# end\n# @param {ListNode} l1\n# @param {ListNode} l2\n# @return {ListNode}\ndef add_two_numbers(l1, l2)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "/**\n * Definition for singly-linked list.\n * public class ListNode {\n * public var val: Int\n * public var next: ListNode?\n * public init() { self.val = 0; self.next = nil; }\n * public init(_ val: Int) { self.val = val; self.next = nil; }\n * public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; }\n * }\n */\nclass Solution {\n func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "/**\n * Definition for singly-linked list.\n * type ListNode struct {\n * Val int\n * Next *ListNode\n * }\n */\nfunc addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode(_x: Int = 0, _next: ListNode = null) {\n * var next: ListNode = _next\n * var x: Int = _x\n * }\n */\nobject Solution {\n def addTwoNumbers(l1: ListNode, l2: ListNode): ListNode = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "/**\n * Example:\n * var li = ListNode(5)\n * var v = li.`val`\n * Definition for singly-linked list.\n * class ListNode(var `val`: Int) {\n * var next: ListNode? = null\n * }\n */\nclass Solution {\n fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode? {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "// Definition for singly-linked list.\n// #[derive(PartialEq, Eq, Clone, Debug)]\n// pub struct ListNode {\n// pub val: i32,\n// pub next: Option>\n// }\n// \n// impl ListNode {\n// #[inline]\n// fn new(val: i32) -> Self {\n// ListNode {\n// next: None,\n// val\n// }\n// }\n// }\nimpl Solution {\n pub fn add_two_numbers(l1: Option>, l2: Option>) -> Option> {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "/**\n * Definition for a singly-linked list.\n * class ListNode {\n * public $val = 0;\n * public $next = null;\n * function __construct($val = 0, $next = null) {\n * $this->val = $val;\n * $this->next = $next;\n * }\n * }\n */\nclass Solution {\n\n /**\n * @param ListNode $l1\n * @param ListNode $l2\n * @return ListNode\n */\n function addTwoNumbers($l1, $l2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "/**\n * Definition for singly-linked list.\n * class ListNode {\n * val: number\n * next: ListNode | null\n * constructor(val?: number, next?: ListNode | null) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n * }\n */\n\nfunction addTwoNumbers(l1: ListNode | null, l2: ListNode | null): ListNode | null {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "; Definition for singly-linked list:\n#|\n\n; val : integer?\n; next : (or/c list-node? #f)\n(struct list-node\n (val next) #:mutable #:transparent)\n\n; constructor\n(define (make-list-node [val 0])\n (list-node val #f))\n\n|#\n\n(define/contract (add-two-numbers l1 l2)\n (-> (or/c list-node? #f) (or/c list-node? #f) (or/c list-node? #f))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "%% Definition for singly-linked list.\n%%\n%% -record(list_node, {val = 0 :: integer(),\n%% next = null :: 'null' | #list_node{}}).\n\n-spec add_two_numbers(L1 :: #list_node{} | null, L2 :: #list_node{} | null) -> #list_node{} | null.\nadd_two_numbers(L1, L2) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "# Definition for singly-linked list.\n#\n# defmodule ListNode do\n# @type t :: %__MODULE__{\n# val: integer,\n# next: ListNode.t() | nil\n# }\n# defstruct val: 0, next: nil\n# end\n\ndefmodule Solution do\n @spec add_two_numbers(l1 :: ListNode.t | nil, l2 :: ListNode.t | nil) :: ListNode.t | nil\n def add_two_numbers(l1, l2) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"2.6M\", \"totalSubmission\": \"6.9M\", \"totalAcceptedRaw\": 2644448, \"totalSubmissionRaw\": 6888821, \"acRate\": \"38.4%\"}", + "hints": [], + "solution": { + "id": "30", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "[2,4,3]\n[5,6,4]", + "metaData": "{\r\n \"name\": \"addTwoNumbers\",\r\n \"params\": [\r\n {\r\n \"name\": \"l1\",\r\n \"type\": \"ListNode\",\r\n \"dealloc\": false\r\n },\r\n {\r\n \"name\": \"l2\",\r\n \"type\": \"ListNode\",\r\n \"dealloc\": false\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"ListNode\",\r\n \"dealloc\": true\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": { + "id": "838", + "date": "2022-03-10", + "incompleteChallengeCount": 0, + "streakCount": 0, + "type": "DAILY", + "__typename": "ChallengeQuestionNode" + }, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/longest-palindromic-substring.html b/算法题/longest-palindromic-substring.html new file mode 100644 index 00000000..0ab8910e --- /dev/null +++ b/算法题/longest-palindromic-substring.html @@ -0,0 +1,25 @@ +

Given a string s, return the longest palindromic substring in s.

+ +

 

+

Example 1:

+ +
+Input: s = "babad"
+Output: "bab"
+Explanation: "aba" is also a valid answer.
+
+ +

Example 2:

+ +
+Input: s = "cbbd"
+Output: "bb"
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 1000
  • +
  • s consist of only digits and English letters.
  • +
diff --git a/算法题/longest-palindromic-substring.json b/算法题/longest-palindromic-substring.json new file mode 100644 index 00000000..7fb00c4b --- /dev/null +++ b/算法题/longest-palindromic-substring.json @@ -0,0 +1,176 @@ +{ + "data": { + "question": { + "questionId": "5", + "questionFrontendId": "5", + "boundTopicId": null, + "title": "Longest Palindromic Substring", + "titleSlug": "longest-palindromic-substring", + "content": "

Given a string s, return the longest palindromic substring in s.

\n\n

 

\n

Example 1:

\n\n
\nInput: s = "babad"\nOutput: "bab"\nExplanation: "aba" is also a valid answer.\n
\n\n

Example 2:

\n\n
\nInput: s = "cbbd"\nOutput: "bb"\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 1 <= s.length <= 1000
  • \n\t
  • s consist of only digits and English letters.
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 16733, + "dislikes": 981, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Shortest Palindrome\", \"titleSlug\": \"shortest-palindrome\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Palindrome Permutation\", \"titleSlug\": \"palindrome-permutation\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Palindrome Pairs\", \"titleSlug\": \"palindrome-pairs\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Longest Palindromic Subsequence\", \"titleSlug\": \"longest-palindromic-subsequence\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Palindromic Substrings\", \"titleSlug\": \"palindromic-substrings\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", + "exampleTestcases": "\"babad\"\n\"cbbd\"", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "String", + "slug": "string", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n string longestPalindrome(string s) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public String longestPalindrome(String s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def longestPalindrome(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def longestPalindrome(self, s: str) -> str:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nchar * longestPalindrome(char * s){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public string LongestPalindrome(string s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string} s\n * @return {string}\n */\nvar longestPalindrome = function(s) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String} s\n# @return {String}\ndef longest_palindrome(s)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func longestPalindrome(_ s: String) -> String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func longestPalindrome(s string) string {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def longestPalindrome(s: String): String = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun longestPalindrome(s: String): String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn longest_palindrome(s: String) -> String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String $s\n * @return String\n */\n function longestPalindrome($s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function longestPalindrome(s: string): string {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (longest-palindrome s)\n (-> string? string?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec longest_palindrome(S :: unicode:unicode_binary()) -> unicode:unicode_binary().\nlongest_palindrome(S) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec longest_palindrome(s :: String.t) :: String.t\n def longest_palindrome(s) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.8M\", \"totalSubmission\": \"5.5M\", \"totalAcceptedRaw\": 1752925, \"totalSubmissionRaw\": 5526053, \"acRate\": \"31.7%\"}", + "hints": [ + "How can we reuse a previously computed palindrome to compute a larger palindrome?", + "If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome?", + "Complexity based hint:
\r\nIf we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2) start - end pairs and O(n) palindromic checks. Can we reduce the time for palindromic checks to O(1) by reusing some previous computation." + ], + "solution": { + "id": "34", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "\"babad\"", + "metaData": "{ \n \"name\": \"longestPalindrome\",\n \"params\": [\n { \n \"name\": \"s\",\n \"type\": \"string\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n }\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/longest-substring-without-repeating-characters.html b/算法题/longest-substring-without-repeating-characters.html new file mode 100644 index 00000000..a858df27 --- /dev/null +++ b/算法题/longest-substring-without-repeating-characters.html @@ -0,0 +1,35 @@ +

Given a string s, find the length of the longest substring without repeating characters.

+ +

 

+

Example 1:

+ +
+Input: s = "abcabcbb"
+Output: 3
+Explanation: The answer is "abc", with the length of 3.
+
+ +

Example 2:

+ +
+Input: s = "bbbbb"
+Output: 1
+Explanation: The answer is "b", with the length of 1.
+
+ +

Example 3:

+ +
+Input: s = "pwwkew"
+Output: 3
+Explanation: The answer is "wke", with the length of 3.
+Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= s.length <= 5 * 104
  • +
  • s consists of English letters, digits, symbols and spaces.
  • +
diff --git a/算法题/longest-substring-without-repeating-characters.json b/算法题/longest-substring-without-repeating-characters.json new file mode 100644 index 00000000..bf8a2f5a --- /dev/null +++ b/算法题/longest-substring-without-repeating-characters.json @@ -0,0 +1,178 @@ +{ + "data": { + "question": { + "questionId": "3", + "questionFrontendId": "3", + "boundTopicId": null, + "title": "Longest Substring Without Repeating Characters", + "titleSlug": "longest-substring-without-repeating-characters", + "content": "

Given a string s, find the length of the longest substring without repeating characters.

\n\n

 

\n

Example 1:

\n\n
\nInput: s = "abcabcbb"\nOutput: 3\nExplanation: The answer is "abc", with the length of 3.\n
\n\n

Example 2:

\n\n
\nInput: s = "bbbbb"\nOutput: 1\nExplanation: The answer is "b", with the length of 1.\n
\n\n

Example 3:

\n\n
\nInput: s = "pwwkew"\nOutput: 3\nExplanation: The answer is "wke", with the length of 3.\nNotice that the answer must be a substring, "pwke" is a subsequence and not a substring.\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 0 <= s.length <= 5 * 104
  • \n\t
  • s consists of English letters, digits, symbols and spaces.
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 22406, + "dislikes": 1004, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Longest Substring with At Most Two Distinct Characters\", \"titleSlug\": \"longest-substring-with-at-most-two-distinct-characters\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Longest Substring with At Most K Distinct Characters\", \"titleSlug\": \"longest-substring-with-at-most-k-distinct-characters\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Subarrays with K Different Integers\", \"titleSlug\": \"subarrays-with-k-different-integers\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Maximum Erasure Value\", \"titleSlug\": \"maximum-erasure-value\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Number of Equal Count Substrings\", \"titleSlug\": \"number-of-equal-count-substrings\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", + "exampleTestcases": "\"abcabcbb\"\n\"bbbbb\"\n\"pwwkew\"", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Hash Table", + "slug": "hash-table", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "String", + "slug": "string", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Sliding Window", + "slug": "sliding-window", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int lengthOfLongestSubstring(string s) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int lengthOfLongestSubstring(String s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def lengthOfLongestSubstring(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def lengthOfLongestSubstring(self, s: str) -> int:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint lengthOfLongestSubstring(char * s){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int LengthOfLongestSubstring(string s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string} s\n * @return {number}\n */\nvar lengthOfLongestSubstring = function(s) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String} s\n# @return {Integer}\ndef length_of_longest_substring(s)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func lengthOfLongestSubstring(_ s: String) -> Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func lengthOfLongestSubstring(s string) int {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def lengthOfLongestSubstring(s: String): Int = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun lengthOfLongestSubstring(s: String): Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn length_of_longest_substring(s: String) -> i32 {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String $s\n * @return Integer\n */\n function lengthOfLongestSubstring($s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function lengthOfLongestSubstring(s: string): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (length-of-longest-substring s)\n (-> string? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec length_of_longest_substring(S :: unicode:unicode_binary()) -> integer().\nlength_of_longest_substring(S) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec length_of_longest_substring(s :: String.t) :: integer\n def length_of_longest_substring(s) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"3.1M\", \"totalSubmission\": \"9.4M\", \"totalAcceptedRaw\": 3110121, \"totalSubmissionRaw\": 9439107, \"acRate\": \"32.9%\"}", + "hints": [], + "solution": { + "id": "36", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": true, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "\"abcabcbb\"", + "metaData": "{ \r\n \"name\": \"lengthOfLongestSubstring\",\r\n \"params\": [\r\n { \r\n \"name\": \"s\",\r\n \"type\": \"string\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"integer\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/median-of-two-sorted-arrays.html b/算法题/median-of-two-sorted-arrays.html new file mode 100644 index 00000000..e55f59da --- /dev/null +++ b/算法题/median-of-two-sorted-arrays.html @@ -0,0 +1,32 @@ +

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

+ +

The overall run time complexity should be O(log (m+n)).

+ +

 

+

Example 1:

+ +
+Input: nums1 = [1,3], nums2 = [2]
+Output: 2.00000
+Explanation: merged array = [1,2,3] and median is 2.
+
+ +

Example 2:

+ +
+Input: nums1 = [1,2], nums2 = [3,4]
+Output: 2.50000
+Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
+
+ +

 

+

Constraints:

+ +
    +
  • nums1.length == m
  • +
  • nums2.length == n
  • +
  • 0 <= m <= 1000
  • +
  • 0 <= n <= 1000
  • +
  • 1 <= m + n <= 2000
  • +
  • -106 <= nums1[i], nums2[i] <= 106
  • +
diff --git a/算法题/median-of-two-sorted-arrays.json b/算法题/median-of-two-sorted-arrays.json new file mode 100644 index 00000000..7e78416b --- /dev/null +++ b/算法题/median-of-two-sorted-arrays.json @@ -0,0 +1,171 @@ +{ + "data": { + "question": { + "questionId": "4", + "questionFrontendId": "4", + "boundTopicId": null, + "title": "Median of Two Sorted Arrays", + "titleSlug": "median-of-two-sorted-arrays", + "content": "

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

\n\n

The overall run time complexity should be O(log (m+n)).

\n\n

 

\n

Example 1:

\n\n
\nInput: nums1 = [1,3], nums2 = [2]\nOutput: 2.00000\nExplanation: merged array = [1,2,3] and median is 2.\n
\n\n

Example 2:

\n\n
\nInput: nums1 = [1,2], nums2 = [3,4]\nOutput: 2.50000\nExplanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • nums1.length == m
  • \n\t
  • nums2.length == n
  • \n\t
  • 0 <= m <= 1000
  • \n\t
  • 0 <= n <= 1000
  • \n\t
  • 1 <= m + n <= 2000
  • \n\t
  • -106 <= nums1[i], nums2[i] <= 106
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 15641, + "dislikes": 1936, + "isLiked": null, + "similarQuestions": "[]", + "exampleTestcases": "[1,3]\n[2]\n[1,2]\n[3,4]", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Binary Search", + "slug": "binary-search", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Divide and Conquer", + "slug": "divide-and-conquer", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n double findMedianSortedArrays(vector& nums1, vector& nums2) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public double findMedianSortedArrays(int[] nums1, int[] nums2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def findMedianSortedArrays(self, nums1, nums2):\n \"\"\"\n :type nums1: List[int]\n :type nums2: List[int]\n :rtype: float\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\ndouble findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public double FindMedianSortedArrays(int[] nums1, int[] nums2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} nums1\n * @param {number[]} nums2\n * @return {number}\n */\nvar findMedianSortedArrays = function(nums1, nums2) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} nums1\n# @param {Integer[]} nums2\n# @return {Float}\ndef find_median_sorted_arrays(nums1, nums2)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func findMedianSortedArrays(_ nums1: [Int], _ nums2: [Int]) -> Double {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def findMedianSortedArrays(nums1: Array[Int], nums2: Array[Int]): Double = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn find_median_sorted_arrays(nums1: Vec, nums2: Vec) -> f64 {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $nums1\n * @param Integer[] $nums2\n * @return Float\n */\n function findMedianSortedArrays($nums1, $nums2) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function findMedianSortedArrays(nums1: number[], nums2: number[]): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (find-median-sorted-arrays nums1 nums2)\n (-> (listof exact-integer?) (listof exact-integer?) flonum?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec find_median_sorted_arrays(Nums1 :: [integer()], Nums2 :: [integer()]) -> float().\nfind_median_sorted_arrays(Nums1, Nums2) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec find_median_sorted_arrays(nums1 :: [integer], nums2 :: [integer]) :: float\n def find_median_sorted_arrays(nums1, nums2) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"1.3M\", \"totalSubmission\": \"3.9M\", \"totalAcceptedRaw\": 1312822, \"totalSubmissionRaw\": 3874786, \"acRate\": \"33.9%\"}", + "hints": [], + "solution": null, + "status": null, + "sampleTestCase": "[1,3]\n[2]", + "metaData": "{\r\n \"name\": \"findMedianSortedArrays\",\r\n \"params\": [\r\n {\r\n \"name\": \"nums1\",\r\n \"type\": \"integer[]\"\r\n },\r\n {\r\n \"name\": \"nums2\",\r\n \"type\": \"integer[]\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"double\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/palindrome-number.html b/算法题/palindrome-number.html new file mode 100644 index 00000000..814fbf4c --- /dev/null +++ b/算法题/palindrome-number.html @@ -0,0 +1,42 @@ +

Given an integer x, return true if x is palindrome integer.

+ +

An integer is a palindrome when it reads the same backward as forward.

+ +
    +
  • For example, 121 is a palindrome while 123 is not.
  • +
+ +

 

+

Example 1:

+ +
+Input: x = 121
+Output: true
+Explanation: 121 reads as 121 from left to right and from right to left.
+
+ +

Example 2:

+ +
+Input: x = -121
+Output: false
+Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
+
+ +

Example 3:

+ +
+Input: x = 10
+Output: false
+Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
+
+ +

 

+

Constraints:

+ +
    +
  • -231 <= x <= 231 - 1
  • +
+ +

 

+Follow up: Could you solve it without converting the integer to a string? \ No newline at end of file diff --git a/算法题/palindrome-number.json b/算法题/palindrome-number.json new file mode 100644 index 00000000..f90a476b --- /dev/null +++ b/算法题/palindrome-number.json @@ -0,0 +1,168 @@ +{ + "data": { + "question": { + "questionId": "9", + "questionFrontendId": "9", + "boundTopicId": null, + "title": "Palindrome Number", + "titleSlug": "palindrome-number", + "content": "

Given an integer x, return true if x is palindrome integer.

\n\n

An integer is a palindrome when it reads the same backward as forward.

\n\n
    \n\t
  • For example, 121 is a palindrome while 123 is not.
  • \n
\n\n

 

\n

Example 1:

\n\n
\nInput: x = 121\nOutput: true\nExplanation: 121 reads as 121 from left to right and from right to left.\n
\n\n

Example 2:

\n\n
\nInput: x = -121\nOutput: false\nExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.\n
\n\n

Example 3:

\n\n
\nInput: x = 10\nOutput: false\nExplanation: Reads 01 from right to left. Therefore it is not a palindrome.\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • -231 <= x <= 231 - 1
  • \n
\n\n

 

\nFollow up: Could you solve it without converting the integer to a string?", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Easy", + "likes": 5442, + "dislikes": 2073, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Palindrome Linked List\", \"titleSlug\": \"palindrome-linked-list\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Find Palindrome With Fixed Length\", \"titleSlug\": \"find-palindrome-with-fixed-length\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", + "exampleTestcases": "121\n-121\n10", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Math", + "slug": "math", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n bool isPalindrome(int x) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public boolean isPalindrome(int x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def isPalindrome(self, x):\n \"\"\"\n :type x: int\n :rtype: bool\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def isPalindrome(self, x: int) -> bool:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nbool isPalindrome(int x){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public bool IsPalindrome(int x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number} x\n * @return {boolean}\n */\nvar isPalindrome = function(x) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer} x\n# @return {Boolean}\ndef is_palindrome(x)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func isPalindrome(_ x: Int) -> Bool {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func isPalindrome(x int) bool {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def isPalindrome(x: Int): Boolean = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun isPalindrome(x: Int): Boolean {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn is_palindrome(x: i32) -> bool {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer $x\n * @return Boolean\n */\n function isPalindrome($x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function isPalindrome(x: number): boolean {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (is-palindrome x)\n (-> exact-integer? boolean?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec is_palindrome(X :: integer()) -> boolean().\nis_palindrome(X) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec is_palindrome(x :: integer) :: boolean\n def is_palindrome(x) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"2M\", \"totalSubmission\": \"3.7M\", \"totalAcceptedRaw\": 1950443, \"totalSubmissionRaw\": 3732238, \"acRate\": \"52.3%\"}", + "hints": [ + "Beware of overflow when you reverse the integer." + ], + "solution": { + "id": "233", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "121", + "metaData": "{\r\n \"name\": \"isPalindrome\",\r\n \"params\": [\r\n {\r\n \"name\": \"x\",\r\n \"type\": \"integer\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"boolean\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/regular-expression-matching.html b/算法题/regular-expression-matching.html new file mode 100644 index 00000000..2f73b9fa --- /dev/null +++ b/算法题/regular-expression-matching.html @@ -0,0 +1,44 @@ +

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:

+ +
    +
  • '.' Matches any single character.​​​​
  • +
  • '*' Matches zero or more of the preceding element.
  • +
+ +

The matching should cover the entire input string (not partial).

+ +

 

+

Example 1:

+ +
+Input: s = "aa", p = "a"
+Output: false
+Explanation: "a" does not match the entire string "aa".
+
+ +

Example 2:

+ +
+Input: s = "aa", p = "a*"
+Output: true
+Explanation: '*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".
+
+ +

Example 3:

+ +
+Input: s = "ab", p = ".*"
+Output: true
+Explanation: ".*" means "zero or more (*) of any character (.)".
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 20
  • +
  • 1 <= p.length <= 30
  • +
  • s contains only lowercase English letters.
  • +
  • p contains only lowercase English letters, '.', and '*'.
  • +
  • It is guaranteed for each appearance of the character '*', there will be a previous valid character to match.
  • +
diff --git a/算法题/regular-expression-matching.json b/算法题/regular-expression-matching.json new file mode 100644 index 00000000..b20cc5e9 --- /dev/null +++ b/算法题/regular-expression-matching.json @@ -0,0 +1,178 @@ +{ + "data": { + "question": { + "questionId": "10", + "questionFrontendId": "10", + "boundTopicId": null, + "title": "Regular Expression Matching", + "titleSlug": "regular-expression-matching", + "content": "

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:

\n\n
    \n\t
  • '.' Matches any single character.​​​​
  • \n\t
  • '*' Matches zero or more of the preceding element.
  • \n
\n\n

The matching should cover the entire input string (not partial).

\n\n

 

\n

Example 1:

\n\n
\nInput: s = "aa", p = "a"\nOutput: false\nExplanation: "a" does not match the entire string "aa".\n
\n\n

Example 2:

\n\n
\nInput: s = "aa", p = "a*"\nOutput: true\nExplanation: '*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".\n
\n\n

Example 3:

\n\n
\nInput: s = "ab", p = ".*"\nOutput: true\nExplanation: ".*" means "zero or more (*) of any character (.)".\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 1 <= s.length <= 20
  • \n\t
  • 1 <= p.length <= 30
  • \n\t
  • s contains only lowercase English letters.
  • \n\t
  • p contains only lowercase English letters, '.', and '*'.
  • \n\t
  • It is guaranteed for each appearance of the character '*', there will be a previous valid character to match.
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Hard", + "likes": 7804, + "dislikes": 1143, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Wildcard Matching\", \"titleSlug\": \"wildcard-matching\", \"difficulty\": \"Hard\", \"translatedTitle\": null}]", + "exampleTestcases": "\"aa\"\n\"a\"\n\"aa\"\n\"a*\"\n\"ab\"\n\".*\"", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "String", + "slug": "string", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Dynamic Programming", + "slug": "dynamic-programming", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Recursion", + "slug": "recursion", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n bool isMatch(string s, string p) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public boolean isMatch(String s, String p) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def isMatch(self, s, p):\n \"\"\"\n :type s: str\n :type p: str\n :rtype: bool\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def isMatch(self, s: str, p: str) -> bool:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nbool isMatch(char * s, char * p){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public bool IsMatch(string s, string p) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string} s\n * @param {string} p\n * @return {boolean}\n */\nvar isMatch = function(s, p) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String} s\n# @param {String} p\n# @return {Boolean}\ndef is_match(s, p)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func isMatch(_ s: String, _ p: String) -> Bool {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func isMatch(s string, p string) bool {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def isMatch(s: String, p: String): Boolean = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun isMatch(s: String, p: String): Boolean {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn is_match(s: String, p: String) -> bool {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String $s\n * @param String $p\n * @return Boolean\n */\n function isMatch($s, $p) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function isMatch(s: string, p: string): boolean {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (is-match s p)\n (-> string? string? boolean?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec is_match(S :: unicode:unicode_binary(), P :: unicode:unicode_binary()) -> boolean().\nis_match(S, P) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec is_match(s :: String.t, p :: String.t) :: boolean\n def is_match(s, p) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"660.6K\", \"totalSubmission\": \"2.3M\", \"totalAcceptedRaw\": 660596, \"totalSubmissionRaw\": 2342600, \"acRate\": \"28.2%\"}", + "hints": [], + "solution": { + "id": "238", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "\"aa\"\n\"a\"", + "metaData": "{ \r\n \"name\": \"isMatch\",\r\n \"params\": [\r\n { \r\n \"name\": \"s\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"name\": \"p\",\r\n \"type\": \"string\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"boolean\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/reverse-integer.html b/算法题/reverse-integer.html new file mode 100644 index 00000000..8fd18a67 --- /dev/null +++ b/算法题/reverse-integer.html @@ -0,0 +1,32 @@ +

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

+ +

Assume the environment does not allow you to store 64-bit integers (signed or unsigned).

+ +

 

+

Example 1:

+ +
+Input: x = 123
+Output: 321
+
+ +

Example 2:

+ +
+Input: x = -123
+Output: -321
+
+ +

Example 3:

+ +
+Input: x = 120
+Output: 21
+
+ +

 

+

Constraints:

+ +
    +
  • -231 <= x <= 231 - 1
  • +
diff --git a/算法题/reverse-integer.json b/算法题/reverse-integer.json new file mode 100644 index 00000000..dd5294cf --- /dev/null +++ b/算法题/reverse-integer.json @@ -0,0 +1,166 @@ +{ + "data": { + "question": { + "questionId": "7", + "questionFrontendId": "7", + "boundTopicId": null, + "title": "Reverse Integer", + "titleSlug": "reverse-integer", + "content": "

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

\n\n

Assume the environment does not allow you to store 64-bit integers (signed or unsigned).

\n\n

 

\n

Example 1:

\n\n
\nInput: x = 123\nOutput: 321\n
\n\n

Example 2:

\n\n
\nInput: x = -123\nOutput: -321\n
\n\n

Example 3:

\n\n
\nInput: x = 120\nOutput: 21\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • -231 <= x <= 231 - 1
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 6844, + "dislikes": 9490, + "isLiked": null, + "similarQuestions": "[{\"title\": \"String to Integer (atoi)\", \"titleSlug\": \"string-to-integer-atoi\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Reverse Bits\", \"titleSlug\": \"reverse-bits\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"A Number After a Double Reversal\", \"titleSlug\": \"a-number-after-a-double-reversal\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]", + "exampleTestcases": "123\n-123\n120", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Math", + "slug": "math", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int reverse(int x) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int reverse(int x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def reverse(self, x):\n \"\"\"\n :type x: int\n :rtype: int\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def reverse(self, x: int) -> int:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint reverse(int x){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int Reverse(int x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number} x\n * @return {number}\n */\nvar reverse = function(x) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer} x\n# @return {Integer}\ndef reverse(x)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func reverse(_ x: Int) -> Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func reverse(x int) int {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def reverse(x: Int): Int = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun reverse(x: Int): Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn reverse(x: i32) -> i32 {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer $x\n * @return Integer\n */\n function reverse($x) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function reverse(x: number): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (reverse x)\n (-> exact-integer? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec reverse(X :: integer()) -> integer().\nreverse(X) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec reverse(x :: integer) :: integer\n def reverse(x) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"2M\", \"totalSubmission\": \"7.5M\", \"totalAcceptedRaw\": 1998363, \"totalSubmissionRaw\": 7511957, \"acRate\": \"26.6%\"}", + "hints": [], + "solution": { + "id": "485", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "123", + "metaData": "{\r\n \"name\": \"reverse\",\r\n \"params\": [\r\n {\r\n \"name\": \"x\",\r\n \"type\": \"integer\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"integer\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/string-to-integer-atoi.html b/算法题/string-to-integer-atoi.html new file mode 100644 index 00000000..6530db26 --- /dev/null +++ b/算法题/string-to-integer-atoi.html @@ -0,0 +1,76 @@ +

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).

+ +

The algorithm for myAtoi(string s) is as follows:

+ +
    +
  1. Read in and ignore any leading whitespace.
  2. +
  3. Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
  4. +
  5. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
  6. +
  7. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
  8. +
  9. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
  10. +
  11. Return the integer as the final result.
  12. +
+ +

Note:

+ +
    +
  • Only the space character ' ' is considered a whitespace character.
  • +
  • Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.
  • +
+ +

 

+

Example 1:

+ +
+Input: s = "42"
+Output: 42
+Explanation: The underlined characters are what is read in, the caret is the current reader position.
+Step 1: "42" (no characters read because there is no leading whitespace)
+         ^
+Step 2: "42" (no characters read because there is neither a '-' nor '+')
+         ^
+Step 3: "42" ("42" is read in)
+           ^
+The parsed integer is 42.
+Since 42 is in the range [-231, 231 - 1], the final result is 42.
+
+ +

Example 2:

+ +
+Input: s = "   -42"
+Output: -42
+Explanation:
+Step 1: "   -42" (leading whitespace is read and ignored)
+            ^
+Step 2: "   -42" ('-' is read, so the result should be negative)
+             ^
+Step 3: "   -42" ("42" is read in)
+               ^
+The parsed integer is -42.
+Since -42 is in the range [-231, 231 - 1], the final result is -42.
+
+ +

Example 3:

+ +
+Input: s = "4193 with words"
+Output: 4193
+Explanation:
+Step 1: "4193 with words" (no characters read because there is no leading whitespace)
+         ^
+Step 2: "4193 with words" (no characters read because there is neither a '-' nor '+')
+         ^
+Step 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit)
+             ^
+The parsed integer is 4193.
+Since 4193 is in the range [-231, 231 - 1], the final result is 4193.
+
+ +

 

+

Constraints:

+ +
    +
  • 0 <= s.length <= 200
  • +
  • s consists of English letters (lower-case and upper-case), digits (0-9), ' ', '+', '-', and '.'.
  • +
diff --git a/算法题/string-to-integer-atoi.json b/算法题/string-to-integer-atoi.json new file mode 100644 index 00000000..746faa3d --- /dev/null +++ b/算法题/string-to-integer-atoi.json @@ -0,0 +1,173 @@ +{ + "data": { + "question": { + "questionId": "8", + "questionFrontendId": "8", + "boundTopicId": null, + "title": "String to Integer (atoi)", + "titleSlug": "string-to-integer-atoi", + "content": "

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).

\n\n

The algorithm for myAtoi(string s) is as follows:

\n\n
    \n\t
  1. Read in and ignore any leading whitespace.
  2. \n\t
  3. Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
  4. \n\t
  5. Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
  6. \n\t
  7. Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
  8. \n\t
  9. If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
  10. \n\t
  11. Return the integer as the final result.
  12. \n
\n\n

Note:

\n\n
    \n\t
  • Only the space character ' ' is considered a whitespace character.
  • \n\t
  • Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.
  • \n
\n\n

 

\n

Example 1:

\n\n
\nInput: s = "42"\nOutput: 42\nExplanation: The underlined characters are what is read in, the caret is the current reader position.\nStep 1: "42" (no characters read because there is no leading whitespace)\n         ^\nStep 2: "42" (no characters read because there is neither a '-' nor '+')\n         ^\nStep 3: "42" ("42" is read in)\n           ^\nThe parsed integer is 42.\nSince 42 is in the range [-231, 231 - 1], the final result is 42.\n
\n\n

Example 2:

\n\n
\nInput: s = "   -42"\nOutput: -42\nExplanation:\nStep 1: "   -42" (leading whitespace is read and ignored)\n            ^\nStep 2: "   -42" ('-' is read, so the result should be negative)\n             ^\nStep 3: "   -42" ("42" is read in)\n               ^\nThe parsed integer is -42.\nSince -42 is in the range [-231, 231 - 1], the final result is -42.\n
\n\n

Example 3:

\n\n
\nInput: s = "4193 with words"\nOutput: 4193\nExplanation:\nStep 1: "4193 with words" (no characters read because there is no leading whitespace)\n         ^\nStep 2: "4193 with words" (no characters read because there is neither a '-' nor '+')\n         ^\nStep 3: "4193 with words" ("4193" is read in; reading stops because the next character is a non-digit)\n             ^\nThe parsed integer is 4193.\nSince 4193 is in the range [-231, 231 - 1], the final result is 4193.\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 0 <= s.length <= 200
  • \n\t
  • s consists of English letters (lower-case and upper-case), digits (0-9), ' ', '+', '-', and '.'.
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 1517, + "dislikes": 4332, + "isLiked": null, + "similarQuestions": "[{\"title\": \"Reverse Integer\", \"titleSlug\": \"reverse-integer\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Valid Number\", \"titleSlug\": \"valid-number\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Check if Numbers Are Ascending in a Sentence\", \"titleSlug\": \"check-if-numbers-are-ascending-in-a-sentence\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]", + "exampleTestcases": "\"42\"\n\" -42\"\n\"4193 with words\"", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "String", + "slug": "string", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n int myAtoi(string s) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int myAtoi(String s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def myAtoi(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def myAtoi(self, s: str) -> int:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nint myAtoi(char * s){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int MyAtoi(string s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string} s\n * @return {number}\n */\nvar myAtoi = function(s) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String} s\n# @return {Integer}\ndef my_atoi(s)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func myAtoi(_ s: String) -> Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func myAtoi(s string) int {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def myAtoi(s: String): Int = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun myAtoi(s: String): Int {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn my_atoi(s: String) -> i32 {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String $s\n * @return Integer\n */\n function myAtoi($s) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function myAtoi(s: string): number {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (my-atoi s)\n (-> string? exact-integer?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec my_atoi(S :: unicode:unicode_binary()) -> integer().\nmy_atoi(S) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec my_atoi(s :: String.t) :: integer\n def my_atoi(s) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"969.3K\", \"totalSubmission\": \"5.9M\", \"totalAcceptedRaw\": 969291, \"totalSubmissionRaw\": 5879000, \"acRate\": \"16.5%\"}", + "hints": [], + "solution": { + "id": "1290", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "\"42\"", + "metaData": "{\n \"name\": \"myAtoi\",\n \"params\": [\n {\n \"name\": \"s\",\n \"type\": \"string\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n }\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": { + "id": "774", + "date": "2022-01-14", + "incompleteChallengeCount": 0, + "streakCount": 0, + "type": "DAILY", + "__typename": "ChallengeQuestionNode" + }, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/two-sum.html b/算法题/two-sum.html new file mode 100644 index 00000000..0803f248 --- /dev/null +++ b/算法题/two-sum.html @@ -0,0 +1,41 @@ +

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

+ +

You may assume that each input would have exactly one solution, and you may not use the same element twice.

+ +

You can return the answer in any order.

+ +

 

+

Example 1:

+ +
+Input: nums = [2,7,11,15], target = 9
+Output: [0,1]
+Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
+
+ +

Example 2:

+ +
+Input: nums = [3,2,4], target = 6
+Output: [1,2]
+
+ +

Example 3:

+ +
+Input: nums = [3,3], target = 6
+Output: [0,1]
+
+ +

 

+

Constraints:

+ +
    +
  • 2 <= nums.length <= 104
  • +
  • -109 <= nums[i] <= 109
  • +
  • -109 <= target <= 109
  • +
  • Only one valid answer exists.
  • +
+ +

 

+Follow-up: Can you come up with an algorithm that is less than O(n2time complexity? \ No newline at end of file diff --git a/算法题/two-sum.json b/算法题/two-sum.json new file mode 100644 index 00000000..d4072933 --- /dev/null +++ b/算法题/two-sum.json @@ -0,0 +1,176 @@ +{ + "data": { + "question": { + "questionId": "1", + "questionFrontendId": "1", + "boundTopicId": null, + "title": "Two Sum", + "titleSlug": "two-sum", + "content": "

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

\n\n

You may assume that each input would have exactly one solution, and you may not use the same element twice.

\n\n

You can return the answer in any order.

\n\n

 

\n

Example 1:

\n\n
\nInput: nums = [2,7,11,15], target = 9\nOutput: [0,1]\nExplanation: Because nums[0] + nums[1] == 9, we return [0, 1].\n
\n\n

Example 2:

\n\n
\nInput: nums = [3,2,4], target = 6\nOutput: [1,2]\n
\n\n

Example 3:

\n\n
\nInput: nums = [3,3], target = 6\nOutput: [0,1]\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 2 <= nums.length <= 104
  • \n\t
  • -109 <= nums[i] <= 109
  • \n\t
  • -109 <= target <= 109
  • \n\t
  • Only one valid answer exists.
  • \n
\n\n

 

\nFollow-up: Can you come up with an algorithm that is less than O(n2time complexity?", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Easy", + "likes": 30567, + "dislikes": 960, + "isLiked": null, + "similarQuestions": "[{\"title\": \"3Sum\", \"titleSlug\": \"3sum\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"4Sum\", \"titleSlug\": \"4sum\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Two Sum II - Input Array Is Sorted\", \"titleSlug\": \"two-sum-ii-input-array-is-sorted\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Two Sum III - Data structure design\", \"titleSlug\": \"two-sum-iii-data-structure-design\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Subarray Sum Equals K\", \"titleSlug\": \"subarray-sum-equals-k\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Two Sum IV - Input is a BST\", \"titleSlug\": \"two-sum-iv-input-is-a-bst\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Two Sum Less Than K\", \"titleSlug\": \"two-sum-less-than-k\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Max Number of K-Sum Pairs\", \"titleSlug\": \"max-number-of-k-sum-pairs\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Count Good Meals\", \"titleSlug\": \"count-good-meals\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Count Number of Pairs With Absolute Difference K\", \"titleSlug\": \"count-number-of-pairs-with-absolute-difference-k\", \"difficulty\": \"Easy\", \"translatedTitle\": null}, {\"title\": \"Number of Pairs of Strings With Concatenation Equal to Target\", \"titleSlug\": \"number-of-pairs-of-strings-with-concatenation-equal-to-target\", \"difficulty\": \"Medium\", \"translatedTitle\": null}, {\"title\": \"Find All K-Distant Indices in an Array\", \"titleSlug\": \"find-all-k-distant-indices-in-an-array\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]", + "exampleTestcases": "[2,7,11,15]\n9\n[3,2,4]\n6\n[3,3]\n6", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "Array", + "slug": "array", + "translatedName": null, + "__typename": "TopicTagNode" + }, + { + "name": "Hash Table", + "slug": "hash-table", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n vector twoSum(vector& nums, int target) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public int[] twoSum(int[] nums, int target) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* twoSum(int* nums, int numsSize, int target, int* returnSize){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public int[] TwoSum(int[] nums, int target) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number[]}\n */\nvar twoSum = function(nums, target) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {Integer[]} nums\n# @param {Integer} target\n# @return {Integer[]}\ndef two_sum(nums, target)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func twoSum(_ nums: [Int], _ target: Int) -> [Int] {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func twoSum(nums []int, target int) []int {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def twoSum(nums: Array[Int], target: Int): Array[Int] = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun twoSum(nums: IntArray, target: Int): IntArray {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn two_sum(nums: Vec, target: i32) -> Vec {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param Integer[] $nums\n * @param Integer $target\n * @return Integer[]\n */\n function twoSum($nums, $target) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function twoSum(nums: number[], target: number): number[] {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (two-sum nums target)\n (-> (listof exact-integer?) exact-integer? (listof exact-integer?))\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec two_sum(Nums :: [integer()], Target :: integer()) -> [integer()].\ntwo_sum(Nums, Target) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec two_sum(nums :: [integer], target :: integer) :: [integer]\n def two_sum(nums, target) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"6.3M\", \"totalSubmission\": \"12.9M\", \"totalAcceptedRaw\": 6255676, \"totalSubmissionRaw\": 12924890, \"acRate\": \"48.4%\"}", + "hints": [ + "A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It is from these brute force solutions that you can come up with optimizations.", + "So, if we fix one of the numbers, say
x
, we have to scan the entire array to find the next number
y
which is
value - x
where value is the input parameter. Can we change our array somehow so that this search becomes faster?", + "The second train of thought is, without changing the array, can we use additional space somehow? Like maybe a hash map to speed up the search?" + ], + "solution": { + "id": "7", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": true, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "[2,7,11,15]\n9", + "metaData": "{\n \"name\": \"twoSum\",\n \"params\": [\n {\n \"name\": \"nums\",\n \"type\": \"integer[]\"\n },\n {\n \"name\": \"target\",\n \"type\": \"integer\"\n }\n ],\n \"return\": {\n \"type\": \"integer[]\",\n \"size\": 2\n },\n \"manual\": false\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file diff --git a/算法题/zigzag-conversion.html b/算法题/zigzag-conversion.html new file mode 100644 index 00000000..77784e88 --- /dev/null +++ b/算法题/zigzag-conversion.html @@ -0,0 +1,51 @@ +

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

+ +
+P   A   H   N
+A P L S I I G
+Y   I   R
+
+ +

And then read line by line: "PAHNAPLSIIGYIR"

+ +

Write the code that will take a string and make this conversion given a number of rows:

+ +
+string convert(string s, int numRows);
+
+ +

 

+

Example 1:

+ +
+Input: s = "PAYPALISHIRING", numRows = 3
+Output: "PAHNAPLSIIGYIR"
+
+ +

Example 2:

+ +
+Input: s = "PAYPALISHIRING", numRows = 4
+Output: "PINALSIGYAHRPI"
+Explanation:
+P     I    N
+A   L S  I G
+Y A   H R
+P     I
+
+ +

Example 3:

+ +
+Input: s = "A", numRows = 1
+Output: "A"
+
+ +

 

+

Constraints:

+ +
    +
  • 1 <= s.length <= 1000
  • +
  • s consists of English letters (lower-case and upper-case), ',' and '.'.
  • +
  • 1 <= numRows <= 1000
  • +
diff --git a/算法题/zigzag-conversion.json b/算法题/zigzag-conversion.json new file mode 100644 index 00000000..86867c13 --- /dev/null +++ b/算法题/zigzag-conversion.json @@ -0,0 +1,166 @@ +{ + "data": { + "question": { + "questionId": "6", + "questionFrontendId": "6", + "boundTopicId": null, + "title": "Zigzag Conversion", + "titleSlug": "zigzag-conversion", + "content": "

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

\n\n
\nP   A   H   N\nA P L S I I G\nY   I   R\n
\n\n

And then read line by line: "PAHNAPLSIIGYIR"

\n\n

Write the code that will take a string and make this conversion given a number of rows:

\n\n
\nstring convert(string s, int numRows);\n
\n\n

 

\n

Example 1:

\n\n
\nInput: s = "PAYPALISHIRING", numRows = 3\nOutput: "PAHNAPLSIIGYIR"\n
\n\n

Example 2:

\n\n
\nInput: s = "PAYPALISHIRING", numRows = 4\nOutput: "PINALSIGYAHRPI"\nExplanation:\nP     I    N\nA   L S  I G\nY A   H R\nP     I\n
\n\n

Example 3:

\n\n
\nInput: s = "A", numRows = 1\nOutput: "A"\n
\n\n

 

\n

Constraints:

\n\n
    \n\t
  • 1 <= s.length <= 1000
  • \n\t
  • s consists of English letters (lower-case and upper-case), ',' and '.'.
  • \n\t
  • 1 <= numRows <= 1000
  • \n
\n", + "translatedTitle": null, + "translatedContent": null, + "isPaidOnly": false, + "difficulty": "Medium", + "likes": 3496, + "dislikes": 8093, + "isLiked": null, + "similarQuestions": "[]", + "exampleTestcases": "\"PAYPALISHIRING\"\n3\n\"PAYPALISHIRING\"\n4\n\"A\"\n1", + "categoryTitle": "Algorithms", + "contributors": [], + "topicTags": [ + { + "name": "String", + "slug": "string", + "translatedName": null, + "__typename": "TopicTagNode" + } + ], + "companyTagStats": null, + "codeSnippets": [ + { + "lang": "C++", + "langSlug": "cpp", + "code": "class Solution {\npublic:\n string convert(string s, int numRows) {\n \n }\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Java", + "langSlug": "java", + "code": "class Solution {\n public String convert(String s, int numRows) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python", + "langSlug": "python", + "code": "class Solution(object):\n def convert(self, s, numRows):\n \"\"\"\n :type s: str\n :type numRows: int\n :rtype: str\n \"\"\"\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Python3", + "langSlug": "python3", + "code": "class Solution:\n def convert(self, s: str, numRows: int) -> str:\n ", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C", + "langSlug": "c", + "code": "\n\nchar * convert(char * s, int numRows){\n\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "C#", + "langSlug": "csharp", + "code": "public class Solution {\n public string Convert(string s, int numRows) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "JavaScript", + "langSlug": "javascript", + "code": "/**\n * @param {string} s\n * @param {number} numRows\n * @return {string}\n */\nvar convert = function(s, numRows) {\n \n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Ruby", + "langSlug": "ruby", + "code": "# @param {String} s\n# @param {Integer} num_rows\n# @return {String}\ndef convert(s, num_rows)\n \nend", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Swift", + "langSlug": "swift", + "code": "class Solution {\n func convert(_ s: String, _ numRows: Int) -> String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Go", + "langSlug": "golang", + "code": "func convert(s string, numRows int) string {\n \n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Scala", + "langSlug": "scala", + "code": "object Solution {\n def convert(s: String, numRows: Int): String = {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Kotlin", + "langSlug": "kotlin", + "code": "class Solution {\n fun convert(s: String, numRows: Int): String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Rust", + "langSlug": "rust", + "code": "impl Solution {\n pub fn convert(s: String, num_rows: i32) -> String {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "PHP", + "langSlug": "php", + "code": "class Solution {\n\n /**\n * @param String $s\n * @param Integer $numRows\n * @return String\n */\n function convert($s, $numRows) {\n \n }\n}", + "__typename": "CodeSnippetNode" + }, + { + "lang": "TypeScript", + "langSlug": "typescript", + "code": "function convert(s: string, numRows: number): string {\n\n};", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Racket", + "langSlug": "racket", + "code": "(define/contract (convert s numRows)\n (-> string? exact-integer? string?)\n\n )", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Erlang", + "langSlug": "erlang", + "code": "-spec convert(S :: unicode:unicode_binary(), NumRows :: integer()) -> unicode:unicode_binary().\nconvert(S, NumRows) ->\n .", + "__typename": "CodeSnippetNode" + }, + { + "lang": "Elixir", + "langSlug": "elixir", + "code": "defmodule Solution do\n @spec convert(s :: String.t, num_rows :: integer) :: String.t\n def convert(s, num_rows) do\n\n end\nend", + "__typename": "CodeSnippetNode" + } + ], + "stats": "{\"totalAccepted\": \"736.4K\", \"totalSubmission\": \"1.8M\", \"totalAcceptedRaw\": 736353, \"totalSubmissionRaw\": 1784897, \"acRate\": \"41.3%\"}", + "hints": [], + "solution": { + "id": "484", + "canSeeDetail": true, + "paidOnly": false, + "hasVideoSolution": false, + "paidOnlyVideo": true, + "__typename": "ArticleNode" + }, + "status": null, + "sampleTestCase": "\"PAYPALISHIRING\"\n3", + "metaData": "{\r\n \"name\": \"convert\",\r\n \"params\": [\r\n {\r\n \"name\": \"s\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"name\": \"numRows\",\r\n \"type\": \"integer\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"string\"\r\n }\r\n}", + "judgerAvailable": true, + "judgeType": "large", + "mysqlSchemas": [], + "enableRunCode": true, + "enableTestMode": false, + "enableDebugger": true, + "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17 . Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"c\": [\"C\", \"

Compiled with gcc 8.2 using the gnu99 standard.

\\r\\n\\r\\n

Your code is compiled with level one optimization (-O1). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n\\r\\n

For hash table operations, you may use uthash. \\\"uthash.h\\\" is included by default. Below are some examples:

\\r\\n\\r\\n

1. Adding an item to a hash.\\r\\n

\\r\\nstruct hash_entry {\\r\\n    int id;            /* we'll use this field as the key */\\r\\n    char name[10];\\r\\n    UT_hash_handle hh; /* makes this structure hashable */\\r\\n};\\r\\n\\r\\nstruct hash_entry *users = NULL;\\r\\n\\r\\nvoid add_user(struct hash_entry *s) {\\r\\n    HASH_ADD_INT(users, id, s);\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

2. Looking up an item in a hash:\\r\\n

\\r\\nstruct hash_entry *find_user(int user_id) {\\r\\n    struct hash_entry *s;\\r\\n    HASH_FIND_INT(users, &user_id, s);\\r\\n    return s;\\r\\n}\\r\\n
\\r\\n

\\r\\n\\r\\n

3. Deleting an item in a hash:\\r\\n

\\r\\nvoid delete_user(struct hash_entry *user) {\\r\\n    HASH_DEL(users, user);  \\r\\n}\\r\\n
\\r\\n

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\\r\\n\\r\\n

Your code is compiled with debug flag enabled (/debug).

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

\\r\\n\\r\\n

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

\\r\\n\\r\\n

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"rust\": [\"Rust\", \"

Rust 1.58.1

\\r\\n\\r\\n

Supports rand v0.6\\u00a0from crates.io

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"], \"racket\": [\"Racket\", \"

Run with Racket 8.3.

\"], \"erlang\": [\"Erlang\", \"Erlang/OTP 24.2\"], \"elixir\": [\"Elixir\", \"Elixir 1.13.0 with Erlang/OTP 24.2\"]}", + "libraryUrl": null, + "adminUrl": null, + "challengeQuestion": null, + "__typename": "QuestionNode" + } + } +} \ No newline at end of file