diff --git a/192. Word Frequency b/192. Word Frequency new file mode 100644 index 0000000..603c653 --- /dev/null +++ b/192. Word Frequency @@ -0,0 +1 @@ +tr -s ' ' '\n' < words.txt | sort | uniq -c | sort -nr | awk '{print $2, $1}' diff --git a/197. Rising Temperature b/197. Rising Temperature new file mode 100644 index 0000000..c28f849 --- /dev/null +++ b/197. Rising Temperature @@ -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 +; diff --git a/Find Customer Referee b/Find Customer Referee new file mode 100644 index 0000000..0739cc0 --- /dev/null +++ b/Find Customer Referee @@ -0,0 +1,3 @@ +SELECT name +FROM Customer +WHERE referee_id IS NULL OR referee_id != 2; diff --git a/Print FooBar Alternately b/Print FooBar Alternately new file mode 100644 index 0000000..af087fd --- /dev/null +++ b/Print FooBar Alternately @@ -0,0 +1,30 @@ +class FooBar { +private: + int n; + mutex m1,m2; +public: + FooBar(int n) { + m2.lock(); + this->n = n; + } + + void foo(function 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 printBar) { + + for (int i = 0; i < n; i++) { + m2.lock(); + // printBar() outputs "bar". Do not change or remove this line. + printBar(); + m1.unlock(); + } + } +}; diff --git a/Rank Scores b/Rank Scores new file mode 100644 index 0000000..cc20088 --- /dev/null +++ b/Rank Scores @@ -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"])