-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion.json
More file actions
2 lines (1 loc) · 7.64 KB
/
question.json
File metadata and controls
2 lines (1 loc) · 7.64 KB
1
2
{'questionId': '1', 'questionFrontendId': '1', 'title': 'Two Sum', 'content': '<p>Given an array of integers <code>nums</code> and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>\n\n<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> element twice.</p>\n\n<p>You can return the answer in any order.</p>\n\n<p> </p>\n<p><strong class="example">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,7,11,15], target = 9\n<strong>Output:</strong> [0,1]\n<strong>Explanation:</strong> Because nums[0] + nums[1] == 9, we return [0, 1].\n</pre>\n\n<p><strong class="example">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,2,4], target = 6\n<strong>Output:</strong> [1,2]\n</pre>\n\n<p><strong class="example">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,3], target = 6\n<strong>Output:</strong> [0,1]\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 <= nums.length <= 10<sup>4</sup></code></li>\n\t<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>\n\t<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>\n\t<li><strong>Only one valid answer exists.</strong></li>\n</ul>\n\n<p> </p>\n<strong>Follow-up: </strong>Can you come up with an algorithm that is less than <code>O(n<sup>2</sup>)</code><font face="monospace"> </font>time complexity?', 'difficulty': 'Easy', 'categoryTitle': 'Algorithms', 'codeSnippets': [{'lang': 'C++', 'langSlug': 'cpp', 'code': 'class Solution {\npublic:\n vector<int> twoSum(vector<int>& nums, int target) {\n \n }\n};'}, {'lang': 'Java', 'langSlug': 'java', 'code': 'class Solution {\n public int[] twoSum(int[] nums, int target) {\n \n }\n}'}, {'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 '}, {'lang': 'Python3', 'langSlug': 'python3', 'code': 'class Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n '}, {'lang': 'C', 'langSlug': 'c', 'code': '/**\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}'}, {'lang': 'C#', 'langSlug': 'csharp', 'code': 'public class Solution {\n public int[] TwoSum(int[] nums, int target) {\n \n }\n}'}, {'lang': 'JavaScript', 'langSlug': 'javascript', 'code': '/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number[]}\n */\nvar twoSum = function(nums, target) {\n \n};'}, {'lang': 'TypeScript', 'langSlug': 'typescript', 'code': 'function twoSum(nums: number[], target: number): number[] {\n \n};'}, {'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}'}, {'lang': 'Swift', 'langSlug': 'swift', 'code': 'class Solution {\n func twoSum(_ nums: [Int], _ target: Int) -> [Int] {\n \n }\n}'}, {'lang': 'Kotlin', 'langSlug': 'kotlin', 'code': 'class Solution {\n fun twoSum(nums: IntArray, target: Int): IntArray {\n \n }\n}'}, {'lang': 'Dart', 'langSlug': 'dart', 'code': 'class Solution {\n List<int> twoSum(List<int> nums, int target) {\n \n }\n}'}, {'lang': 'Go', 'langSlug': 'golang', 'code': 'func twoSum(nums []int, target int) []int {\n \n}'}, {'lang': 'Ruby', 'langSlug': 'ruby', 'code': '# @param {Integer[]} nums\n# @param {Integer} target\n# @return {Integer[]}\ndef two_sum(nums, target)\n \nend'}, {'lang': 'Scala', 'langSlug': 'scala', 'code': 'object Solution {\n def twoSum(nums: Array[Int], target: Int): Array[Int] = {\n \n }\n}'}, {'lang': 'Rust', 'langSlug': 'rust', 'code': 'impl Solution {\n pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {\n \n }\n}'}, {'lang': 'Racket', 'langSlug': 'racket', 'code': '(define/contract (two-sum nums target)\n (-> (listof exact-integer?) exact-integer? (listof exact-integer?))\n )'}, {'lang': 'Erlang', 'langSlug': 'erlang', 'code': '-spec two_sum(Nums :: [integer()], Target :: integer()) -> [integer()].\ntwo_sum(Nums, Target) ->\n .'}, {'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'}], 'exampleTestcases': '[2,7,11,15]\n9\n[3,2,4]\n6\n[3,3]\n6', '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}, {"title": "First Letter to Appear Twice", "titleSlug": "first-letter-to-appear-twice", "difficulty": "Easy", "translatedTitle": null}, {"title": "Number of Excellent Pairs", "titleSlug": "number-of-excellent-pairs", "difficulty": "Hard", "translatedTitle": null}, {"title": "Number of Arithmetic Triplets", "titleSlug": "number-of-arithmetic-triplets", "difficulty": "Easy", "translatedTitle": null}, {"title": "Node With Highest Edge Score", "titleSlug": "node-with-highest-edge-score", "difficulty": "Medium", "translatedTitle": null}, {"title": "Check Distances Between Same Letters", "titleSlug": "check-distances-between-same-letters", "difficulty": "Easy", "translatedTitle": null}, {"title": "Find Subarrays With Equal Sum", "titleSlug": "find-subarrays-with-equal-sum", "difficulty": "Easy", "translatedTitle": null}, {"title": "Largest Positive Integer That Exists With Its Negative", "titleSlug": "largest-positive-integer-that-exists-with-its-negative", "difficulty": "Easy", "translatedTitle": null}, {"title": "Number of Distinct Averages", "titleSlug": "number-of-distinct-averages", "difficulty": "Easy", "translatedTitle": null}, {"title": "Count Pairs Whose Sum is Less than Target", "titleSlug": "count-pairs-whose-sum-is-less-than-target", "difficulty": "Easy", "translatedTitle": null}]', 'topicTags': [{'name': 'Array', 'slug': 'array'}, {'name': 'Hash Table', 'slug': 'hash-table'}]}