- 博客(11)
- 资源 (4)
- 收藏
- 关注
原创 Palindrome Linked List
题目Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: true总结思路:这题的关键是找到链表的中间节点(medium)用slow和fast两个指...
2018-09-22 19:47:18 124
原创 Reverse Linked List
题目Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULL总结思路一:递归,从后往前反转代码:# Definition for singly-linked list.# class ListNo...
2018-09-21 14:26:09 113
原创 Isomorphic Strings
题目Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot...
2018-09-14 10:46:27 122
原创 Count Primes
题目Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.总结思路一:判断每一个数是不...
2018-09-13 00:09:40 106
原创 Happy Number
题目Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squar...
2018-09-12 00:10:28 311
原创 Factorial Trailing Zeroes
题目Given an integer n, return the number of trailing zeroes in n!.Example 1:Input: 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: 5Output: 1Explanation: 5! = 120, one tra...
2018-09-08 21:04:48 125
原创 Majority Element
题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element ...
2018-09-07 19:27:38 118
原创 Intersection of Two Linked Lists
题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ ...
2018-09-06 14:51:12 110
原创 Linked List Cycle
题目Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?总结我的代码:public class Solution { public boolean hasCycle(ListNode head) ...
2018-09-04 22:31:05 108
原创 Pascal's Triangle II
题目Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal’s triangle.Note that the row index starts from 0. In Pascal’s triangle, each number is the sum of the two numbe...
2018-09-03 23:41:55 117
原创 Minimum Depth of Binary Tree
题目Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no chi...
2018-09-01 01:06:44 93
华为杯研究生数模竞赛2017年试题
2018-09-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人