![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
andy_gfz
这个作者很懒,什么都没留下…
展开
-
【leetcode】336 Palindrome Pairs
题目Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e.words[i] + words[j] is a palindrome.Example 1原创 2017-06-18 18:56:46 · 306 阅读 · 0 评论 -
二进制中1的个数
一.题目输入一个整数,输出该数的二进制表示中1的个数。二.分析1.可能引起死循环的解法int NumberOf1(int n){ int count = 0; while(n != 0){ if((n & 1) != 0){ count+; } n = n >> 1; } return count;}在实际编程中,除法的效率原创 2018-01-13 21:46:12 · 197 阅读 · 0 评论 -
反转链表
一.题目定义一个函数,反转链表后,输出链表的所有元素。二.分析需要注意以下三种问题:(1)输入的链表头为指针为null,或者整个链表只有一个结点时,程序奔溃(2)反转后的链表出现断裂(3)返回的反转之后的头结点不是原始链表的尾结点。三.代码/*public class ListNode { int val; ListNode next原创 2018-01-13 20:44:20 · 196 阅读 · 0 评论 -
leetcode 150.Evaluate Reverse Polish Notation
一 .题目Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2",原创 2017-12-24 16:35:45 · 194 阅读 · 0 评论 -
LeetCode 672. Bulb Switcher II
1.题目房间里有n盏灯,初始时全是亮的,房间的墙上有4个按钮。问在按了恰好m次按钮后,n盏灯的状态共有多少种可能,返回这个值。 设n盏灯的标号[1,2,3,……,n],4个按钮的功能如下:i.反转所有灯的状态。ii.反转所有偶数标号的灯的状态。iii.反转所有奇数标号的灯的状态。iv.反转所有形如(3*k+1)标号的灯的状态,k=0,1,2,……。:房间里有n盏灯,初始时全原创 2017-10-10 10:41:56 · 390 阅读 · 0 评论 -
LeetCode 458.poor pigs
1.题目There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the mini原创 2017-09-27 11:04:24 · 218 阅读 · 0 评论 -
leetcode Add to List 442. Find All Duplicates in an Array
题目:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it w原创 2017-06-14 10:47:43 · 231 阅读 · 0 评论 -
LeetCode 142: Linked List Cycle II
一 题目Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?原创 2017-06-23 14:39:16 · 184 阅读 · 0 评论 -
leetcode 41. First Missing Positive
题目Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses原创 2017-06-11 18:59:27 · 185 阅读 · 0 评论 -
leetcode 118. Pascal's Triangle
原创 2017-06-10 18:19:48 · 153 阅读 · 0 评论 -
[LeetCode]565. Array Nesting
一 题目https://leetcode.com/problems/array-nesting/#/description原创 2017-06-09 10:40:27 · 258 阅读 · 0 评论 -
leetcode 120. Triangle
原创 2017-06-08 15:06:56 · 306 阅读 · 0 评论 -
leetcode 687. Longest Univalue Path
一 题目Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of path between two n原创 2018-01-04 18:04:53 · 207 阅读 · 0 评论