File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ #include < gtest/gtest.h>
3+ using namespace std ;
4+
5+
6+ // // START
7+ /*
8+ ## Stack Sort
9+
10+ */
11+
12+ class Solution {
13+ public:
14+ /*
15+ * @param stk: an integer stack
16+ * @return: void
17+ */
18+ void stackSorting (stack<int >& stk) {
19+ stack<int > st;
20+ while (!stk.empty ()){
21+ auto now = stk.top ();
22+ stk.pop ();
23+ if (st.empty ()){
24+ st.push (now);
25+ }else {
26+ int n = 0 ;
27+ while (!st.empty () && now > st.top ()){
28+ stk.push (st.top ());
29+ st.pop ();
30+ n++;
31+ }
32+ st.push (now);
33+ while (n > 0 ){
34+ n--;
35+ st.push (stk.top ());
36+ stk.pop ();
37+ }
38+ }
39+ }
40+ while (!st.empty ()){
41+ stk.push (st.top ());
42+ st.pop ();
43+ }
44+ }
45+ };
46+
47+
48+ // // END
49+ struct T {
50+
51+ };
52+
53+ TEST (Solution,test){
54+ T ts[] = {
55+ {
56+
57+ },
58+ {
59+
60+ },
61+
62+ };
63+
64+
65+ for (T t : ts){
66+ Solution solution;
67+
68+ }
69+ }
70+
71+ int main () {
72+ testing::InitGoogleTest ();
73+
74+ return RUN_ALL_TESTS ();
75+ }
76+
77+
You can’t perform that action at this time.
0 commit comments