Skip to content

Instantly share code, notes, and snippets.

View Himanshu3198's full-sized avatar
🎯
Focusing

HIMANSHU SHARMA Himanshu3198

🎯
Focusing
View GitHub Profile
class Solution {
vector<vector<int>> mem;
bool subsetSum(vector<int>& nums,int n,int pos,int sum)
{
if(sum==0) //Sum found
return true;
else if(pos>=n || sum<0) //Out of bounds
return false;
if(mem[pos][sum]!=-1)
return mem[pos][sum];
static int speedUp=[](){
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
class Solution {
public:
int ladderLength(string beginWord, string endWord, vector<string>& wordList) {
class Solution {
public:
int singleNumber(vector<int>& nums) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//Using XOR + AND combination
int ones = 0;
int twos = 0;
for(auto ele: nums)
class Solution {
void dfs(vector<vector<int>>& image, int sr, int sc,int newColor,int rows,int cols,int source)
{
if(sr<0 || sr>=rows || sc<0 || sc>=cols)
return;
else if(image[sr][sc]!=source)
return;
image[sr][sc] = newColor;
class Solution {
public:
int subarraySum(vector<int>& nums, int k) {
//For fast I/O in C++
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n = nums.size();
if(n==0)
// C++ program to implement a stack that supports
// getMinimum() in O(1) time and O(1) extra space.
#include <bits/stdc++.h>
using namespace std;
// A user defined stack that supports getMin() in
// addition to push() and pop()
struct MyStack
{
stack<int> s;
// A Stack based C++ program to find next
// greater element for all array elements.
#include <bits/stdc++.h>
using namespace std;
/* prints element and NGE pair for all
elements of arr[] of size n */
void printNGE(int arr[], int n) {
stack < int > s;
// Program to find minimum number of platforms
// required on a railway station
#include<iostream>
#include<algorithm>
using namespace std;
// Returns minimum number of platforms reqquired
int findPlatform(int arr[], int dep[], int n)
{
@cruiz24
cruiz24 / circleQ.cpp
Last active February 1, 2021 17:50
Implementation of Circular Queue using C++
Implementation using C++ programming
#include <iostream>
#define SIZE 5 /* Size of Circular Queue */
using namespace std;
class Queue {
private:
int items[SIZE], front, rear;
@shubham100795
shubham100795 / findceilfloor.cpp
Created March 2, 2017 14:13
Find ceil and floor of a key in BST
#include<iostream>
#include<cstdlib>
using namespace std;
struct node{
int data;
struct node *left;
struct node *right;
};