Koko Eating bananas - LeetCodeProblem Link C++ Code class Solution { bool check(int x, vector<int> &piles, int h, int n) { long long hours = 0; for(int i=0; i<n; i++) { if(piles[i]%x == 0) { hours += piles[i]/x; } el...Jul 28, 2024·2 min read
Longest Substring Without Repeating Characters - LeetCodeProblem Link C++ Code class Solution { public: int lengthOfLongestSubstring(string s) { int n = s.size(); vector<bool> isPresent(256, false); int i=0, j=0; int maxLength = 0; while(j<n) { i...Jul 27, 2024·1 min read
Two Sum - LeetCodeProblem Link C++ Code class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { map<int, int> hashMap; vector<int> ans; for(int i=0; i<nums.size(); i++) { int num = nums[i]; ...Jul 27, 2024·1 min read
Segment Trees - Introduction#include <bits/stdc++.h> using namespace std; int n; vector<int> a; vector<int> segTree; // build function to build the segment tree void build(int i, int j, int k) { // i -> starting index of a part of the array // j -> ending index of a...Jul 25, 2024·2 min read