0% found this document useful (0 votes)
21 views2 pages

Essential Coding Interview Questions

The document lists frequently asked interview questions along with their solutions in Python. Key topics include string manipulation, palindrome checking, character frequency counting, finding maximum and minimum values, removing duplicates, finding the second largest number, merging dictionaries, identifying common elements in lists, and detecting repeating numbers. Each question is rated with a difficulty level indicated by stars.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Essential Coding Interview Questions

The document lists frequently asked interview questions along with their solutions in Python. Key topics include string manipulation, palindrome checking, character frequency counting, finding maximum and minimum values, removing duplicates, finding the second largest number, merging dictionaries, identifying common elements in lists, and detecting repeating numbers. Each question is rated with a difficulty level indicated by stars.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Frequently ASKED INTERVIEW QUESTIONS

1.​ Reverse a string ⭐⭐⭐⭐


s = "hello"
reversed_str = s[::-1]

2.​ Check for palindrome ⭐⭐⭐⭐


​ s = "madam"
is_palindrome = s == s[::-1]
print(is_palindrome)

3.​ Count character frequency ⭐⭐⭐⭐⭐


​ s = "hello"
freq = {}
for char in s:
​ ​ freq[char] = [Link](char, 0) + 1

4.​ Find maximum and minimum without using any inbuilt functions ⭐⭐⭐⭐⭐ (Very
important )
​ ​ arr = [10, 20, 4, 45, 99]
max_val = arr[0]
min_val = arr[0]
for num in arr:
​ ​ ​ if num > max_val:
​ ​ ​ max_val = num
​ ​ ​ if num < min_val:
​ ​ ​ min_val = num

5.​ Remove duplicates (imp) ⭐⭐⭐⭐⭐


​ lst = [1, 2, 2, 3, 4, 4]
​ unique = list(set(lst))

6.​ Find second largest number ⭐⭐⭐⭐⭐


lst = [10, 20, 4, 45, 99, 99]
second_largest = sorted(set(lst))[-2]
print(second_largest)

7.​ Merge 2 dictionary ⭐⭐⭐⭐


​ d1 = {'a': 1, 'b': 2}
d2 = {'b': 3, 'c': 4}
merged = {**d1, **d2}
Frequently ASKED INTERVIEW QUESTIONS

8.​ Find common elements in 2 lists ⭐⭐⭐⭐⭐


list1 = [1, 2, 3, 4]
list2 = [3, 4, 5, 6]

common = list(set(list1) & set(list2))

9.​ Find repeating number ⭐⭐⭐⭐


arr = [1, 2, 3, 4, 2, 5]
seen = set()
repeat = []
for num in arr:
if num in seen:
[Link](num)
else:
​ [Link](num)

You might also like