Sort by

recency

|

2721 Discussions

|

  • + 0 comments

    Here is problem solution in Python, java, c++, c and javascript - https://programmingoneonone.com/hackerrank-day-8-dictionaries-and-maps-30-days-of-code-solution.html

  • + 0 comments

    n=int(input()) d={} for _ in range(n): details=input() f_name,phone_no=map(str,details.split()) d[f_name]=phone_no

    while True: try: name=input() if name in d: print(f'{name}={d[name]}') else: print("Not found") except EOFError: break

  • + 0 comments

    public static void main(String []argh){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Map phonebook=new HashMap<>(); for(int i = 0; i < n; i++){ String name = in.next(); int phone = in.nextInt(); phonebook.put(name,phone); // Write code here } while(in.hasNext()){ String s = in.next(); //write your code here if(phonebook.containsKey(s)) System.out.println(s+"="+phonebook.get(s)); else System.out.println("Not found"); } in.close(); }

  • + 0 comments
    x = int(input())
    dic = {}
    

    Reading phonebook entries

    for i in range(x):
        a = input().split(' ', 1)
        dic[a[0]] = a[1]
    

    Handling multiple queries safely until EOF

    try: 
        while True:
            a = input()
            if len(a) > 0:
                if a in dic:
                    print(f'{a}={dic[a]}')
                else:
                    print('Not found')
    except EOFError:
        pass
    
  • + 1 comment

    This is python solution can any one fix the error it failed test case1 n= int(input()) phonebook = {} for i in range(n):

    entry = input().split()
    name = entry[0]
    phone = entry [1]
    phonebook[name] = phone
    

    queries = []

    for i in range(n): query = input() queries.append(query)

    for query in queries: if query in phonebook: print(f"{query}={phonebook[query]}")

      else:
            print("Not found")