• 为了保证你在浏览本网站时有着更好的体验,建议使用类似Chrome、Firefox之类的浏览器~~
    • 如果你喜欢本站的内容何不Ctrl+D收藏一下呢,与大家一起分享各种编程知识~
    • 本网站研究机器学习、计算机视觉、模式识别~当然不局限于此,生命在于折腾,何不年轻时多折腾一下
136.OJ-获取列表中仅出现一次的数字

136.OJ-获取列表中仅出现一次的数字

给定一个非空的整数数组,除了一个元素外,每个元素都会出现两次。 找一个单一的。Note:您的算法应具有线性运行时复杂性。 你能不用额外的内存来实现吗?示例 1:Input: [2,2,1]Output: 1 示例 2:Input: [4,1,2,1,2]Output: 4解法:这个题算是划水的,主要是注意点是在不适用额……

123. 最佳时间买卖股票(仅限N次)

123. 最佳时间买卖股票(仅限N次)

假设您有一个数组,其中第 i 个元素是第 i 天给定股票的价格。设计算法以找到最大利润。 您最多可以完成两笔交易。注意:您不得同时进行多笔交易(即,您必须在再次购买之前卖出股票)。例 1:输入:[3,3,5,0,0,3,1,4]产量:6说明:在第 4 天买入(价格= 0)并在第 6 天卖出(价格= 3),利润= 3-0 = 3。然后在第 7 天……

121. Best Time to Buy and Sell Stock(最佳时间买卖)

121. Best Time to Buy and Sell Stock(最佳时间买卖)

假设您有一个数组,其中的 ith 元素是第 i 天给定股票的价格。如果你只被允许完成至多一笔交易(即买一份,卖一份股票),设计一个算法来找到最大利润。请注意,在购买股票之前,您不能出售股票。Example 1:Input: [7,1,5,3,6,4]Output: 5Explanation: Buy on day 2 (price = 1) ……

118. Pascal’s Triangle(帕斯卡三角形)

118. Pascal’s Triangle(帕斯卡三角形)

Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above ……

112. Path Sum(路径求和)

112. Path Sum(路径求和)

给定一个二叉树和一个和,确定该树是否有一个根到叶的路径,以便将路径上的所有值相加等于给定的和。注意:叶是没有子节点的节点。举例:给定如下二叉树以及 sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ \7 2 1返回 ……

111. Minimum Depth of Binary Tree(二叉树最小深度)

111. 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……

110. Balanced Binary Tree(平衡树判断)

110. Balanced Binary Tree(平衡树判断)

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of ever……

Convert Sorted Array to Binary Search Tree(有序列表转化为BST)

Convert Sorted Array to Binary Search Tree(有序列表转化为BST)

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in ……

107. Binary Tree Level Order Traversal II(二叉树分层排序)

107. Binary Tree Level Order Traversal II(二叉树分层排序)

Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example:Given bina……

104. Maximum Depth of Binary Tree(二叉树深度-DFS方法)

104. Maximum Depth of Binary Tree(二叉树深度-DFS方法)

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……

101. Symmetric Tree

101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 ……

100. Same Tree

100. Same Tree

Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the……

88. Merge Sorted Array

88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and nrespectively.Yo……

83. Remove Duplicates from Sorted List

83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->……

67. Add Binary

67. Add Binary

Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"……

58. Length of Last Word

58. Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0……

53. Maximum Subarray

53. Maximum Subarray

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],……

38. Count and Say

38. Count and Say

The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one……