We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Search
  4. Ice Cream Parlor
  5. Discussions

Ice Cream Parlor

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Sort 848 Discussions, By:

recency

Please Login in order to post a comment

  • aravp2319
    23 hours ago+ 0 comments

    Basically Two Sum

    def icecreamParlor(m, arr):
        d = dict()
        for idx, price in enumerate(arr):
            if m - price in d:
                return [d[m - price], idx + 1]
            d[price] = idx + 1
        
        return [0,0]
    
    0|
    Permalink
  • gunggus2367
    2 days ago+ 0 comments

    Python

    def icecreamParlor(m, arr):
        for i in range(len(arr)-1):
            j = i + 1
            while j < len(arr):
                if arr[i] + arr[j] == m:
                    return i+1, j+1
                j += 1
    
    0|
    Permalink
  • augustoribeiro_1
    5 days ago+ 0 comments
    public static List<Integer> icecreamParlor(int m, List<Integer> arr) {
            
            List<Integer> result = new ArrayList<>();
            
            for(int i = 0; i < arr.size() - 1; i++) {
                
                int c1 = arr.get(i);
                
                for(int j = i + 1; j < arr.size(); j++) {
                    
                    int c2 = arr.get(j);
                    
                    if(c1 + c2 == m) {
                        result.add(i + 1);
                        result.add(j + 1);
                        
                        return result;
                    }
                        
                }
                
            }
            
            return result;
        }
    
    0|
    Permalink
  • kokejecb
    3 weeks ago+ 0 comments

    Python 3

    def icecreamParlor(m, arr):
        for idx, i in enumerate(arr):
            if arr[idx+1:].count(m-i) > 0:
                return idx+1, arr[idx+1:].index(m-i)+idx+2
    
    0|
    Permalink
  • davepaul321
    4 weeks ago+ 0 comments
    def icecreamParlor(m, arr):
        # Write your code here
        for i,it1 in enumerate(arr):
            for j,it2 in enumerate(arr[i+1:]):
                if it1+it2==m:
                    return([i+1,i+1+j+1])
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy