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
1 change: 1 addition & 0 deletions 192. Word Frequency
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tr -s ' ' '\n' < words.txt | sort | uniq -c | sort -nr | awk '{print $2, $1}'
7 changes: 7 additions & 0 deletions 197. Rising Temperature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT today.id
FROM Weather yesterday
CROSS JOIN Weather today

WHERE DATEDIFF(today.recordDate,yesterday.recordDate) = 1
AND today.temperature > yesterday.temperature
;
3 changes: 3 additions & 0 deletions Find Customer Referee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT name
FROM Customer
WHERE referee_id IS NULL OR referee_id != 2;
30 changes: 30 additions & 0 deletions Print FooBar Alternately
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class FooBar {
private:
int n;
mutex m1,m2;
public:
FooBar(int n) {
m2.lock();
this->n = n;
}

void foo(function<void()> printFoo) {

for (int i = 0; i < n; i++) {
m1.lock();
// printFoo() outputs "foo". Do not change or remove this line.
printFoo();
m2.unlock();
}
}

void bar(function<void()> printBar) {

for (int i = 0; i < n; i++) {
m2.lock();
// printBar() outputs "bar". Do not change or remove this line.
printBar();
m1.unlock();
}
}
};
19 changes: 19 additions & 0 deletions Rank Scores
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pandas as pd

def order_scores(scores: pd.DataFrame) -> pd.DataFrame:
occr_dict = Counter(scores["score"])

intr_arr = []
for key, freq in occr_dict.items():
intr_arr.append([key, freq])

intr_arr.sort(reverse = True)

ans = []

for i, e in enumerate(intr_arr):

for j in range(e[1]):
ans.append([e[0], i + 1])

return pd.DataFrame(ans, columns=["score", "rank"])