All Projects → SrGrace → InterviewBit

SrGrace / InterviewBit

Licence: GPL-3.0 license
Collection of solution for problems on InterviewBit

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to InterviewBit

Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (+115.58%)
Mutual labels:  hashing, linked-list, stack, queue, maps, arrays, dynamic-programming
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+5667.53%)
Mutual labels:  tree, linked-list, stack, queue, bit-manipulation, dynamic-programming, greedy-algorithms
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+502.6%)
Mutual labels:  hashing, tree, linked-list, stack, queue, bit-manipulation
Data-Structures-Algorithms-Handbook
A series of important questions with solutions to crack the coding interview and ace it!
Stars: ✭ 30 (-61.04%)
Mutual labels:  hashing, linked-list, strings, backtracking, bit-manipulation, dynamic-programming
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-54.55%)
Mutual labels:  tree, linked-list, stack, queue, strings, arrays
algoexpert
AlgoExpert is an online platform that helps software engineers to prepare for coding and technical interviews.
Stars: ✭ 8 (-89.61%)
Mutual labels:  strings, arrays, dynamic-programming, greedy-algorithms, heaps
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (+57.14%)
Mutual labels:  tree, linked-list, stack, queue, arrays
Data Structures Algorithms
My implementation of 85+ popular data structures and algorithms and interview questions in Python 3 and C++
Stars: ✭ 273 (+254.55%)
Mutual labels:  tree, linked-list, strings, arrays, dynamic-programming
Coding Ninjas Java Solutions
This will have solutions to all the problems that are included in Coding Ninja's 2020 Java Course. Star the repo if you like it.
Stars: ✭ 32 (-58.44%)
Mutual labels:  linked-list, stack, strings, arrays, dynamic-programming
Competitive Programming
Contains solutions and codes to various online competitive programming challenges and some good problems. The links to the problem sets are specified at the beginning of each code.
Stars: ✭ 65 (-15.58%)
Mutual labels:  linked-list, stack, queue, dynamic-programming, greedy-algorithms
Data-Structures-and-Algorithms
Implementation of various Data Structures and algorithms - Linked List, Stacks, Queues, Binary Search Tree, AVL tree,Red Black Trees, Trie, Graph Algorithms, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Segment Trees etc.
Stars: ✭ 144 (+87.01%)
Mutual labels:  tree, linked-list, queue, dynamic-programming, greedy-algorithms
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (+115.58%)
Mutual labels:  tree, linked-list, stack, queue, dynamic-programming
AlgoDaily
just for fun
Stars: ✭ 118 (+53.25%)
Mutual labels:  tree, linked-list, stack, queue, binary-search
DSA--GeeksForGeeks
DSA course solutions in C++ Jump to below directly for more problems
Stars: ✭ 47 (-38.96%)
Mutual labels:  linked-list, backtracking, arrays, dynamic-programming, greedy-algorithms
LeetCode
Solution to LeetCode Problems in Python and Golang 🎯
Stars: ✭ 12 (-84.42%)
Mutual labels:  linked-list, strings, dynamic-programming, greedy-algorithms, two-pointers
Learningmasteringalgorithms C
Mastering Algorithms with C 《算法精解:C语言描述》源码及Xcode工程、Linux工程
Stars: ✭ 615 (+698.7%)
Mutual labels:  tree, linked-list, stack, queue
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (-31.17%)
Mutual labels:  tree, linked-list, stack, queue
Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+4083.12%)
Mutual labels:  tree, linked-list, stack, queue
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+1364.94%)
Mutual labels:  tree, linked-list, stack, queue
Data Structures
This repository contains some data structures implementation in C programming language. I wrote the tutorial posts about these data structures on my personal blog site in Bengali language. If you know Bengali then visit my site
Stars: ✭ 82 (+6.49%)
Mutual labels:  tree, linked-list, stack, queue

SrGrace's InterviewBit-Wiki

Collection of solution for problems on InterviewBit

Open Source Love InterviewBit GitHub Forks GitHub Stars GitHub Contributors

Contents

Arrays


####Add one to number
Given a non-negative number represented as an array of digits, add 1 to the number ( increment the number represented by the digits ). The digits are stored such that the most significant digit is at the head of the list.

Example: If the vector has [1, 2, 3] the returned vector should be [1, 2, 4] as 123 + 1 = 124.

Note: The result may be very large, so you need to return a string instead of an integer.

Solution


####Find duplicate in array
Given a read only array of n + 1 integers between 1 and n, find one number that repeats in linear time using less than O(n) space and traversing the stream sequentially O(1) times.

Example: For [3, 4, 1, 4, 1], you should return 1.

Note: If there are multiple possible answers ( like in the sample case above ), output any one.

Solution


####First missing integer
Given an unsorted integer array, find the first missing positive integer.

Example: For [1,2,0] return 3, [3,4,-1,1] return 2, [-8, -7, -6] returns 1

Note: Your algorithm should run in O(n) time and use constant space.

Solution


####flip
You are given a binary string(i.e. with characters 0 and 1) S consisting of characters S1, S2, …, SN. In a single operation, you can choose two indices L and R such that 1 ≤ L ≤ R ≤ N and flip the characters SL, SL+1, …, SR. By flipping, we mean change character 0 to 1 and vice-versa.
Your aim is to perform ATMOST one operation such that in final string number of 1s is maximised. If you don’t want to perform the operation, return an empty array. Else, return an array consisting of two elements denoting L and R. If there are multiple solutions, return the lexicographically smallest pair of L and R.

