Skip to content

Commit f757894

Browse files
committed
7-jan-24
0 parents  commit f757894

9 files changed

+385
-0
lines changed

.vscode/settings.json

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"files.associations": {
3+
"ostream": "cpp",
4+
"stdc++": "cpp",
5+
"__bit_reference": "cpp",
6+
"__config": "cpp",
7+
"__debug": "cpp",
8+
"__errc": "cpp",
9+
"__hash_table": "cpp",
10+
"__locale": "cpp",
11+
"__mutex_base": "cpp",
12+
"__node_handle": "cpp",
13+
"__split_buffer": "cpp",
14+
"__threading_support": "cpp",
15+
"__tree": "cpp",
16+
"__verbose_abort": "cpp",
17+
"any": "cpp",
18+
"array": "cpp",
19+
"atomic": "cpp",
20+
"barrier": "cpp",
21+
"bitset": "cpp",
22+
"cctype": "cpp",
23+
"cfenv": "cpp",
24+
"charconv": "cpp",
25+
"cinttypes": "cpp",
26+
"clocale": "cpp",
27+
"cmath": "cpp",
28+
"codecvt": "cpp",
29+
"complex": "cpp",
30+
"condition_variable": "cpp",
31+
"csetjmp": "cpp",
32+
"csignal": "cpp",
33+
"cstdarg": "cpp",
34+
"cstddef": "cpp",
35+
"cstdint": "cpp",
36+
"cstdio": "cpp",
37+
"cstdlib": "cpp",
38+
"cstring": "cpp",
39+
"ctime": "cpp",
40+
"cuchar": "cpp",
41+
"cwchar": "cpp",
42+
"cwctype": "cpp",
43+
"deque": "cpp",
44+
"exception": "cpp",
45+
"coroutine": "cpp",
46+
"forward_list": "cpp",
47+
"fstream": "cpp",
48+
"future": "cpp",
49+
"initializer_list": "cpp",
50+
"iomanip": "cpp",
51+
"ios": "cpp",
52+
"iosfwd": "cpp",
53+
"iostream": "cpp",
54+
"istream": "cpp",
55+
"latch": "cpp",
56+
"limits": "cpp",
57+
"list": "cpp",
58+
"locale": "cpp",
59+
"map": "cpp",
60+
"mutex": "cpp",
61+
"new": "cpp",
62+
"numbers": "cpp",
63+
"optional": "cpp",
64+
"queue": "cpp",
65+
"ratio": "cpp",
66+
"regex": "cpp",
67+
"scoped_allocator": "cpp",
68+
"semaphore": "cpp",
69+
"set": "cpp",
70+
"shared_mutex": "cpp",
71+
"source_location": "cpp",
72+
"span": "cpp",
73+
"sstream": "cpp",
74+
"stack": "cpp",
75+
"stdexcept": "cpp",
76+
"streambuf": "cpp",
77+
"string": "cpp",
78+
"string_view": "cpp",
79+
"system_error": "cpp",
80+
"thread": "cpp",
81+
"tuple": "cpp",
82+
"typeindex": "cpp",
83+
"typeinfo": "cpp",
84+
"unordered_map": "cpp",
85+
"unordered_set": "cpp",
86+
"valarray": "cpp",
87+
"variant": "cpp",
88+
"vector": "cpp",
89+
"algorithm": "cpp"
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int areaOfMaxDiagonal(vector<vector<int>>& n) {
4+
int a=0,l=0;
5+
for(auto i:n)
6+
if(i[0]*i[0]+i[1]*i[1]>=l)
7+
l=i[0]*i[0]+i[1]*i[1];
8+
for(auto i:n)
9+
if(i[0]*i[0]+i[1]*i[1]==l)
10+
a=max(a,i[0]*i[1]);
11+
return a;
12+
}
13+
};

Untitled-1

Whitespace-only changes.

count_symetric_integers.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include<bits/stdc++>
2+
using namespace std;
3+
int main(){
4+
5+
return 0;
6+
}

