This repository contains the solutions and explanations to the algorithm problems on LeetCode. Only medium or above are included. All are written in C++/Python and implemented by myself. The problems attempted multiple times are labelled with hyperlinks.
0025 Reverse Nodes in k-Group Go 53.4% Hard 0026 Remove Duplicates from Sorted Array Go 50.3% Easy 0027 Remove Element Go 52.0% Easy 0028 Find the Index of the First Occurrence in a String Go 37.4% Medium 0029 Divide Two Integers Go 17.4% Medium 0030 Substring with Concatenation of...
classSolution{int maxscore=0;public:intmaxScoreWords(vector<string>&words,vector<char>&letters,vector<int>&score){int n=words.size(),i;vector<int>count(26,0);for(i=0;i<letters.size();++i)count[letters[i]-'a']++;//可使用的字母数量dfs(words,count,score,0,0);returnmaxscore;}void...
LC 1799. N 次操作后的最大分数和 题解:dp[i]表示状态i的最大分数,可以由子集j转移而来,i减去两个1形成j class Solution { public: int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } int maxScore(vector<int>& nums) { int n = nums.size(); int dp[1<<n]; memset(dp,...
Each number in candidates may only be used once in the combination. Note: All numbers (including target) will be positive integers. The solution set must not contain duplicate combinations. Example 1: Input: candidates = [10,1,2,7,6,1,5], target = 8, A solution set is: [ [1, 7]...
class Solution { public: int ladderLength(string start, string end, unordered_set<string> &dict) { if(start.size() == 0 || end.size() == 0) return 0; queue<string> wordQ; wordQ.push(start); wordQ.push(""); int path = 1; ...
1796. Second Largest Digit in a String 1797. Design Authentication Manager 1798. Maximum Number of Consecutive Values You Can Make 1799. Maximize Score After N OperationsWeekly Contest 2321790. Check if One String Swap Can Make Strings Equal 1791. Find Center of Star Graph 1792. Maximum ...
"solution/1600-1699/1661.Average Time of Process per Machine/Solution.sql", "solution/1600-1699/1667.Fix Names in a Table/Solution.sql", "solution/1600-1699/1699.Number of Calls Between Two Persons/Solution.sql", "solution/1700-1799/1777.Product's Price for Each Store/Solution.sql",...
LeetCode Daily Questions Solution. Contribute to Yashmenaria1/Leetcode_daily_solutions development by creating an account on GitHub.
25 Reverse Nodes in k-Group Hard Solution 26 Remove Duplicates from Sorted Array Easy Solution 27 Remove Element Easy Solution 28 Implement strStr() Easy Solution 29 Divide Two Integers Medium Solution 30 Substring with Concatenation of All Words Hard Solution 31 Next Permutation Medium Solution 32...