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 / BST.rb
Created July 31, 2019 17:01
Binary Search Tree Implementation in Ruby
class Tree
attr_accessor :data, :left, :right
def initialize(data)
@data = data
end
end
def insert(root, data)
if data > root.data
if !root.right
@manojnaidu619
manojnaidu619 / alpha-board-path.rb
Last active July 28, 2019 04:27
Leetcode Solution for "Alphabet Board Path" in Ruby
def alphabet_board_path(target)
board = [
['a','b','c','d','e'],
['f','g','h','i','j'],
['k','l','m','n','o'],
['p','q','r','s','t'],
['u','v','w','x','y'],
['z']
]
answer = []
@manojnaidu619
manojnaidu619 / Easy-Math.rb
Created July 27, 2019 14:51
Codechef solution for " Easy Math (prob code : RPD) " in Ruby
n = gets.to_i
count = []
a = []
n.times do
count << gets.to_i
s = gets.strip.split(/\s+/).map(&:to_i)
a << s
#p sum.max
end
a.each do |i|
@manojnaidu619
manojnaidu619 / best-time-to-buy-and-sell-stock.cpp
Created July 26, 2019 11:08
Leetcode solution for " Best Time to Buy and Sell Stock " problem in CPP
class Solution {
public:
int maxProfit(vector<int>& prices) {
if(prices.size() <= 1){
return 0;
}
int max=-9999,min;
vector<int> max_profit;
vector<int> min_uptil;
min_uptil.push_back(prices[0]);
@manojnaidu619
manojnaidu619 / On-the-way-home.cpp
Last active July 25, 2019 14:50
Solving "On the way Home problem using DP"
/*
Question:
You are located at the top-left corner of a mxn grid. You can only move either right or down at any point in time.
Your home is located at the bottom right corner of this grid. In how many unique ways can you reach your home?
*/
#include <iostream>
#include <vector>
using namespace std;
@manojnaidu619
manojnaidu619 / 2d_vector.cpp
Last active July 21, 2019 14:25
Multidimensional Vectors(2D) in CPP
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<vector<int>> name = {{1,2,3},{4,5,6}};
for(int i=0;i<name.size();i++){
for(int j=0;j<name[i].size();j++){
cout << name[i][j] << " ";
}
@manojnaidu619
manojnaidu619 / lambda_exp.cpp
Last active July 20, 2019 06:34
Lambda expressions examples in CPP
#include <iostream>
using namespace std;
int main(){
int a = 5;
int b = 78;
//Defining a Lambda function : [capture_local_var](parameters){}();
//Simple hello
@manojnaidu619
manojnaidu619 / maps_stl.cpp
Last active July 20, 2019 06:12
Maps(STL) in C++
#include <iostream>
#include <map>
using namespace std;
int main(){
map<int,string> m;
m.insert(pair<int,string>(1,"Apple"));
m.insert(pair<int,string>(2,"Banana"));
m.insert(pair<int,string>(3,"Litchi"));
@manojnaidu619
manojnaidu619 / get_in_axios.js
Last active July 16, 2019 09:14
Get request in Axios
created(){ // As soon as the page loads..
axios.get('http://localhost:3000/api/v1/users.json')
.then(res => {
for(var i=0;i<res.data.length;i++){
console.log(res.data[0].email)
}
})
}
@manojnaidu619
manojnaidu619 / animation&transition_in_vue.html
Created July 15, 2019 17:08
Adding animation classes to div in Vue js
<transition
enter-active-class="animated fadeIn"
leave-active-class="animated fadeOut">
<div v-if="show" class="alert alert-success">
<strong>Success!</strong> Indicates a successful or positive action.
</div>
</transition>