Git Product home page Git Product logo

21-days-of-code-with-code-warriors's Introduction

21-Days-Of-Code-With-Code-Warriors

Recently I came across the initiative started by Code Warriors i.e. 21 Days of Code with Code Warriors.
They started this initiative so that the participants can code continuously for 21 days and build a habit of coding among themselves.
My main aim for enrolling in this program was that I can prepare for the companies interview that's going to take place in my college this year.
So I started with Data Structures and I noticed that I had to cover the following topics during my practice.

  • Array
  • Linked List
  • Stack
  • Queue
  • Binary Tree
  • Binary Search Tree
  • Hashing
  • Graph

Day 1

Given two strings, check to see if they are anagrams. An anagram is when the two strings can be written using the exact same letters (so you can just rearrange the letters to get a different phrase or word).
For example:
"public relations" is an anagram of "crap built on lies."
"Clint Eastwood" is an anagram of "old west action"
Note: Ignore spaces and capitalization. So "d go" is an anagram of "God" and "dog" and "o d g".

Solution

Anagrams Solution

Day 2

Array Sum
Given an array A[] and a number x, check for pair in A[] with sum as x
Write a program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x.

Input: arr[] = {0, -1, 2, -3, 1}
sum = -2
Output: -3, 1
If we calculate the sum of the output,
1 + (-3) = -2


Input: arr[] = {1, -2, 1, 0, 5}
sum = 0
Output: -1
No valid pair exists.

Solution

Array Sum Solution

Day 3

Find the Missing Element
Problem
Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first array and deleting a random element. Given these two arrays, find which element is missing in the second array.

Here is an example input, the first array is shuffled and the number 5 is removed to construct the second array.

Input:
finder([1,2,3,4,5,6,7],[3,7,2,1,4,6]) 
Output:
5 is the missing number

Solution

Find the Missing Element

Day 4

Largest Continuous Sum
Problem
Given an array of integers (positive and negative) find the largest continuous sum. Example
a = [-2, -3, 4, -1, -2, 1, 5, -3]
large_cont_sum(a)
7

Solution

Largest Continuous Sum

Day 5

Problem 1

1. Sentence Reversal
Problem
Given a string of words, reverse all the words. For example:

Given:

'This is the best'
Return:

'best the is This'
As part of this exercise you should remove all leading and trailing whitespace. So that inputs such as:

'  space here'  and 'space here      '
both become:

'here space'

Problem 2

2. String Compression
Problem
Given a string in the form 'AAAABBBBCCCCCDDEEEE' compress it to become 'A4B4C5D2E4'. For this problem, you can falsely "compress" strings of single or double letters. For instance, it is okay for 'AAB' to return 'A2B1' even though this technically takes more space.

The function should also be case sensitive, so that a string 'AAAaaa' returns 'A3a3'.

Solution

Sentence Reversal and String Compression

Day 6

Unique Characters in String
Problem
Given a string,determine if it is compreised of all unique characters. For example, the string 'abcde' has all unique characters and should return True. The string 'aabcde' contains duplicate characters and should return false.

Solution

Unique Characters in String

Day 7

Data Structure Implementation in Python
* Stack Implementation
* Queue Implementation
* Deque Implementation

Solution

Stack, Queue and Deque Implementation

After 2 Days of Weekend Break

Day 10

Given a string of opening and closing parentheses, check whether it’s balanced.
We have 3 types of parentheses: round brackets: (), square brackets: [], and curly brackets: {}.
Assume that the string doesn’t contain any other character than these, no spaces words or numbers. 
As a reminder, balanced parentheses require every opening parenthesis to be closed in the reverse order opened. 
For example ‘([])’ is balanced but ‘([)]’ is not. 

You can assume the input string has no spaces.

Solution

Balanced Parenthesis

Day 11

Implement a Queue - Using Two Stacks
Given the Stack class below, implement a Queue class using two stacks! Note, this is a "classic" interview problem. Use a Python list data structure as your Stack.

Solution

Queue Using 2 Stacks

Day 12

Convert Decimal Integer to Binary
In this coding exercise, you are required to use the stack data structure(List can also be used) to convert integer values to their binary equivalent.

Solution

Decimal Integer to Binary

Day 13

Linked List Insertion
we’ll implement the class methods to insert elements in a linked list:
1) append
2) prepend
3) insert_after_node

Solution

Linked List Insertion

Day 18

Linked List Operations
we’ll implement the class methods to delete and find length of nodes in a linked list:
1) Delete nodes by value and position
2) Find Length iterative and recursively

Solution

Linked List Operations

Day 19

Node Swap in Singly Linked List
In this lesson, we will continue with our linked list implementation and focus on how to swap two different nodes in a linked list.
We will give different keys corresponding to the data elements in the nodes. 
Now we want to swap the two nodes that contain those two keys.

Solution

Node Swap in Singly Linked List

Day 21

Reverse Node in Singly Linked List
In this lesson, we will look at how we can reverse a singly linked list in an iterative way

Solution

Reverse Node in Singly Linked List

21-days-of-code-with-code-warriors's People

Contributors

mayank8200 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.