![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 89
听歌健身码代码
这个作者很懒,什么都没留下…
展开
-
[leetcode]初级算法——数组
Title:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., bu...原创 2018-05-26 15:28:50 · 233 阅读 · 0 评论 -
[lleetcode]初级算法——设计问题
打乱数组Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);// Shuffle the array [1,2,3] and return it...原创 2018-06-20 13:28:40 · 155 阅读 · 0 评论 -
[leetcode]中级算法——数组和字符串
三数之和Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...原创 2018-06-27 16:41:33 · 164 阅读 · 0 评论 -
[leetcode]中级算法——其他
快乐数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 squares ...原创 2018-07-02 20:51:52 · 233 阅读 · 0 评论 -
[leetcode]中级算法——设计
二叉树的序列化和反序列化Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connectio...原创 2018-07-02 22:12:58 · 227 阅读 · 0 评论 -
[leetcode]中级算法——链表
两数相加You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and retu...原创 2018-06-28 00:01:30 · 204 阅读 · 0 评论 -
[leetcode]中级算法——树和图
二叉树的中序遍历Given a binary tree, return the inorder traversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Code(By myself):# Definition for a binary tree n...原创 2018-06-28 23:40:22 · 255 阅读 · 0 评论 -
[leetcode]高级算法——数组和字符串
除自身以外数组的乘积Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Example:Input: [1,2,3,4]Out...原创 2018-07-04 15:44:35 · 257 阅读 · 0 评论 -
[leetcode]高级算法——链表
合并K个排序链表Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->...原创 2018-07-04 23:48:50 · 182 阅读 · 0 评论 -
[leetcode]高级算法——回溯算法
分割回文串Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: "aab"Output:[ ["aa","b"], ["a","a",".原创 2018-07-13 10:59:57 · 341 阅读 · 0 评论 -
[leetcode]初级算法——其他
位1的个数Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 0000000...原创 2018-06-20 11:16:40 · 143 阅读 · 0 评论 -
[leetcode]初级算法——数学
Fizz BuzzWrite a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Bu...原创 2018-06-19 21:13:53 · 210 阅读 · 0 评论 -
[leetcode]初级算法——字符串
反转字符串Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".Code(By myself):class Solution: def reverseString(self, s): """...原创 2018-06-15 14:13:38 · 268 阅读 · 0 评论 -
[leetcode]初级算法——链表
删除链表中的节点Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Example:Input: head = [4,5,1,9], node = 5Output: [4,1,9]Explanation: You are given...原创 2018-06-16 13:44:00 · 162 阅读 · 0 评论 -
[leetcode]初级算法——树
二叉树的最大深度Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no chi...原创 2018-06-17 15:23:04 · 136 阅读 · 0 评论 -
[leetcode]初级算法——排序和搜索
合并两个有序数组Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume t...原创 2018-06-17 16:42:06 · 181 阅读 · 0 评论 -
[leetcode]初级算法——动态规划
爬楼梯You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive ...原创 2018-06-18 15:35:22 · 247 阅读 · 0 评论 -
[leetcode]中级算法——回溯算法
电话号码的字母组合Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons)...原创 2018-06-29 23:24:40 · 328 阅读 · 0 评论 -
[leetcode]中级算法——排序和搜索
分类颜色Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the ...原创 2018-06-30 16:00:28 · 830 阅读 · 0 评论 -
[leetcode]中级算法——动态规划
跳跃游戏Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo...原创 2018-06-30 23:37:03 · 180 阅读 · 0 评论 -
[leetcode]高级算法——树和图
被围绕的区域Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.Example:X X X XX O O ...原创 2018-07-08 00:28:40 · 437 阅读 · 0 评论