2020年9月6日

翻转字符串(坑比较多)

摘要: Given an input string, reverse the string word by word. Example 1: Input: "the sky is blue" Output: "blue is sky the" Example 2: Input: " hello world! 阅读全文

posted @ 2020-09-06 18:23 wsw_seu 阅读(156) 评论(0) 推荐(0) 编辑

(字符串)子串变位词

摘要: 题目: 给定两个串a和b,问b是否是a的子串的变位词,例如输入a=hello,b=lel,lle,ello都是true,但b=elo是false。(字串是连续的) 思路: 滑动窗口思想:动态维护一个“窗口”,比如b的长度是3,考察a[0..2],a[1..3],a[2..4]是否是b的变位词,关键在 阅读全文

posted @ 2020-09-06 17:16 wsw_seu 阅读(128) 评论(0) 推荐(0) 编辑

反转链表 II

摘要: 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 说明:1 ≤ m ≤ n ≤ 链表长度。 示例: 输入: 1->2->3->4->5->NULL, m = 2, n = 4输出: 1->4->3->2->5->NULL /** * Definition for singly-linked 阅读全文

posted @ 2020-09-06 11:37 wsw_seu 阅读(140) 评论(0) 推荐(0) 编辑

翻转链表

摘要: 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; 阅读全文

posted @ 2020-09-06 11:36 wsw_seu 阅读(82) 评论(0) 推荐(0) 编辑

导航