Skip to content

Commit beefce3

Browse files
authored
Merge branch 'master' into master
2 parents 6a3a7d1 + 3da0a20 commit beefce3

29 files changed

Lines changed: 892 additions & 35 deletions

Code.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
arr=[-1,-1,-1]
2+
pos=0
3+
neg=0
4+
zero=0
5+
step=0
6+
for i in range(len(arr)):
7+
if arr[i]==0:
8+
zero=zero+1
9+
elif arr[i]<0:
10+
neg=neg+1
11+
step=step+(-1-arr[i])
12+
else:
13+
pos=pos+1
14+
step=step+(arr[i]-1)
15+
if(neg%2==0):
16+
step=step+zero
17+
18+
else:
19+
if(zero>0):
20+
step=step+zeo
21+
else:
22+
step=step+2
23+
print(step)
24+

Converter.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
print ("1. Temp")
2+
print ("2. speed")
3+
print ("3. area")
4+
5+
aa= int(input("want to convert in "))
6+
7+
def temp(t):
8+
9+
switcher = {
10+
1: (((b*9)/5)+32),
11+
2: (((b-32)*5)/9),
12+
}
13+
return switcher.get(t, "nothing")
14+
def Speed(s):
15+
switcher ={
16+
17+
18+
1: ((b*5)/18),
19+
2: ((b*18)/5),
20+
}
21+
return switcher.get(s, "nothing")
22+
23+
def area(a):
24+
switcher ={
25+
26+
27+
1: (b*39.37),
28+
2: (b*3.281),
29+
3: (b*10.764),
30+
4: (b*0.0001),
31+
5: (b*0.000247),
32+
}
33+
return switcher.get(a, "nothing")
34+
35+
if (aa==1):
36+
print ("1. degree C to degree F")
37+
print ("2. degree F to degree C")
38+
t=int(input("enter the converter number "))
39+
b=int(input("enter the data "))
40+
print(temp(t))
41+
42+
elif (aa==2):
43+
print ("1. km/hr to m/s")
44+
print ("2. m/s to km/hr")
45+
s=int(input("enter the converter number "))
46+
b=int(input("enter the data "))
47+
print(Speed(s))
48+
49+
elif (aa==3):
50+
print ("1. m to inch")
51+
print ("2. m to feet")
52+
print ("3. m.sq to sq.feet")
53+
print ("4. m.sq to hectare")
54+
print ("5. m.sq to acre")
55+
a=int(input("enter the converter number "))
56+
b=int(input("enter the data "))
57+
print(area(a))
58+

EvenOdd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class EvenOdd{
2+
3+
public static void main(String []args){
4+
int number = 10;
5+
if(number%2==0){
6+
System.out.println("Even");
7+
}
8+
else{
9+
System.out.println("Odd");
10+
}
11+
}
12+
}

