Solutions for the practice problems on HackerRank.
Attribute Parser :: [C++ STL] {medium}
string
input viacin
string.substr
string.find_first_of
vector<string>
unordered_map<string, string>
The Minion Game :: [Python] {medium}
- substrings
- Counter class (in Version 1)
Merge the Tools! :: [Python] {medium}
- substrings
sorted
withkey
Exceptional Server :: [C++ STL] {medium}
- throw with try-catch
- standard and non-standard exceptions
Inherited Code :: [C++ STL] {medium}
- custom exceptions with parameters
Virtual Functions :: [C++ STL] {medium}
- abstract functions
- virtual functions
- overloaded functions
- static fields
Abstract Classes - Polymorphism :: [C++ STL] {hard}
- abstract functions
- virtual functions
- double-linked lists
map
Accessing Inherited Functions :: [C++ STL] {medium}
- multiple inheritance
- private, protected, and public functions
Operator Overloading :: [C++ STL] {medium}
- operator overloading
- 2-D
vector
Messages Order :: [C++ STL] {medium}
- static fields
- operator overloading
Template Specialization :: [C++ STL] {medium}
enum
- class/struct template specialization
- template parameter packs
- variadic templates
- non-type template parameters
Magic Spells :: [C++ STL] {hard}
dynamic_cast
- 2-D
vector
- Longest common subsequence problem
Quicksort 1 - Partition :: [C++ STL] [PHP] {easy}
- Quicksort
- sets
Count Triplets :: [Python] {medium}
- hash table
- tuples
deque<int>
Piling Up! :: [Python] {medium}
collection.deque
DefaultDict Tutorial :: [Python] {easy}
collections.defaultdict
Hash Tables: Ransom Note :: [Python] {medium}
- collectios.Counter
- Binary Search Tree
Is This a Binary Search Tree? :: [C++ STL] {medium}
- Binary Search Tree
Tree: Level Order Traversal :: [C++ STL] {easy}
- Binary Tree
Attending Workshops :: [C++ STL] {medium}
- Interval scheduling maximization problem
- initializing an array of unknown size
vector
sort with a custom function
- bit operations
- Set bits in an integer / Brian Kernighan's Algorithm
Construct the Array :: [C++ STL] {medium}
- construct an array with
n
elements such that each element between1
andk
, inclusive - the first and last elements of the array to be
1
andx
Array Manipulation :: [C++ STL] {hard}
heap<int>
(C++) /heapq
(Python)
Extra Long Factorials :: [C++ STL] {medium}
- big integers
vector.reverse_iterator
Roads and Libraries :: [C++ STL] {medium}
- graphs
- depth first search
- connected components
Easy problems (in one Jupyter Notebook) :: [Python]
Medium and Hard problems (in individual files) :: [Python]
Iterables and Iterators :: [Python] {medium}
itertools.permutations
Compress the String! :: [Python] {medium}
itertools.groupby
- list comprehension
Maximize It! :: [Python] {hard}
itertools.product
map
- list comprehension
Weather Observation Station 4 :: [SQL] {easy}
count
/distinct count
Weather Observation Station 5 :: [SQL] {easy}
- shortest / longest string value in the table
Weather Observation Station 8 :: [SQL] {easy}
- starting or ending with a vowel
Weather Observation Station 11 :: [SQL] {easy}
- not starting or not ending with a vowel
The Report :: [SQL]
inner join
,case
inner join
,group by
,having
,count
inner join
,min
Challenges :: [SQL]
inner join
,group by
,having
,count
inner join
,group by
,having
,sum
,max
Weather Observation Station 18 :: [SQL] {medium}
- Manhattan distance
cast
,max
,min
,abs
Weather Observation Station 19 :: [SQL] {medium}
- Euclidean distance
cast
,max
,min
,square
,sqrt
Weather Observation Station 20 :: [SQL] {medium}
- Median value in a table
The Blunder :: [SQL] {easy}
cast
,avg
,replace
,ceiling
- Version 1:
while
,replicate
- Version 2: Recursive Common Table Expressions (CTE's)
- Control of Flow:
while
,break
,if
Not A Triangle :: [SQL] {easy}
case
group by
,count
,left
,lower
,cast
Occupations :: [SQL] {medium}
rank
,partition
,pivot
Binary Tree Nodes :: [SQL] {medium}
case
,exists
New Companies :: [SQL] {medium}
join
,count distinct
,group by
15 Days of Learning SQL :: [SQL] {hard}
with
,row_number over
,partition by
,group by
,count
,datediff
- Common Table Expressions (CTE's)
- Finding Sequences Tabibitosan Method
cross join
(Cartesian Product)with
,row_number over
,datediff
Placements :: [SQL] {medium}
join
Symmetric Pairs :: [SQL] {medium}
with
,row_number over
- Common Table Expressions (CTE's)