Notes: Pair (a, b) is lexicographically smaller than pair (c, d) if a < c or, if a == c and b < d.

Example: Given S = 010,

Pair of [L, R] Final string
[1 1] 110
[1 2] 100
[1 3] 101
[2 2] 000
[2 3] 001

We see that two pairs [1, 1] and [1, 3] give same number of 1s in final string. So, we return [1, 1].

Example: Given S = 111,
No operation can give us more than three 1s in final string. So, we return empty array [].

Solution


####Largest number
Given a list of non negative integers, arrange them such that they form the largest number.

Example: Given [3, 30, 34, 5, 9], the largest formed number is 9534330.

Note: The result may be very large, so you need to return a string instead of an integer.

Solution


####Max sum contiguous subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

Example: For [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the largest sum, which is 6.

For this problem, return the maximum sum.

Solution


####Merge overlapping intervals
Given a collection of intervals, merge all overlapping intervals.

Example: Given [1,3], [2,6], [8,10], [15,18], return [1,6] [8,10] [15,18].

Note: Make sure the returned intervals are sorted.

Solution


####Min steps in infinite grid
You are in an infinite 2D grid where you can move in any of the 8 directions :
(x,y) to
(x+1, y),
(x - 1, y),
(x, y+1),
(x, y-1),
(x-1, y-1),
(x+1,y+1),
(x-1,y+1),
(x+1,y-1)

You are given a sequence of points and the order in which you need to cover the points. Give the minimum number of steps in which you can achieve it. You start from the first point.

Example: For [(0, 0), (1, 1), (1, 2)], return 2.
It takes 1 step to move from (0, 0) to (1, 1). It takes one more step to move from (1, 1) to (1, 2).

Solution


####Repeat and missing number array
You are given a read only array of n integers from 1 to n. Each integer appears exactly once except A which appears twice and B which is missing. Return A and B.

Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
Note 2: that in your output A should precede B.

Example: For [3, 1, 2, 5, 3] return [3, 4]

Solution


####Set matrix zeros
Given an m x n matrix of 0s and 1s, if an element is 0, set its entire row and column to 0. Do it in place.

Example: For a given array A as [ [1, 0 ,1], [1, 1, 1], [1, 1, 1,] ], on returning, the array A should be [ [0, 0 ,0], [1, 0, 1], [1, 0, 1] ]

Note: Try to minimize the space and time complexity.

Solution


Math


####Rearrange Array
Rearrange a given array so that Arr[i] becomes Arr[Arr[i]] with O(1) extra space.

Example: For a given array Arr as [1, 0], on returning, the array Arr should be [0, 1]

Note: Lets say N = size of the array. Then, following holds true :

  • All elements in the array are in the range [0, N-1]
  • N * N does not overflow for a signed integer

Solution


####Excel Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.

Example:
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB

Solution


####Excel Column Number
Given a column title as appears in an Excel sheet, return its corresponding column number.

Example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28

Solution


####FizzBuzz
Given a positive integer N, print all the integers from 1 to N. But for multiples of 3 print “Fizz” instead of the number and for the multiples of 5 print “Buzz”. Also for number which are multiple of 3 and 5, prints “FizzBuzz”.

Example: Given N = 5 Return: [1 2 Fizz 4 Buzz]

Note: Instead of printing the answer, you have to return it as list of strings.

Solution


####Palindrome Integer
Determine whether an integer is a palindrome. Do this without extra space.
A palindrome integer is an integer x for which reverse(x) = x where reverse(x) is x with its digit reversed. Negative numbers are not palindromic.

Example:
Input : 12121
Output : True

Input : 123
Output : False

Solution


####Power Of Two Integers
Given a positive integer which fits in a 32 bit signed integer, find if it can be expressed as A^P where P > 1 and A > 0.
A and P both should be integers.

Example:
Input : 4
Output : True
as 2^2 = 4.

Solution


####Prime Sum
Given an even number ( greater than 2 ), return two prime numbers whose sum will be equal to given number.

Example:
Input : 4
Output : 2 + 2 = 4

Note: If there are more than one solutions possible, return the lexicographically smaller solution.
If [a, b] is one solution with a <= b,
and [c,d] is another solution with c <= d, then
[a, b] < [c, d]
If a < c OR a==c AND b < d.

Solution


####Greatest Common Divisor
Given 2 non negative integers m and n, find gcd(m, n).
GCD of 2 integers m and n is defined as the greatest integer g such that g is a divisor of both m and n. Both m and n fit in a 32 bit signed integer.

Example:
Input : m = 6, n = 9
Output : GCD(m, n) = 3

Note: DO NOT USE LIBRARY FUNCTIONS

Solution


Binary Search


Strings


Bit Manipulation


Two Pointers


Linked List


Stacks and Queues


BackTracking


Hashing


Heaps And Maps


####Merge K Sorted Lists
Merge k sorted linked lists and return it as one sorted list.

Example:
1 -> 10 -> 20
4 -> 11 -> 13
3 -> 8 -> 9

will result in
1 -> 3 -> 4 -> 8 -> 9 -> 10 -> 11 -> 13 -> 20

Solution


Trees


Dynamic Programming


Greedy


Graphs






NOTE: PRs and Stars are always welcome

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].