Skip to content

Contains personal approaches and codes from hackerrank,codechef,leetcode,interviewbit,etc

Notifications You must be signed in to change notification settings

AshishKempwad/Competitive-Coding

Repository files navigation

Competitive-Coding

Contains all codes from hackerrank,codechef,leetcode,interviewbit,etc

1)Permutation_Palindrome - Easy - Codechef - {Covers the best use of map(stl) and palindrome logic}

2)Occurances of words in a sentence - Easy - Coding Ninjas - {Learned to use 'getline','stringstream','map','itreating over a map'}

3)Extracting unique words from the char array -Easy -Coding Ninjas -{How to deal with character array,unorderedmap}

4)Set ith bit - EASY -Coding Ninjas - (Bit manipulation,alternate for power of 2) Problem :(You are given two integers N and i. You need to make ith bit of binary representation of N to 1 and return the updated N.Counting of bits start from 0 from right to left.)

5)Unset ith bit - EASY - Coding Ninjas Problem : (You are given two integers N and i. You need to make ith bit of binary representation of N to 0 and return the updated N.)

6)Flip the ith bit - EASY - Coding Ninjas - (Learnt the use of Xor property to flip a bit)

7)Find number is even or odd -EASY - Coding Ninjas- (optimized way of finding number is even or odd)

8)Find first set bit - EASY - Coding Ninjas - (Learnt the helpfulness of bitwise & operator in finding the smallest set bit) Problem: You are given an integer N. You need to return an integer M, in which only one bit is set which at position of lowest set bit of N (from right to left).

9)Turn off 1st set bit - EASY - Coding Ninjas Problem :You are given an integer Ni. You need to make first set bit of binary representation of N to 0 and return the updated N.Counting of bits start from 0 from right to left.

  1. Equilize - EASY - Codeforces Link to problem : https://codeforces.com/problemset/problem/1037/C

11)Trapping Rainwater -EASY Link : https://practice.geeksforgeeks.org/problems/trapping-rain-water-1587115621/1/?track=SPCF-Arrays&batchId=154 TC:O(n) , SC: O(n)

NOTE: https://leetcode.com/articles/trapping-rain-water/# - Here, Approach 4, using 2 pointers has been given in great manner. This method solves the problem in O(1) space complexity.