Skip to content

Gabospa/30DaysOfCode

Repository files navigation

30DaysOfCode

Solutions to HackerRank 30Days Challenge in Python 3

I hope this repo could help anyone who find this solutions. Also comments or improvements would be apreciated. This is only for learning purposes. Problems made by their Authors on HackerRank.

Day 0: Hello World!

Here we go!

Day 1: Data Types

No problem with this

Day 2: Operators

Simple maths

Day 3: Intro to conditional statements

Attention to your conditional statements, also interesting to check how to implement multime conditions on the same statement.

if all( [cond1 == 'val1', cond2 == 'val2', cond3 == 'val3', cond4 == 'val4'] ):

if any( [cond1 == 'val1', cond2 == 'val2', cond3 == 'val3', cond4 == 'val4'] ):

From S.Lott on Stack Overflow

Day 4: Class vs. Instance

I learned that you can set conditions over the initial properties just after their declarations. Also practice on conditionals

Day 5: Loops

Easy maths and loops on Python. Iterables are very interesting. Lists, Tuples, dictionaries and sets are iterables. All have a iter() method

Day 6: Let's Review

Good practice on string slices

Day 7: Arrays

Appliying slice and string to list methods

Day 8: Dictionaries and Maps

First take on Dictionaries, but it forces you to find about error handling, that is a tip to manage unknown numbers of inputs.

Day 9: Recursion 3

Not much to say, basics of recursion

Day 10: Binary Numbers

Looks simple at first but had to spend some time thinking how to count the max of ones

Day 11: 2D Arrays

Good exercise to handle matrix index

Day 12: Inheritance

Just declaration of sub class, but good example to keep things simple

Day 13: Abstract Classes

Abstract Classes could have a constructor and methods. There are serveral ways to implement empty methods.

Day 14: Scope

Two loop cycles that check abs diference between elements and keep the max.

Day 15: Linked-List

The most important thing is to understand how to traverse a linked list.

Day 16: Exceptions

In this case, when the input type is wrong, the type of error is ValueError

Day 17: More Exception

Important use, an exception could be raised from a Class and be used over the main program

Day 18: Queues and Stacks

Stacks are normal lists with propper care, queues came from collections, and remember to use popleft, not pop.

Day 19: Interfaces

Important to learn about Abstract Classes and Interfaces. Python only have Abstract classes, Java uses Interfaces for multiple inheritance.

Day 20: Sorting

Implementantion of Bubble Sort

Day 21: Generics

Only file on C++. Generics was not available on Python, but you only need to undestand the logic of generics, which means a single function or class who could recive different type of inputs. Also important how to print statements on C++.

Day 22: Binary Search Trees

Have to find the height of trees, which is the definition.

Day 23: BST Level Order Traversal

The key is using a queue, understanding data structures. This is Breadth First Search

Day 24 : More Linked Lists

Had to fight for a while with edge cases, is not hard but thing about several repeated values.

Day 25: Running Time and Complexity

You should always try to understand the algorithm before trying to code it. Why O(n**0.5)?. That's always lower than O(n)

Day 26: Nested Logic

Beware of edge cases, logic is simple but keep in mind end of months and other special cases

Day 27: Testing

Important to understand the meaning of the test, you just have to be clear with the results you want.

Day 28: RegEx, Patterns, and Intro to databases

Not so much about databases but simple example of Regex.

Day 29: Bitwise AND

This was a genuine surprise, logic by brute force is simple, but you should try it and later improve it. There is a elegant solution to this problems. I had to look for this solution which only improves runtime but is not the best. The road is just beggining.

About

Solutions to HackerRanck 30Days Challenge in Python 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published