Borrowed from the article below
- By Taha Sufiyan
- DISCLAIMER: Although there are solutions in the article, the purpose of this repo is to do the challenges by creating my own personalized solutions to the problems
Python Solution palindrome.py
python palindrome.py <list value as arguments>
- e.g
python python/palindrome.py 34 44 676 009 0 free stits 12.21
- Output
Value: 34 --> Not Palindrome
Value: 44 --> Palindrome
Value: 676 --> Palindrome
Value: 009 --> Not Palindrome
Value: 0 --> Palindrome
Value: free --> Not Palindrome
Value: stits --> Palindrome
Value: 12.21 --> Palindrome
Python Solution: reverse_string.py
python reverse_str.py <list value as arguments>
- e.g
python python/reverse_string.py 34 44 676 009 0 free stits 12.21
- Output
Value: 34 --> Reversed as: 43
Value: 44 --> Reversed as: 44
Value: 676 --> Reversed as: 676
Value: 009 --> Reversed as: 900
Value: 0 --> Reversed as: 0
Value: free --> Reversed as: eerf
Value: stits --> Reversed as: stits
Value: 12.21 --> Reversed as: 12.21
Python Solution char_occurence.py
python python/char_occurrence.py <char> <string>
- e.g
python python/char_occurrence.py 2 333323
- Output
The char '2' appeared 1 time(s) in the string '333323'.
Python Solution anagrams.py
python python/anagrams.py <string_a> <string_b>
- e.g
python python/anagrams.py "I'm a dot in place." "A decimal point"
- Output
'I'm a dot in place.' and 'A decimal point' are anagrams
eg.2
python python/anagrams.py "njagi ndungo" "omar njagi"
- Output
'njagi ndungo' and 'omar njagi' are not anagrams
Python Solution cons_vow.py
python python/cons_vow.py <string_a> <string_b>
- e.g
python python/cons_vow.py "aba" "sugar" "osama bin laden" "smooth sailor" "muslimah"
- Output
aba has 2 vowels and 1 consonants.
sugar has 2 vowels and 3 consonants.
osama bin laden has 6 vowels and 7 consonants.
smooth sailor has 5 vowels and 7 consonants.
muslimah has 3 vowels and 5 consonants.
eg.2
python python/cons_vow.py
- Output
No arguments provided
Python Solution matching_elements.py
python python/matching_elements.py <a list of integers>
- e.g
python python/matching_elements.py 1 2 3 4 5 5 6 6 7 8 9 10
- Output
The elements [5, 6] have a match in the array [1, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10].
eg.2
python python/matching_elements.py 1 2 3 4 5 6 7 8 9 10
- Output
The array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] has no matching elements.
eg.3
python python/matching_elements.py
- Output
Please input a list of integers.
eg.4
python python/matching_elements.py a 2 3 4 5 6 7 8 9 1q
- Output
The array [2, 3, 4, 5, 6, 7, 8, 9] has no matching elements.
Python Solution anagrams.py
python python/reverse_array.py <arr_item_a> <arr_item_b> ...
- e.g
python python/reverse_array.py
- Output
please input an array in list form, with items separated in spaces
eg.2
python python/reverse_array.py 2
- Output
The array [2] is reversed to: [2]
eg.3
python python/reverse_array.py 2 3 4 5 6 7 8 9
- Output
The array [2, 3, 4, 5, 6, 7, 8, 9] is reversed to: [9, 8, 7, 6, 5, 4, 3, 2]
Python Solution sum_array.py
python python/sum_array.py <a list of array elements to sum>
- e.g
python python/sum_array.py 1 2 3.788888888888
- Output
6.7889
eg.2
python python/sum_array.py
- Output
please input an array in list form, with items separated in spaces
eg.3
python python/sum_array.py free
- Output
please input numbers in list form, separated with spaces
21. Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if open brackets are closed by the same type of brackets and in the correct order. For example, '()' and '()[{}]' are valid but '(]' and '([)]' are not. Explain your approach and any data structures you would use to solve this efficiently.
22. Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
23. In this problem, you need to merge two sorted linked lists into one sorted list. Walk me through how you would approach merging these lists and explain your thought process step by step, any edge cases you'd consider, and the time and space complexity of your solution.
24. Given a string s, find the length of the longest substring without repeating characters. For example, for the input 'abcabcbb', the answer is 3, because the longest substring without repeating characters is 'abc'.
Coding Interview Questions On Conceptual Understanding
-
What is a Data Structure?
-
What is an Array?
-
What is a Linked List?
-
What is LIFO?
-
What is a Stack?
-
What is FIFO?
-
What is a Queue?
-
What are Binary Trees?
-
What is Recursion?
-
What is the OOPs concept?
-
What are the concepts introduced in OOPs?
-
Explain what a Binary Search Tree is.
-
Explain Doubly Linked Lists?
-
What is a Graph?
-
Differentiate between linear and non-linear data structure?
-
What is a Deque? A deque is a double-ended queue.
-
What’s the difference between Stack and Array?
-
Which sorting algorithm is the best?
-
How does variable declaration affect memory?
-
What are dynamic data structures?