19. 删除链表的倒数第N个节点 [toc] 1、题目介绍 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 试题链接:https://leetcode cn.com/problems/remove nth node from end of list/ 2、java 2.1、遍历两 ...
分类:
其他好文 时间:
2020-03-02 22:47:07
阅读次数:
64
链接:https://leetcode-cn.com/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof/ 思路: cnt记录个数,val记录值;遍历数组,若等于val,则cnt++,否则cnt--,若cnt为0, ...
分类:
编程语言 时间:
2020-03-02 22:42:00
阅读次数:
70
链接:https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/ 代码: class Solution { public: vector<string> permutation(string s) { vector<string> re ...
分类:
其他好文 时间:
2020-03-02 22:27:15
阅读次数:
49
160. 相交链表 [toc] 1、试题介绍 编写一个程序,找到两个单链表相交的起始节点。 试题链接:https://leetcode cn.com/problems/intersection of two linked lists/ 2、java做法 2.1、双重循环 测试结果: 2.2、双指针做 ...
分类:
其他好文 时间:
2020-03-02 20:41:45
阅读次数:
64
原题链接在这里:https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/ 题目: You have a pointer at index 0 in an array of size ...
分类:
其他好文 时间:
2020-03-02 14:34:45
阅读次数:
88
反转一个单链表。 示例: 进阶: 你可以迭代或递归地反转链表。你能否用两种方法解决这道题? https://leetcode cn.com/problems/reverse linked list/ 迭代 思路是在原链表之前建立一个空的newHead,因为首节点会变,然后从head开始,将之后的一个 ...
分类:
其他好文 时间:
2020-03-02 13:02:26
阅读次数:
40
反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 说明: 1 ≤ m ≤ n ≤ 链表长度。 示例: https://leetcode cn.com/problems/reverse linked list ii/ 迭代 1 2 3 4 5 NULL 1 3 2 4 5 NULL 1 4 3 ...
分类:
其他好文 时间:
2020-03-02 12:48:00
阅读次数:
70
A. Contest for Robots Polycarp is preparing the first programming contest for robots. There are 𝑛n problems in it, and a lot of robots are going to p ...
分类:
其他好文 时间:
2020-03-02 01:18:29
阅读次数:
74
题目: https://leetcode-cn.com/problems/compress-string-lcci/ 字符串压缩。利用字符重复出现的次数,编写一种方法,实现基本的字符串压缩功能。比如,字符串aabcccccaaa会变为a2b1c5a3。若“压缩”后的字符串没有变短,则返回原先的字符串 ...
分类:
其他好文 时间:
2020-03-01 16:01:32
阅读次数:
63
题目: https://leetcode-cn.com/problems/is-unique-lcci/ 实现一个算法,确定一个字符串 s 的所有字符是否全都不同。 示例 1: 输入: s = "leetcode"输出: false 示例 2: 输入: s = "abc"输出: true限制: 0 ...
分类:
其他好文 时间:
2020-03-01 14:14:40
阅读次数:
71