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
40 changes: 40 additions & 0 deletions Day-17/Q1:Determine if two strings are close/kalpana--cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Solution {
public:
bool closeStrings(string word1, string word2) {
if (word1.length() != word2.length())
return false;

unordered_map<char, int> count1;
unordered_map<char, int> count2;
string s1;
string s2;
vector<int> freqs1;
vector<int> freqs2;

for (const char c : word1)
++count1[c];

for (const char c : word2)
++count2[c];

for (const auto& [c, freq] : count1) {
s1 += c;
freqs1.push_back(freq);
}

for (const auto& [c, freq] : count2) {
s2 += c;
freqs2.push_back(freq);
}

ranges::sort(s1);
ranges::sort(s2);

if (s1 != s2)
return false;

ranges::sort(freqs1);
ranges::sort(freqs2);
return freqs1 == freqs2;
}
};
18 changes: 18 additions & 0 deletions Day-21/q2 : Container With Most Water/kalpana--python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
left = 0
right = len(height) - 1
distance = right - left
max_area = 0
while left < right:
max_area = max(min(height[left],height[right]) * distance, max_area)
if height[left] < height[right]:
left += 1
else:
right -= 1
distance -= 1
return max_area
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:
vector<int> searchRange(vector<int>& nums, int target) {
vector<int> ans(2,-1);
if(nums.size()==0)return ans;
int t1=lower_bound(nums.begin(),nums.end(),target)-nums.begin();
int t2=upper_bound(nums.begin(),nums.end(),target)-nums.begin();
if(t1==t2)return ans;
cout<<t1<<t2;
ans[0]=t1;
ans[1]=t2-1;
return ans;
}
};