koko_eating_bananas.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
long long int help(vector<int>&arr,int n,int s){
4+
if(n<s){
5+
return 0;
6+
}
7+
long long int nt=help(arr,n-1,s);
8+
long long int t=arr[n]+help(arr,n-2,s);
9+
return max(t,nt);
10+
}
11+
long long int houseRobber(vector<int>& arr)
12+
{
13+
int n=arr.size();
14+
int m=n-1;
15+
long long int ans1=0;
16+
ans1=help(arr,n-1,1);
17+
long long int ans2=0;
18+
ans2=help(arr,n-2,0);
19+
return max(ans1,ans2);
20+
}
21+
int main(){
22+
23+
vector<int>arr = {1,2,3,4,5,4,3,2,5,1};
24+
cout<<houseRobber(arr)<<endl;
25+
}

leetcode_b_111.cpp

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
#define pb push_back
4+
typedef long long int ll;
5+
int findPairs(vector<ll>arr,ll n,ll x)
6+
{
7+
ll l = 0, r = n-1;
8+
ll result = 0;
9+
while (l < r)
10+
{
11+
if (arr[l] + arr[r] < x)
12+
{
13+
result += (r - l);
14+
l++;
15+
}
16+
else
17+
r--;
18+
}
19+
20+
return result;
21+
}
22+
int help(vector<int>v,int n,int i,int c){
23+
if(i==n)
24+
{
25+
if(v[i-1]<v[i-2]){
26+
return INT_MAX;
27+
}
28+
// for(int id=1;id<n;id++){
29+
// if(v[id]<v[id-1]){
30+
// return INT_MAX;
31+
// }
32+
// }
33+
return c;
34+
}
35+
if(i>=2 && v[i-1]<v[i-2]){
36+
return INT_MAX;
37+
}
38+
if(i>=2){
39+
int j=1;
40+
int k=i-1;
41+
while(j<=k){
42+
if(v[j]<v[j-1] || v[k]<v[k-1]){
43+
return INT_MAX;
44+
}
45+
}
46+
}
47+
int nt=help(v,n,i+1,c);
48+
v[i]=1;
49+
int ct1=help(v,n,i+1,c+1);
50+
v[i]=2;
51+
int ct2=help(v,n,i+1,c+1);
52+
v[i]=3;
53+
int ct3=help(v,n,i+1,c+1);
54+
return min({nt,ct1,ct2,ct3});
55+
}
56+
int minimumOperations(vector<int>& nums) {
57+
int n=nums.size();
58+
vector<int>t={};
59+
int co=0;
60+
vector<int>nums2=nums;
61+
int f=0;
62+
sort(nums2.begin(),nums2.end());
63+
int cc=0;
64+
for(int i=0;i<n;i++){
65+
if(nums2[i]!=nums[i]){
66+
f=1;
67+
cc++;
68+
// break;
69+
}
70+
}
71+
if(f==0){
72+
return 1;
73+
}
74+
for(int i=0;i<n;i++){
75+
auto f=upper_bound(nums.begin(),nums.end(),nums[i]);
76+
if(f==t.end()){
77+
t.push_back(nums[i]);
78+
}
79+
else if(f!=t.end()){
80+
int jk=abs(t.begin()-f);
81+
t[jk]=min(jk,nums[i]);
82+
co++;
83+
}
84+
}
85+
return co;
86+
87+
88+
89+
90+
91+
92+
int i1=0;
93+
// int ans=help(nums,n,0,0);
94+
// cout<<cc<<endl;
95+
// return min(cc,ans);
96+
}
97+
int main(){
98+
int t;
99+
t=1;
100+
101+
// for(int i=0;i<33;i++){
102+
// cout<<"3,";
103+
// }for(int i=0;i<33;i++){
104+
// cout<<"2,";
105+
// }
106+
// for(int i=0;i<34;i++){
107+
// cout<<1<<",";
108+
// }
109+
110+
// cin>>t;
111+
// t=0;
112+
while(t--){
113+
vector<int>v={1,3,2,1,2,2,3,3,2,1,2,3,1};
114+
int n=v.size();
115+
v={1,2,3};
116+
int i=n;
117+
int j=1;
118+
int k=i-1;
119+
while(j<=k){
120+
cout<<j<<" "<<k<<endl;
121+
// if(v[j]<v[j-1] || v[k]<v[k-1]){
122+
// cout<<"-\n";
123+
// }
124+
j++;
125+
k--;
126+
}
127+
cout<<"!!";
128+
// cout<<minimumOperations(v);
129+
}
130+
}

leetcode_c_111

185 KB
Binary file not shown.

0 commit comments

Comments
 (0)