- 博客(15)
- 资源 (1)
- 收藏
- 关注
原创 206. Reverse Linked List 【反转链表】
描述Reverse a singly linked list例子思路因为要反转,所以就会断了当前结点和下一个结点的本来关系,所以要保留下一个结点xia方法1遍历链表,对于每个结点,先保留下一个结点的位置,然后采用头插法,将该结点插入新的链表,修改当前结点时刻保存当前结点方法2遍历链表,对于每个结点,先保留下一个结点,然后,将head指向pre,修改pre和...
2019-10-29 10:18:54 184
原创 3.无重复字符的最长子串_面试题48. 最长不含重复字符的子字符串
描述Given a string, find the length of the longest substring without repeating 》 characters.给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度例子思路使用滑动窗口:[i,j],且只能向前滑用字典保存已经字符串中出现的字符的上一个出现的下标使用下标j遍历字符串,如果该字符已经...
2019-10-28 14:36:06 141
原创 2. Add Two Numbers [两数相加]
描述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...
2019-10-25 09:30:50 89
原创 141. Linked List Cycle [环形链表]
描述Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail...
2019-10-23 20:58:02 123
原创 136. Single Number [只出现一次的数字]
描述Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without ...
2019-10-23 19:27:07 66
原创 125. Valid Palindromec [验证回文串]
回文串正读和反读都一样的字符串,比如“level”或者“noon”描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we defin...
2019-10-23 16:58:33 108
原创 121. 买卖股票的最佳时机_面试题63. 股票的最大利润_[找出数组中一个元素和它后面最大的元素的差值]
描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stoc...
2019-10-22 22:49:04 167
原创 119. Pascal's Triangle II [杨辉三角形2]
描述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.给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k+1 行例子思路方法1递归:不使用其他临时变量...
2019-10-22 18:32:30 129
原创 118. Pascal's Triangle [杨辉三角形]
描述Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.给定一个非负整数 numRows,生成杨辉三角的前 numRows 行例子思路方法1:每一行除去头尾,其值为肩上的相加方法2:第4行为 1 3 3 1第5行为 1 4 6 4 1答案...
2019-10-22 15:00:13 236
原创 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.最小深度是从根节点到最近叶子节点的最短路径上的节点数量例子...
2019-10-14 15:25:45 180
原创 110. Balanced Binary Tree [平衡二叉树]
描述Given a binary tree, determine if it is height-balanced.判断一个二叉树是否为平衡二叉树例子思路递归对于每一个结点为空时:是平衡结点不为空时:当左右子树皆为平衡二叉树,且高度差小于2时,该结点为平衡二叉树答案pythonclass Solution: def isBalanced(self,...
2019-10-14 14:49:26 100
原创 108. Convert Sorted Array to Binary Search Tree [ 将有序数组转换为二叉搜索树]
描述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 which the depth of ...
2019-10-14 14:00:58 154
原创 107. Binary Tree Level Order Traversal II [二叉树的层次遍历 II]_剑指offer_面试题32 - II. 从上到下打印二叉树 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)一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右...
2019-10-11 14:42:18 172
原创 104. Maximum Depth of Binary Tree 【树的最大深度】
描述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 child...
2019-10-11 10:36:28 133
原创 101. Symmetric Tree [对称的树]_剑指offer_面试题28. 对称的二叉树
描述Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center)给定一个二叉树,检查它是否是镜像对称的例子思路第100题:两个树是否相同比较具有相同的值比较结点的左子树和另一个结点的左子树此题:两个树互为镜像. 结点具有相同的值. 比较结点...
2019-10-10 11:15:11 103
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人