Skip to content

Commit

Permalink
Merge pull request #57 from sanskar28/master
Browse files Browse the repository at this point in the history
Uploaded Hash Tables in Python
  • Loading branch information
championballer authored Dec 24, 2019
2 parents 49cb42c + 6ed78fe commit 34cca5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ in C++, Java and Python.
||[Pairs](https://www.hackerrank.com/challenges/pairs/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/paris.cpp)||[Done](/Search/Pairs.py)|
||[Triple Sum](https://www.hackerrank.com/challenges/triple-sum/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/triple_sum.cpp)||[Done](/Search/TripleSum.py)|
||[Maximum Subarray Sum](https://www.hackerrank.com/challenges/maximum-subarray-sum/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/maximum_subarray_sum.cpp)||[Done](/Search/MaximumSubarraySum.py)|
||[Hash Tables: Ice Cream Parlor](https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/ice_cream_parlor.cpp)|||
||[Hash Tables: Ice Cream Parlor](https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/ice_cream_parlor.cpp)||[Done](/Search/hash_tables.py)|
||[Swap Nodes [Algo]](https://www.hackerrank.com/challenges/swap-nodes-algo/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|||[Done](/Search/SwapNodes.py)|
||[Making Candies](https://www.hackerrank.com/challenges/making-candies/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|||[Done](/Search/MakingCandies.py)|
|Dynamic Programming| ||||
Expand Down
23 changes: 23 additions & 0 deletions Search/hash_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/python3

import math
import os
import random
import re
import sys
def flavors(m,a):
prices = {}
for idx, p in enumerate(a):
if m-p in prices:
return prices[m-p], idx
prices[p] = idx
return None

t = int(input().strip())
for a0 in range(t):
m = int(input().strip())
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
f1, f2 = flavors(m,a)
print(f1+1, f2+1)

0 comments on commit 34cca5a

Please sign in to comment.