Hello_World_in_every_language/HelloWorld.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
class HelloWorld {
44
public static void main(String[] args) {
5-
System.out.println("Hello World");
5+
System.out.println("Hello World!!!");
66
}
77
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Hello World in Kotlin
2+
3+
fun main(args: Array<String>){
4+
println("Hello World")
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello World");
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
>++++++++[<+++++++++>-]<.
2+
>++++[<+++++++>-]<+.
3+
+++++++..
4+
+++.
5+
>>++++++[<+++++++>-]<++.
6+
------------.
7+
>++++++[<+++++++++>-]<+.
8+
<.
9+
+++.
10+
------.
11+
--------.
12+
>>>++++[<++++++++>-]<+.

Maximum Expression.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
Problem
3+
You are given a string SS of length NN, consisting of the digits 0-9 and the characters '+' and '-'. SS represents a valid mathematical expression.
4+
5+
Rearrange the characters of SS to form a valid mathematical expression such that the result obtained upon evaluating it is maximum.
6+
7+
If there are multiple possible answers, you may print any of them.
8+
9+
Note: A string SS of length NN is said to be a valid mathematical expression if the following hold:
10+
11+
The first character of SS is not + or -.
12+
The last character of SS is not + or -.
13+
Any + or - in SS must not be adjacent to another + or -.
14+
In particular, numbers are allowed to have leading zeros, and adding/subtracting zero is fine.
15+
16+
Input Format
17+
The first line of input will contain a single integer TT, denoting the number of test cases.
18+
Each test case consists of 22 lines of input.
19+
The first line of each test case contains a single integer NN, denoting the size of the string.
20+
The second line of each test case contains the string SS.
21+
Output Format
22+
For each test case, output on a new line the rearranged string giving the maximum value upon evaluation. If there are multiple possible answers, you may print any of them.
23+
24+
Constraints
25+
1 \leq T \leq 10001≤T≤1000
26+
3 \leq N \leq 10^53≤N≤10
27+
5
28+
29+
Each character of SS is one of \{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, -\}{0,1,2,3,4,5,6,7,8,9,+,−}.
30+
The sum of N across all test cases won't exceed 1.5 \times 10^61.5×10
31+
6
32+
.
33+
Sample 1:
34+
Input
35+
Output
36+
3
37+
7
38+
4-89+20
39+
5
40+
5-9+0
41+
3
42+
9-5
43+
984+2-0
44+
5+9-0
45+
9-5
46+
Explanation:
47+
Test case 11: The given output expression evaluates to 986986, which is the maximum possible.
48+
49+
Test case 22: The given output expression evaluates to 1414, which is the maximum possible.
50+
51+
Test case 33: The given output expression evaluates to 44, which is the maximum possible.
52+
*/
53+
54+
#include <bits/stdc++.h>
55+
#include <bits/stdc++.h>
56+
57+
using namespace std;
58+
59+
int main() {
60+
int talab;
61+
cin>>talab;
62+
while(talab--){
63+
int f;
64+
cin>>f;
65+
string s;
66+
cin>>s;
67+
int plus = 0, minus = 0, dig = 0;
68+
int d[10] = {0};
69+
for (int i = 0; i < f; i++) {
70+
if(s[i] == '+'){
71+
plus++;
72+
}
73+
else if(s[i]=='-'){
74+
minus++;
75+
}
76+
else{
77+
d[s[i]-'0']++;
78+
dig++;
79+
}
80+
}
81+
string ans = "";
82+
int i = 9;
83+
while(dig-(plus+minus)){
84+
if(d[i] == 0){
85+
i--;
86+
continue;
87+
}
88+
ans += ('0'+i);
89+
d[i]--;
90+
dig--;
91+
}
92+
while(plus){
93+
if(d[i] == 0){
94+
i--;
95+
continue;
96+
}
97+
ans += '+';
98+
ans += ('0'+i);
99+
d[i]--;
100+
plus--;
101+
}
102+
while(minus){
103+
if(d[i] == 0){
104+
i--;
105+
continue;
106+
}
107+
ans += '-';
108+
ans += ('0'+i);
109+
d[i]--;
110+
minus--;
111+
}
112+
cout<<ans;
113+
cout<<"\n";
114+
}
115+
return 0;
116+
}

Queue Using Stack.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*Problem Link: https://leetcode.com/problems/implement-queue-using-stacks/description/
2+
3+
4+
5+
Problem Description:
6+
Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty).
7+
8+
Implement the MyQueue class:
9+
10+
void push(int x) Pushes element x to the back of the queue.
11+
int pop() Removes the element from the front of the queue and returns it.
12+
int peek() Returns the element at the front of the queue.
13+
boolean empty() Returns true if the queue is empty, false otherwise.
14+
15+
16+
17+
Approach: The idea is to make use of 2 stacks and work as follows:
18+
1. In case of PUSH , simply push the element to first stack
19+
2. In case of POP, element will be popped from second stac always, therefore if the stack 2 is not empty pop the element from it else pop all elements from
20+
stack 1 and push it to stack 2 and the pop the element from stack 2.
21+
3. In case of PEEK, perform the operations exactly as in peek just do not pop from stack2 instead return the top element
22+
4. In case of EMPTY CHECK make sure both the stacks are empty for the Oueue to be empty
23+
24+
Using this algorithm we can implement all the functionalities of Queue using stacks.
25+
26+
There would only be certain instances where the time complexity would go O(n) for ceratin operations. Most of the operations would be O(1). Thus we say it is amortised time complexity
27+
28+
29+
30+
Time Complexity: O(1) (amortized -- performing n operations will take overall O(n) time even if one of those operations may take longer)
31+
Space Complexity: O(2n)
32+
33+
34+
35+
36+
Implementation in C++:
37+
38+
/**
39+
* Your MyQueue object will be instantiated and called as such:
40+
* MyQueue* obj = new MyQueue();
41+
* obj->push(x);
42+
* int param_2 = obj->pop();
43+
* int param_3 = obj->peek();
44+
* bool param_4 = obj->empty();
45+
*/
46+
47+
class MyQueue
48+
{
49+
public:
50+
stack<int> st1, st2;
51+
52+
MyQueue()
53+
{
54+
}
55+
56+
void push(int x)
57+
{
58+
st1.push(x);
59+
}
60+
61+
int pop()
62+
{
63+
64+
if (st2.empty())
65+
{
66+
while (!st1.empty())
67+
{
68+
st2.push(st1.top());
69+
st1.pop();
70+
}
71+
}
72+
int ele = st2.top();
73+
st2.pop();
74+
return ele;
75+
}
76+
77+
int peek()
78+
{
79+
if (st2.empty())
80+
{
81+
while (!st1.empty())
82+
{
83+
st2.push(st1.top());
84+
st1.pop();
85+
}
86+
}
87+
88+
return st2.top();
89+
}
90+
91+
bool empty()
92+
{
93+
return st1.empty() && st2.empty();
94+
}
95+
};

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# CodingClubIndia
22

3+
34
This repo is to demonstrate the GIT version control and promote Hacktober fest.
45

6+
How?
7+
You can share the best pieces of code in this repo written in any language, we will review the code and merge accordingly. Additionally we are using this readme for maintaining the name of contributos, feel free to add your name here :)
8+
59
Watch these videos before contributing
610
[Intro to Hacktoberfest and Open Source](https://www.youtube.com/watch?v=RdwbdOKMiTc&t=27s)
11+
12+
713
[Hands-On Demo of Hacktoberfest](https://www.youtube.com/watch?v=-PAcwWag-hI)
814

915
Please add your names below:
1016

17+
Kiran Patil (Maharashtra)
18+
1119
Suraj Keshari ( VARANASI ).
1220

1321
Shubham Kumar (Chattisgarh).
@@ -374,6 +382,14 @@ Royal Simpson Pinto (Mangalore)
374382

375383
Kaustubh Jogle (Mumbai)
376384

385+
Ashutosh Kosti (Jabalpur)
386+
377387
Ananya Gupta (Indore)
378388

379389
Sumukha Sureban (Betageri-Gadag)
390+
391+
Aayush Solanki (Indore)
392+
393+
Aaditya Mayankar (Pune)
394+
395+
Vanshika Pandey (Lucknow)

0 commit comments

Comments
 (0)