To the Top
File:  root - text - article - 2019 - 10 - two-sum.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Problem, Data Structures and Algorithms, | English | Home Page | Category: Computing | 1158 Views, 14509 Search Bots | 76 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:

You are given a list of numbers, and a target number k. Return whether or not there are two numbers in the list that add up to k.

Example:
Given [4, 7, 1 , -3, 2] and k = 5,
return true since 4 + 1 = 5.


def two_sum(list, k):
# Fill this in.

print two_sum([4,7,1,-3,2], 5)
# True


Try to do it in a single pass of the list.
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Problem, Data Structures and Algorithms, | English | Home Page | Cateogry: Computing | 1158 Views, 14509 Search Bots | 76 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  2. [Daily Problem] Longest Palindromic Substring
  3. Daily Interview Problem: Sort Colors
  4. Patterns for breaking down questions you haven
  5. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  6. Daily Interview Puzzle: Ways to Traverse a Grid
  7. Daily Interview Problem: Distribute Bonuses
  8. Delphi Dynamic Array
  9. Daily Interview Problem: Word Ordering in a Different Alphabetical Order
  10. Spreadsheet Column Title

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />