To the Top
File:  root - text - article - 2019 - 10 - two-sum.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Problem, Data Structures and Algorithms, | English | Home Page | Category: Computing | 1172 Views, 14910 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 | 1172 Views, 14910 Search Bots | 76 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Spiral Traversal of Grid
  2. Skip the readings, focus on problems. And use all the hints!
  3. Daily Interview Puzzle: Minimum Size Subarray Sum
  4. First and Last Indices of an Element in a Sorted Array
  5. Daily Interview Problem: Merge List Of Number Into Ranges
  6. Daily Interview Question: Create a Simple Calculator
  7. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  8. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  9. Algorithm Interview Question: Max and Min with Limited Comparisons
  10. Daily Interview Problem: Full Binary Tree

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">