左旋转字符串

This commit is contained in:
2023-05-25 10:20:40 +08:00
parent 59586d0eb6
commit 81da2f5b17
3 changed files with 45 additions and 14 deletions
+18 -13
View File
@@ -35,6 +35,14 @@ public:
*/
bool is_number(std::string s);
/**
* 剑指 Offer 58 - II. 左旋转字符串
*
* @url https://leetcode.cn/leetbook/read/illustration-of-algorithm/589fz2/
* @param s
* @param n
* @return
*/
std::string reverse_left_words(std::string s, int n);
};
@@ -55,6 +63,16 @@ public:
void reverse_stack(ListNode *head, std::vector<int> &res);
void reverse(ListNode *head, std::vector<int> &res);
/**
* 剑指 Offer 24. 反转链表
*
* @url https://leetcode.cn/leetbook/read/illustration-of-algorithm/9pdjbm/
* @param head
* @return
*/
ListNode *reverse_list(ListNode *head);
ListNode* reverse_list(ListNode* cur, ListNode* pre);
};
@@ -95,19 +113,6 @@ public:
private:
std::stack<int> _stk;
std::stack<int> _min_stk;
void reverse_stack(ListNode *head, std::vector<int> &res);
void reverse(ListNode *head, std::vector<int> &res);
/**
* 剑指 Offer 24. 反转链表
*
* @url https://leetcode.cn/leetbook/read/illustration-of-algorithm/9pdjbm/
* @param head
* @return
*/
ListNode *reverse_list(ListNode *head);
ListNode* reverse_list(ListNode* cur, ListNode* pre);
};
}