Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Akash Kumar/1.GroupAnagrams/Screenshot .png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Akash Kumar/1.GroupAnagrams/soln.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//LeetCode Environment
//Time Complexity=O(N∗M)
//Space Complexity=O(N∗M)

class Solution {
public:

string generate(string word)
{
int arr[26]={0};
for(char ch:word)
{
arr[ch-'a']++;
}
string new_word="";
for(int i=0;i<26;i++)
{
int freq=arr[i];
if(freq>0)
{
new_word+=string(freq,i+'a');
}
}
return new_word;
}
vector<vector<string>> groupAnagrams(vector<string>& strs)
{
unordered_map<string, vector<string>>mp;
vector<vector<string>>result;
for(int i=0;i<strs.size();i++)
{
string word=strs[i];
string new_word=generate(word);
mp[new_word].push_back(word);
}
for(auto it:mp)
{
result.push_back(it.second);
}
return result;

}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Akash Kumar/2.MaxConsecutiveOnes3/soln.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//LeetCode Environment
//Time Complexity=O(N)
//Space Complexity=O(1)

class Solution {
public:
int longestOnes(vector<int>& nums, int k)
{
int ans=0;
int l=0;
for (int r=0;r<nums.size();r++)
{
if (nums[r]==0)
{
k--;
}
if (k<0)
{
if (nums[l]==0)
{
k++;
}
l++;
}
ans=max(ans,r-l+1);
}
return ans;
}
};
Binary file removed Leetcode DSA sheet by Fraz 1.xlsx
Binary file not shown.
154 changes: 0 additions & 154 deletions README.md

This file was deleted.