Eeclaircpincompetitive-programming.hashnode.dev·Jul 28, 2024 · 2 min readKoko 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...00
Eeclaircpincompetitive-programming.hashnode.dev·Jul 28, 2024 · 2 min readFind Peak Element - LeetCodeProblem Link C++ Code class Solution { public: int findPeakElement(vector<int>& nums) { int n = nums.size(); if(n == 1) return 0; int low = 0; int high = n-1; while(low <= high) { ...00
Eeclaircpincompetitive-programming.hashnode.dev·Jul 28, 2024 · 1 min readFind Minimum in Rotated Sorted Array - LeetCodeProblem Link C++ Code class Solution { public: int findMin(vector<int>& nums) { int low = 0; int high = nums.size() - 1; int ans = INT_MAX; while(low <= high) { int mid = low + (high-low)/2; ...00
Eeclaircpincompetitive-programming.hashnode.dev·Jul 28, 2024 · 2 min readSearch in Rotated Sorted Array II - LeetCodeProblem Link C++ Code class Solution { public: bool search(vector<int>& nums, int target) { int low = 0, high = nums.size()-1; while(low <= high) { int mid = low + (high-low)/2; if(nums[mid] == target) ...00
Eeclaircpincompetitive-programming.hashnode.dev·Jul 27, 2024 · 1 min readPow(x, n) - LeetCodeProblem Link C++ Code class Solution { double pow(double x, long long n) { if(n==0) return 1; if(n%2==0) { return pow(x*x, n/2); } else { return x*pow(x, n-1); } } publi...00