摘要: 使用双指针技巧,判断链表中是否有环。 struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution { public: bool hasCycle(ListNo 阅读全文
posted @ 2020-03-10 22:36 jenningszheng 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 输入一个链表,按链表从尾到头的顺序返回一个ArrayList。 struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; class Solution { public: 阅读全文
posted @ 2020-03-10 20:48 jenningszheng 阅读(96) 评论(0) 推荐(0) 编辑
摘要: struct Node { int val; Node *next; Node(int x): val(x), next(nullptr){}; }; class MyLinkedList { public: /** Initialize your data structure here. */ i 阅读全文
posted @ 2020-03-10 18:33 jenningszheng 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 class Solution { public: void replaceSpace(char *str,int length) { int 阅读全文
posted @ 2020-03-10 16:07 jenningszheng 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 class Solution { public: bool Find(int target, vector 阅读全文
posted @ 2020-03-10 16:04 jenningszheng 阅读(88) 评论(0) 推荐(0) 编辑