这个题,不要忘了一开始check num == 1?
分类:LeetCode
[LeetCode] Remove Duplicates from Sorted List 移除有序链表中的重复项
Given a sorted linked list, delete all duplicates such that each element appear only once. Example…
LeetCode | Count and Say(统计并输出)
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1&nbs…
[array] leetCode-18. 4Sum -Medium
18. 4Sum -Medium descrition Given an array S of n integers, are there elements a, b, c, and d in S such that a…
323. Number of Connected Components in an Undirected Graph
Medium Given n nodes labeled from “0 to n - 1 and a list of undirected edges (each edge is a pair of nod…
89. Gray Code
/* 89. Gray Code Total Accepted: 57721 Total Submissions: 160293 Difficulty: Medium The gray code is a binary …
LeetCode | ZigZag Conversion(锯齿形转换)
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you…
LeetCode 27. Remove Element
题目 给定一个数组和一个值,在原地删除与值相同的数字,返回新数组的长度。 元素的顺序可以改变,并且对新的数组不会有影响。 样例 给出一个数组[0,4,4,0,0,2,4,4],和值 4返回 4 并且4个元素的新数组为[0…
LeetCode 总结 - 搞不定 Dynamic Programming 面试题
emmm…动态规划就练几个简单的题吧,其他的搞不定,告辞告辞~ 如何想到使用DP 找最大值/最小值(maximum/minimum) 判断是否可行(yes/no) 所有可能结果的数量(count) 解题思路 …
二刷15. 3Sum
Medium 过两天面Yelp, k sum在最近面经里频率还行,拿来做做吧。还是处理edge case的时候卡了一下, 记一下内部的while循环要记得加上bound: left < right, 顺便再记一下这…
[LeetCode By Go 98]172. Factorial Trailing Zeroes
题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmi…
LeetCode 090 Subsets II
题目描述 Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: El…