Skip to content

Instantly share code, notes, and snippets.

View manojnaidu619's full-sized avatar
🎯
Focusing

Manoj Kumar manojnaidu619

🎯
Focusing
  • Bangalore,India
View GitHub Profile
@manojnaidu619
manojnaidu619 / dfs.cpp
Created July 9, 2019 11:07
Depth First Search(DFS) of a Graph in CPP
#include <iostream>
using namespace std;
// DFS technique uses Stack. As, we are implementing it using recursion it automatically uses Stack structure
void DFS(int G[][7],int start,int n){
static int visited[7] = {0};
if(visited[start]!=1){
cout << start << " ";
visited[start] = 1;
@manojnaidu619
manojnaidu619 / bfs.cpp
Created July 9, 2019 10:51
Breadth First Search(BFS) of a Graph in CPP
#include <iostream>
using namespace std;
// This is Implementation of Queue
struct Node {
int data;
struct Node *next;
}*front=NULL,*rear=NULL;
@manojnaidu619
manojnaidu619 / rotate_string.rb
Created July 8, 2019 09:13
Leetcode Solution for "Rotate String" in Ruby
def rotate_string(a, b)
return false if a!=b && a.length != b.length
a = a*3
return true if a.include?(b)
return false
end
@manojnaidu619
manojnaidu619 / linear_probing(insert&search).cpp
Last active July 8, 2019 08:20
Linear Probing (Insertion and Searching) in CPP
#include <iostream>
using namespace std;
int hash_(int key){
return key%10;
}
int insert_probe(int HT[],int key){
int i=1,pindex;
while(1){
@manojnaidu619
manojnaidu619 / hash_table_insertion&deletion(chaining).cpp
Last active July 8, 2019 07:18
Insertion & Deletion to/from Hash Table(Chaining) in CPP
#include <iostream>
using namespace std;
struct Node{
int data;
struct Node *next;
};
int hash_(int key)
{
@manojnaidu619
manojnaidu619 / hash_table_creation(chaining).cpp
Created July 7, 2019 15:14
Creation of Hash Table(chaining) in CPP
#include <iostream>
using namespace std;
struct Node{
int data;
struct Node *next;
};
int main(){
@manojnaidu619
manojnaidu619 / corporate_filght_bookings.rb
Created July 7, 2019 04:22
Leetcode solution for contest problem "Corporate Flight Bookings" in Ruby
def corp_flight_bookings(bookings, n)
min_max = []
return bookings if bookings.empty? or bookings[0].empty?
bookings.each do |i|
min_max << i[0] << i[1]
min_max << 1 if i[0]!=1 and i[1]!=1
end
min_max.sort!
min_max.uniq!
min = min_max.first
@manojnaidu619
manojnaidu619 / min_heap.cpp
Created July 6, 2019 12:05
Creation and insertion of Binary min heap
#include <iostream>
#include <vector>
using namespace std;
vector <int> a = {0};
void insert(int ele){
int temp;
a.push_back(ele);
long last = a.size()-1;
@manojnaidu619
manojnaidu619 / max_heap.cpp
Last active July 6, 2019 12:05
Creation and insertion into Binary max heap
#include <iostream>
#include <vector>
using namespace std;
vector <int> a = {0};
void insert(int ele){
int temp;
a.push_back(ele);
long last = a.size()-1;
@manojnaidu619
manojnaidu619 / chef_and_mean.rb
Last active July 5, 2019 15:07
codechef solution for "Chef and Mean" problem in Ruby
# Problem Code : CHFM
elements = []
count = []
a = []
n = gets.to_i
return if !n
n.to_i.times do
count << gets.to_i