You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<
8000
script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"fileTree":{"algorithms/cpp/twoSum":{"items":[{"name":"twoSum.II.cpp","path":"algorithms/cpp/twoSum/twoSum.II.cpp","contentType":"file"},{"name":"twoSum.III.cpp","path":"algorithms/cpp/twoSum/twoSum.III.cpp","contentType":"file"},{"name":"twoSum.cpp","path":"algorithms/cpp/twoSum/twoSum.cpp","contentType":"file"}],"totalCount":3},"algorithms/cpp":{"items":[{"name":"3Sum","path":"algorithms/cpp/3Sum","contentType":"directory"},{"name":"3SumClosest","path":"algorithms/cpp/3SumClosest","contentType":"directory"},{"name":"4Sum","path":"algorithms/cpp/4Sum","contentType":"directory"},{"name":"LRUCache","path":"algorithms/cpp/LRUCache","contentType":"directory"},{"name":"addAndSearchWord","path":"algorithms/cpp/addAndSearchWord","contentType":"directory"},{"name":"addBinary","path":"algorithms/cpp/addBinary","contentType":"directory"},{"name":"addDigits","path":"algorithms/cpp/addDigits","contentType":"directory"},{"name":"addTwoNumbers","path":"algorithms/cpp/addTwoNumbers","contentType":"directory"},{"name":"additiveNumber","path":"algorithms/cpp/additiveNumber","contentType":"directory"},{"name":"anagrams","path":"algorithms/cpp/anagrams","contentType":"directory"},{"name":"balancedBinaryTree","path":"algorithms/cpp/balancedBinaryTree","contentType":"directory"},{"name":"basicCalculator","path":"algorithms/cpp/basicCalculator","contentType":"directory"},{"name":"bestTimeToBuyAndSellStock","path":"algorithms/cpp/bestTimeToBuyAndSellStock","contentType":"directory"},{"name":"binarySearchTreeIterator","path":"algorithms/cpp/binarySearchTreeIterator","contentType":"directory"},{"name":"binaryTreeInorderTraversal","path":"algorithms/cpp/binaryTreeInorderTraversal","contentType":"directory"},{"name":"binaryTreeLevelOrderTraversal","path":"algorithms/cpp/binaryTreeLevelOrderTraversal","contentType":"directory"},{"name":"binaryTreeMaximumPathSum","path":"algorithms/cpp/binaryTreeMaximumPathSum","contentType":"directory"},{"name":"binaryTreePaths","path":"algorithms/cpp/binaryTreePaths","contentType":"directory"},{"name":"binaryTreePostorderTraversal","path":"algorithms/cpp/binaryTreePostorderTraversal","contentType":"directory"},{"name":"binaryTreePreorderTraversal","path":"algorithms/cpp/binaryTreePreorderTraversal","contentType":"directory"},{"name":"binaryTreeRightSideView","path":"algorithms/cpp/binaryTreeRightSideView","contentType":"directory"},{"name":"binaryTreeUpsideDown","path":"algorithms/cpp/binaryTreeUpsideDown","contentType":"directory"},{"name":"binaryTreeZigzagLevelOrderTraversal","path":"algorithms/cpp/binaryTreeZigzagLevelOrderTraversal","contentType":"directory"},{"name":"bitwiseANDOfNumbersRange","path":"algorithms/cpp/bitwiseANDOfNumbersRange","contentType":"directory"},{"name":"bulbSwitcher","path":"algorithms/cpp/bulbSwitcher","contentType":"directory"},{"name":"bullsAndCows","path":"algorithms/cpp/bullsAndCows","contentType":"directory"},{"name":"burstBalloons","path":"algorithms/cpp/burstBalloons","contentType":"directory"},{"name":"candy","path":"algorithms/cpp/candy","contentType":"directory"},{"name":"climbStairs","path":"algorithms/cpp/climbStairs","contentType":"directory"},{"name":"cloneGraph","path":"algorithms/cpp/cloneGraph","contentType":"directory"},{"name":"coinChange","path":"algorithms/cpp/coinChange","contentType":"directory"},{"name":"combinationSum","path":"algorithms/cpp/combinationSum","contentType":"directory"},{"name":"combinations","path":"algorithms/cpp/combinations","contentType":"directory"},{"name":"compareVersionNumbers","path":"algorithms/cpp/compareVersionNumbers","contentType":"directory"},{"name":"constructBinaryTreeFromInorderAndPostorderTraversal","path":"algorithms/cpp/constructBinaryTreeFromInorderAndPostorderTraversal","contentType":"directory"},{"name":"constructBinaryTreeFromPreorderAndInorderTraversal","path":"algorithms/cpp/constructBinaryTreeFromPreorderAndInorderTraversal","contentType":"directory"},{"name":"containerWithMostWater","path":"algorithms/cpp/containerWithMostWater","contentType":"directory"},{"name":"containsDuplicate","path":"algorithms/cpp/containsDuplicate","contentType":"directory"},{"name":"convertSortedArrayToBinarySearchTree","path":"algorithms/cpp/convertSortedArrayToBinarySearchTree","contentType":"directory"},{"name":"convertSortedListToBinarySearchTree","path":"algorithms/cpp/convertSortedListToBinarySearchTree","contentType":"directory"},{"name":"copyListWithRandomPointer","path":"algorithms/cpp/copyListWithRandomPointer","contentType":"directory"},{"name":"countAndSay","path":"algorithms/cpp/countAndSay","contentType":"directory"},{"name":"countCompleteTreeNodes","path":"algorithms/cpp/countCompleteTreeNodes","contentType":"directory"},{"name":"countOfRangeSum","path":"algorithms/cpp/countOfRangeSum","contentType":"directory"},{"name":"countOfSmallerNumbersAfterSelf","path":"algorithms/cpp/countOfSmallerNumbersAfterSelf","contentType":"directory"},{"name":"countPrimes","path":"algorithms/cpp/countPrimes","contentType":"directory"},{"name":"countingBits","path":"algorithms/cpp/countingBits","contentType":"directory"},{"name":"courseSchedule","path":"algorithms/cpp/courseSchedule","contentType":"directory"},{"name":"createMaximumNumber","path":"algorithms/cpp/createMaximumNumber","contentType":"directory"},{"name":"decodeWays","path":"algorithms/cpp/decodeWays","contentType":"directory"},{"name":"deleteNodeInALinkedList","path":"algorithms/cpp/deleteNodeInALinkedList","contentType":"directory"},{"name":"differentWaysToAddParentheses","path":"algorithms/cpp/differentWaysToAddParentheses","contentType":"directory"},{"name":"distinctSubsequences","path":"algorithms/cpp/distinctSubsequences","contentType":"directory"},{"name":"divideTwoInt","path":"algorithms/cpp/divideTwoInt","contentType":"directory"},{"name":"dungeonGame","path":"algorithms/cpp/dungeonGame","contentType":"directory"},{"name":"editDistance","path":"algorithms/cpp/editDistance","contentType":"directory"},{"name":"evaluateReversePolishNotation","path":"algorithms/cpp/evaluateReversePolishNotation","contentType":"directory"},{"name":"excelSheetColumnNumber","path":"algorithms/cpp/excelSheetColumnNumber","contentType":"directory"},{"name":"excelSheetColumnTitle","path":"algorithms/cpp/excelSheetColumnTitle","contentType":"directory"},{"name":"expressionAddOperators","path":"algorithms/cpp/expressionAddOperators","contentType":"directory"},{"name":"factorialTrailingZeroes","path":"algorithms/cpp/factorialTrailingZeroes","contentType":"directory"},{"name":"findMedianFromDataStream","path":"algorithms/cpp/findMedianFromDataStream","contentType":"directory"},{"name":"findMinimumInRotatedSortedArray","path":"algorithms/cpp/findMinimumInRotatedSortedArray","contentType":"directory"},{"name":"findPeakElement","path":"algorithms/cpp/findPeakElement","contentType":"directory"},{"name":"findTheDuplicateNumber","path":"algorithms/cpp/findTheDuplicateNumber","contentType":"directory"},{"name":"firstBadVersion","path":"algorithms/cpp/firstBadVersion","contentType":"directory"},{"name":"firstMissingPositive","path":"algorithms/cpp/firstMissingPositive","contentType":"directory"},{"name":"flattenBinaryTreeToLinkedList","path":"algorithms/cpp/flattenBinaryTreeToLinkedList","contentType":"directory"},{"name":"flattenNestedListIterator","path":"algorithms/cpp/flattenNestedListIterator","contentType":"directory"},{"name":"fractionToRecurringDecimal","path":"algorithms/cpp/fractionToRecurringDecimal","contentType":"directory"},{"name":"gasStation","path":"algorithms/cpp/gasStation","contentType":"directory"},{"name":"generateParentheses","path":"algorithms/cpp/generateParentheses","contentType":"directory"},{"name":"grayCode","path":"algorithms/cpp/grayCode","contentType":"directory"},{"name":"h-Index","path":"algorithms/cpp/h-Index","contentType":"directory"},{"name":"happyNumber","path":"algorithms/cpp/happyNumber","contentType":"directory"},{"name":"houseRobber","path":"algorithms/cpp/houseRobber","contentType":"directory"},{"name":"implementQueueUsingStacks","path":"algorithms/cpp/implementQueueUsingStacks","contentType":"directory"},{"name":"implementStackUsingQueues","path":"algorithms/cpp/implementStackUsingQueues","contentType":"directory"},{"name":"implementTriePrefixTree","path":"algorithms/cpp/implementTriePrefixTree","contentType":"directory"},{"name":"increasingTripletSubsequence","path":"algorithms/cpp/increasingTripletSubsequence","contentType":"directory"},{"name":"insertInterval","path":"algorithms/cpp/insertInterval","contentType":"directory"},{"name":"insertionSortList","path":"algorithms/cpp/insertionSortList","contentType":"directory"},{"name":"integerBreak","path":"algorithms/cpp/integerBreak","contentType":"directory"},{"name":"integerToEnglishWords","path":"algorithms/cpp/integerToEnglishWords","contentType":"directory"},{"name":"integerToRoman","path":"algorithms/cpp/integerToRoman","contentType":"directory"},{"name":"interleavingString","path":"algorithms/cpp/interleavingString","contentType":"directory"},{"name":"intersectionOfTwoArrays","path":"algorithms/cpp/intersectionOfTwoArrays","contentType":"directory"},{"name":"intersectionOfTwoArraysII","path":"algorithms/cpp/intersectionOfTwoArraysII","contentType":"directory"},{"name":"intersectionOfTwoLinkedLists","path":"algorithms/cpp/intersectionOfTwoLinkedLists","contentType":"directory"},{"name":"invertBinaryTree","path":"algorithms/cpp/invertBinaryTree","contentType":"directory"},{"name":"isomorphicStrings","path":"algorithms/cpp/isomorphicStrings","contentType":"directory"},{"name":"jumpGame","path":"algorithms/cpp/jumpGame","contentType":"directory"},{"name":"kthLargestElementInAnArray","path":"algorithms/cpp/kthLargestElementInAnArray","contentType":"directory"},{"name":"kthSmallestElementInaBST","path":"algorithms/cpp/kthSmallestElementInaBST","contentType":"directory"},{"name":"largestNumber","path":"algorithms/cpp/largestNumber","contentType":"directory"},{"name":"largestRectangleInHistogram","path":"algorithms/cpp/largestRectangleInHistogram","contentType":"directory"},{"name":"lengthOfLastWord","path":"algorithms/cpp/lengthOfLastWord","contentType":"directory"},{"name":"letterCombinationsOfAPhoneNumber","path":"algorithms/cpp/letterCombinationsOfAPhoneNumber","contentType":"directory"},{"name":"linkedListCycle","path":"algorithms/cpp/linkedListCycle","contentType":"directory"},{"name":"longestCommonPrefix","path":"algorithms/cpp/longestCommonPrefix","contentType":"directory"},{"name":"longestConsecutiveSequence","path":"algorithms/cpp/longestConsecutiveSequence","contentType":"directory"},{"name":"longestIncreasingPathInAMatrix","path":"algorithms/cpp/longestIncreasingPathInAMatrix","contentType":"directory"},{"name":"longestIncreasingSubsequence","path":"algorithms/cpp/longestIncreasingSubsequence","contentType":"directory"},{"name":"longestPalindromicSubstring","path":"algorithms/cpp/longestPalindromicSubstring","contentType":"directory"},{"name":"longestSubstringWithAtMostTwoDistinctCharacters","path":"algorithms/cpp/longestSubstringWithAtMostTwoDistinctCharacters","contentType":"directory"},{"name":"longestSubstringWithoutRepeatingCharacters","path":"algorithms/cpp/longestSubstringWithoutRepeatingCharacters","contentType":"directory"},{"name":"longestValidParentheses","path":"algorithms/cpp/longestValidParentheses","contentType":"directory"},{"name":"lowestCommonAncestorOfABinarySearchTree","path":"algorithms/cpp/lowestCommonAncestorOfABinarySearchTree","contentType":"directory"},{"name":"lowestCommonAncestorOfABinaryTree","path":"algorithms/cpp/lowestCommonAncestorOfABinaryTree","contentType":"directory"},{"name":"majorityElement","path":"algorithms/cpp/majorityElement","contentType":"directory"},{"name":"maxPointsOnALine","path":"algorithms/cpp/maxPointsOnALine","contentType":"directory"},{"name":"maximalRectangle","path":"algorithms/cpp/maximalRectangle","contentType":"directory"},{"name":"maximalSquare","path":"algorithms/cpp/maximalSquare","contentType":"directory"},{"name":"maximumDepthOfBinaryTree","path":"algorithms/cpp/maximumDepthOfBinaryTree","contentType":"directory"},{"name":"maximumGap","path":"algorithms/cpp/maximumGap","contentType":"directory"},{"name":"maximumProductSubarray","path":"algorithms/cpp/maximumProductSubarray","contentType":"directory"},{"name":"maximumSubArray","path":"algorithms/cpp/maximumSubArray","contentType":"directory"},{"name":"medianOfTwoSortedArrays","path":"algorithms/cpp/medianOfTwoSortedArrays","contentType":"directory"},{"name":"mergeIntervals","path":"algorithms/cpp/mergeIntervals","contentType":"directory"},{"name":"mergeKSortedLists","path":"algorithms/cpp/mergeKSortedLists","contentType":"directory"},{"name":"mergeTwoSortedArray","path":"algorithms/cpp/mergeTwoSortedArray","contentType":"directory"},{"name":"mergeTwoSortedList","path":"algorithms/cpp/mergeTwoSortedList","contentType":"directory"},{"name":"minStack","path":"algorithms/cpp/minStack","contentType":"directory"},{"name":"minimumDepthOfBinaryTree","path":"algorithms/cpp/minimumDepthOfBinaryTree","contentType":"directory"},{"name":"minimumHeightTrees","path":"algorithms/cpp/minimumHeightTrees","contentType":"directory"},{"name":"minimumPathSum","path":"algorithms/cpp/minimumPathSum","contentType":"directory"},{"name":"minimumSizeSubarraySum","path":"algorithms/cpp/minimumSizeSubarraySum","contentType":"directory"},{"name":"minimumWindowSubstring","path":"algorithms/cpp/minimumWindowSubstring","contentType":"directory"},{"name":"missingNumber","path":"algorithms/cpp/missingNumber","contentType":"directory"},{"name":"missingRanges","path":"algorithms/cpp/missingRanges","contentType":"directory"},{"name":"moveZeroes","path":"algorithms/cpp/moveZeroes","contentType":"directory"},{"name":"multiplyStrings","path":"algorithms/cpp/multiplyStrings","contentType":"directory"},{"name":"nQueens","path":"algorithms/cpp/nQueens","contentType":"directory"},{"name":"nextPermutation","path":"algorithms/cpp/nextPermutation","contentType":"directory"},{"name":"nimGame","path":"algorithms/cpp/nimGame","contentType":"directory"},{"name":"numberOf1Bits","path":"algorithms/cpp/numberOf1Bits","contentType":"directory"},{"name":"numberOfDigitOne","path":"algorithms/cpp/numberOfDigitOne","contentType":"directory"},{"name":"numberOfIslands","path":"algorithms/cpp/numberOfIslands","contentType":"directory"},{"name":"oddEvenLinkedList","path":"algorithms/cpp/oddEvenLinkedList","contentType":"directory"},{"name":"oneEditDistance","path":"algorithms/cpp/oneEditDistance","contentType":"directory"},{"name":"palindromeLinkedList","path":"algorithms/cpp/palindromeLinkedList","contentType":"directory"},{"name":"palindromeNumber","path":"algorithms/cpp/palindromeNumber","contentType":"directory"},{"name":"palindromePartitioning","path":"algorithms/cpp/palindromePartitioning","contentType":"directory"},{"name":"partitionList","path":"algorithms/cpp/partitionList","contentType":"directory"},{"name":"pascalTriangle","path":"algorithms/cpp/pascalTriangle","contentType":"directory"},{"name":"patchingArray","path":"algorithms/cpp/patchingArray","contentType":"directory"},{"name":"pathSum","path":"algorithms/cpp/pathSum","contentType":"directory"},{"name":"peekingIterator","path":"algorithms/cpp/peekingIterator","contentType":"directory"},{"name":"perfectSquares","path":"algorithms/cpp/perfectSquares","contentType":"directory"},{"name":"permutationSequence","path":"algorithms/cpp/permutationSequence","contentType":"directory"},{"name":"permutations","path":"algorithms/cpp/permutations","contentType":"directory"},{"name":"plusOne","path":"algorithms/cpp/plusOne","contentType":"directory"},{"name":"populatingNextRightPointersInEachNode","path":"algorithms/cpp/populatingNextRightPointersInEachNode","contentType":"directory"},{"name":"pow","path":"algorithms/cpp/pow","contentType":"directory"},{"name":"powerOfFour","path":"algorithms/cpp/powerOfFour","contentType":"directory"},{"name":"powerOfThree","path":"algorithms/cpp/powerOfThree","contentType":"directory"},{"name":"powerOfTwo","path":"algorithms/cpp/powerOfTwo","contentType":"directory"},{"name":"productOfArrayExceptSelf","path":"algorithms/cpp/productOfArrayExceptSelf","contentType":"directory"},{"name":"rangeSumQuery-Immutable","path":"algorithms/cpp/rangeSumQuery-Immutable","contentType":"directory"},{"name":"rangeSumQuery2D-Immutable","path":"algorithms/cpp/rangeSumQuery2D-Immutable","contentType":"directory"},{"name":"readNCharactersGivenRead4","path":"algorithms/cpp/readNCharactersGivenRead4","contentType":"directory"},{"name":"recoverBinarySearchTree","path":"algorithms/cpp/recoverBinarySearchTree","contentType":"directory"},{"name":"rectangleArea","path":"algorithms/cpp/rectangleArea","contentType":"directory"},{"name":"regularExpressionMatching","path":"algorithms/cpp/regularExpressionMatching","contentType":"directory"},{"name":"removeDuplicatesFromSortedArray","path":"algorithms/cpp/removeDuplicatesFromSortedArray","contentType":"directory"},{"name":"removeDuplicatesFromSortedList","path":"algorithms/cpp/removeDuplicatesFromSortedList","contentType":"directory"},{"name":"removeElement","path":"algorithms/cpp/removeElement","contentType":"directory"},{"name":"removeInvalidParentheses","path":"algorithms/cpp/removeInvalidParentheses","contentType":"directory"},{"name":"removeLinkedListElements","path":"algorithms/cpp/removeLinkedListElements","contentType":"directory"},{"name":"removeNthNodeFromEndOfList","path":"algorithms/cpp/removeNthNodeFromEndOfList","contentType":"directory"},{"name":"reorderList","path":"algorithms/cpp/reorderList","contentType":"directory"},{"name":"repeatedDNASequences","path":"algorithms/cpp/repeatedDNASequences","contentType":"directory"},{"name":"restoreIPAddresses","path":"algorithms/cpp/restoreIPAddresses","contentType":"directory"},{"name":"reverseBits","path":"algorithms/cpp/reverseBits","contentType":"directory"},{"name":"reverseInteger","path":"algorithms/cpp/reverseInteger","contentType":"directory"},{"name":"reverseLinkedList","path":"algorithms/cpp/reverseLinkedList","contentType":"directory"},{"name":"reverseNodesInKGroup","path":"algorithms/cpp/reverseNodesInKGroup","contentType":"directory"},{"name":"reverseString","path":"algorithms/cpp/reverseString","contentType":"directory"},{"name":"reverseVowelsOfAString","path":"algorithms/cpp/reverseVowelsOfAString","contentType":"directory"},{"name":"reverseWordsInAString","path":"algorithms/cpp/reverseWordsInAString","contentType":"directory"},{"name":"romanToInteger","path":"algorithms/cpp/romanToInteger","contentType":"directory"},{"name":"rotateArray","path":"algorithms/cpp/rotateArray","contentType":"directory"},{"name":"rotateImage","path":"algorithms/cpp/rotateImage","contentType":"directory"},{"name":"rotateList","path":"algorithms/cpp/rotateList","contentType":"directory"},{"name":"sameTree","path":"algorithms/cpp/sameTree","contentType":"directory"},{"name":"scrambleString","path":"algorithms/cpp/scrambleString","contentType":"directory"},{"name":"search2DMatrix","path":"algorithms/cpp/search2DMatrix","contentType":"directory"},{"name":"searchForRange","path":"algorithms/cpp/searchForRange","contentType":"directory"},{"name":"searchInRotatedSortedArray","path":"algorithms/cpp/searchInRotatedSortedArray","contentType":"directory"},{"name":"searchInsertPosition","path":"algorithms/cpp/searchInsertPosition","contentType":"directory"},{"name":"serializeAndDeserializeBinaryTree","path":"algorithms/cpp/serializeAndDeserializeBinaryTree","contentType":"directory"},{"name":"setMatrixZeroes","path":"algorithms/cpp/setMatrixZeroes","contentType":"directory"},{"name":"shortestPalindrome","path":"algorithms/cpp/shortestPalindrome","contentType":"directory"},{"name":"simplifyPath","path":"algorithms/cpp/simplifyPath","contentType":"directory"},{"name":"singleNumber","path":"algorithms/cpp/singleNumber","contentType":"directory"},{"name":"slidingWindowMaximum","path":"algorithms/cpp/slidingWindowMaximum","contentType":"directory"},{"name":"sortColors","path":"algorithms/cpp/sortColors","contentType":"directory"},{"name":"sortList","path":"algorithms/cpp/sortList","contentType":"directory"},{"name":"spiralMatrix","path":"algorithms/cpp/spiralMatrix","contentType":"directory"},{"name":"sqrt","path":"algorithms/cpp/sqrt","contentType":"directory"},{"name":"strStr","path":"algorithms/cpp/strStr","contentType":"directory"},{"name":"stringToIntegerAtoi","path":"algorithms/cpp/stringToIntegerAtoi","contentType":"directory"},{"name":"subsets","path":"algorithms/cpp/subsets","contentType":"directory"},{"name":"substringWithConcatenationOfAllWords","path":"algorithms/cpp/substringWithConcatenationOfAllWords","contentType":"directory"},{"name":"sudokuSolver","path":"algorithms/cpp/sudokuSolver","contentType":"directory"},{"name":"sumRootToLeafNumber","path":"algorithms/cpp/sumRootToLeafNumber","contentType":"directory"},{"name":"summaryRanges","path":"algorithms/cpp/summaryRanges","contentType":"directory"},{"name":"surroundedRegions","path":"algorithms/cpp/surroundedRegions","contentType":"directory"},{"name":"swapNodesInPairs","path":"algorithms/cpp/swapNodesInPairs","contentType":"directory"},{"name":"symmetricTree","path":"algorithms/cpp/symmetricTree","contentType":"directory"},{"name":"textJustification","path":"algorithms/cpp/textJustification","contentType":"directory"},{"name":"theSkylineProblem","path":"algorithms/cpp/theSkylineProblem","contentType":"directory"},{"name":"topKFrequentElements","path":"algorithms/cpp/topKFrequentElements","contentType":"directory"},{"name":"trappingRainWater","path":"algorithms/cpp/trappingRainWater","contentType":"directory"},{"name":"triangle","path":"algorithms/cpp/triangle","contentType":"directory"},{"name":"twoSum","path":"algorithms/cpp/twoSum","contentType":"directory"},{"name":"uglyNumber","path":"algorithms/cpp/uglyNumber","contentType":"directory"},{"name":"uniqueBinarySearchTrees","path":"algorithms/cpp/uniqueBinarySearchTrees","contentType":"directory"},{"name":"uniquePaths","path":"algorithms/cpp/uniquePaths","contentType":"directory"},{"name":"validNumber","path":"algorithms/cpp/validNumber","contentType":"directory"},{"name":"validPalindrome","path":"algorithms/cpp/validPalindrome","contentType":"directory"},{"name":"validParentheses","path":"algorithms/cpp/validParentheses","contentType":"directory"},{"name":"validSudoku","path":"algorithms/cpp/validSudoku","contentType":"directory"},{"name":"validateBinarySearchTree","path":"algorithms/cpp/validateBinarySearchTree","contentType":"directory"},{"name":"wildcardMatching","path":"algorithms/cpp/wildcardMatching","contentType":"directory"},{"name":"wordBreak","path":"algorithms/cpp/wordBreak","contentType":"directory"},{"name":"wordLadder","path":"algorithms/cpp/wordLadder","contentType":"directory"},{"name":"wordPattern","path":"algorithms/cpp/wordPattern","contentType":"directory"},{"name":"wordSearch","path":"algorithms/cpp/wordSearch","contentType":"directory"},{"name":"zigZagConversion","path":"algorithms/cpp/zigZagConversion","contentType":"directory"}],"totalCount":230},"algorithms":{"items":[{"name":"cpp","path":"algorithms/cpp","contentType":"directory"},{"name":"java","path":"algorithms/java","contentType":"directory"}],"totalCount":2},"":{"items":[{"name":"algorithms","path":"algorithms","contentType":"directory"},{"name":"scripts","path":"scripts","contentType":"directory"},{"name":"shell","path":"shell","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"}],"totalCount":5}},"fileTreeProcessingTime":21.008414,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":62286799,"defaultBranch":"master","name":"leetcode","ownerLogin":"wung","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2016-06-30T06:50:22.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/2314188?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1620087262.338113","canEdit":false,"refType":"branch","currentOid":"0de9d9113c45d747e47731e3b62eef241bce2ac1"},"path":"algorithms/cpp/twoSum/twoSum.cpp","currentUser":null,"blob":{"rawLines":["// Source : https://oj.leetcode.com/problems/two-sum/","// Author : Hao Chen","// Date : 2014-06-17","","/********************************************************************************** ","* ","* Given an array of integers, find two numbers such that they add up to a specific target number.","* ","* The function twoSum should return indices of the two numbers such that they add up to the target, ","* where index1 must be less than index2. Please note that your returned answers (both index1 and index2) ","* are not zero-based.","* ","* You may assume that each input would have exactly one solution.","* ","* Input: numbers={2, 7, 11, 15}, target=9","* Output: index1=1, index2=2","* ","* ","**********************************************************************************/","","class Solution {","public:"," /*"," * The easy solution is O(n^2) run-time complexity."," * ```"," * foreach(item1 in array) {"," * foreach(item2 in array){"," * if (item1 + item2 == target) {"," * return result"," * }"," * }"," * ```"," * "," * We can see the nested loop just for searching, "," * So, we can use a hashmap to reduce the searching time complexity from O(n) to O(1)"," * (the map's `key` is the number, the `value` is the position)"," * "," * But be careful, if there are duplication numbers in array, "," * how the map store the positions for all of same numbers?"," *"," */","",""," //"," // The implementation as below is bit tricky. but not difficult to understand"," //"," // 1) Traverse the array one by one"," // 2) just put the `target - num[i]`(not `num[i]`) into the map"," // so, when we checking the next num[i], if we found it is exisited in the map."," // which means we found the second one."," // "," vector\u003cint\u003e twoSum(vector\u003cint\u003e \u0026numbers, int target) {"," unordered_map\u003cint, int\u003e m;"," vector\u003cint\u003e result;"," for(int i=0; i\u003cnumbers.size(); i++){"," // not found the second one"," if (m.find(numbers[i])==m.end() ) { "," // store the first one poisition into the second one's key"," m[target - numbers[i]] = i; "," }else { "," // found the second one"," result.push_back(m[numbers[i]]+1);"," result.push_back(i+1);"," break;"," }"," }"," return result;"," }","};"],"stylingDirectives":[[[0,53,"pl-c"],[0,2,"pl-c"]],[[0,20,"pl-c"],[0,2,"pl-c"]],[[0,22,"pl-c"],[0,2,"pl-c"]],[],[[0,84,"pl-c"],[0,2,"pl-c"]],[[0,2,"pl-c"]],[[0,97,"pl-c"]],[[0,2,"pl-c"]],[[0,100,"pl-c"]],[[0,105,"pl-c"]],[[0,21,"pl-c"]],[[0,2,"pl-c"]],[[0,65,"pl-c"]],[[0,2,"pl-c"]],[[0,41,"pl-c"]],[[0,28,"pl-c"]],[[0,2,"pl-c"]],[[0,16,"pl-c"]],[[0,83,"pl-c"],[81,83,"pl-c"]],[],[[0,5,"pl-k"],[6,14,"pl-en"]],[[0,7,"pl-k"]],[[4,6,"pl-c"],[4,6,"pl-c"]],[[0,57,"pl-c"]],[[0,12,"pl-c"]],[[0,38,"pl-c"]],[[0,41,"pl-c"]],[[0,51,"pl-c"]],[[0,38,"pl-c"]],[[0,22,"pl-c"]],[[0,18,"pl-c"]],[[0,12,"pl-c"]],[[0,9,"pl-c"]],[[0,56,"pl-c"]],[[0,91,"pl-c"]],[[0,69,"pl-c"]],[[0,9,"pl-c"]],[[0,68,"pl-c"]],[[0,65,"pl-c"]],[[0,6,"pl-c"]],[[0,7,"pl-c"],[5,7,"pl-c"]],[],[],[[4,6,"pl-c"],[4,6,"pl-c"]],[[4,81,"pl-c"],[4,6,"pl-c"]],[[4,6,"pl-c"],[4,6,"pl-c"]],[[4,40,"pl-c"],[4,6,"pl-c"]],[[4,68,"pl-c"],[4,6,"pl-c"]],[[4,87,"pl-c"],[4,6,"pl-c"]],[[4,47,"pl-c"],[4,6,"pl-c"]],[[4,12,"pl-c"],[4,6,"pl-c"]],[[11,14,"pl-k"],[16,22,"pl-en"],[30,33,"pl-k"],[45,48,"pl-k"]],[[22,25,"pl-k"],[27,30,"pl-k"]],[[15,18,"pl-k"]],[[8,11,"pl-k"],[12,15,"pl-k"],[18,19,"pl-c1"],[31,35,"pl-c1"]],[[12,39,"pl-c"],[12,14,"pl-c"]],[[12,14,"pl-k"],[18,22,"pl-c1"],[38,41,"pl-c1"]],[[16,74,"pl-c"],[16,18,"pl-c"]],[],[[13,17,"pl-k"]],[[16,39,"pl-c"],[16,18,"pl-c"]],[[23,32,"pl-c1"],[47,48,"pl-c1"]],[[23,32,"pl-c1"],[35,36,"pl-c1"]],[[16,21,"pl-k"]],[],[],[[8,14,"pl-k"]],[],[]],"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/wung/leetcode/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"twoSum.cpp","displayUrl":"https://github.com/wung/leetcode/blob/master/algorithms/cpp/twoSum/twoSum.cpp?raw=true","headerInfo":{"blobSize":"2.39 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"6ef67fa","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fwung%2Fleetcode%2Fblob%2Fmaster%2Falgorithms%2Fcpp%2FtwoSum%2FtwoSum.cpp","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"69","truncatedSloc":"65"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"C++","languageID":43,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/wung/leetcode/blob/master/algorithms/cpp/twoSum/twoSum.cpp","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/wung/leetcode/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/wung/leetcode/raw/refs/heads/master/algorithms/cpp/twoSum/twoSum.cpp","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/wung/leetcode/branches":{"post":"t7J8PI3JIJk1CnQ-nGc7oDRwSvUbW9zTC0jXOzDfSdxKVkLLygDXO6MVA0gBwOM2rbJL3GiLtXyMUajyhCaI8Q"},"/repos/preferences":{"post":"Xjd-iuZjdLSEK3GJGmZDgihBgx_JfzpMIWJAO2R6Y9WMTbroDZQyPYC5nyIvwnJ-J3V1loteY81105cN7YyJTA"}}},"title":"leetcode/algorithms/cpp/twoSum/twoSum.cpp at master · wung/leetcode","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}