随笔分类 - leetcode
DO IT BEST
摘要:题目 Given a non empty string s and a dictionary wordDict containing a list of non empty words, determine if s can be segmented into a space separated s
阅读全文
摘要:题目 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 分析 判断链表是否有环,采用快慢指针,如果相遇则表示有环 AC代码
阅读全文
摘要:题目 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
阅读全文
摘要:原题 Given a singly linked list L: L0?L1?…?Ln 1?Ln, reorder it to: L0?Ln?L1?Ln 1?L2?Ln 2?… You must do this in place without altering the nodes' values.
阅读全文
摘要:原题 Given a binary tree, return the preorder traversal of its nodes' values. 分析 对二叉树进行先序遍历,即根节点 左子树 右子树 代码: 递归: 递归代码十分简单,建立一个vector作为返回的结果,现将根节点push进去,
阅读全文
摘要:__描述:__ Given a binary tree, return the postorder traversal of its nodes' values. 直接递归,按照 左子树 右子树 头结点的顺序 AC代码:
阅读全文
摘要:__描述:__ Sort a linked list using insertion sort. 使用插入排序对一个链表进行排序 普通的插入排序,时间复杂度O(n^2)
阅读全文
摘要:Sort a linked list in O(n log n) time using constant space complexity.
阅读全文
摘要:Description: Given a string, find the length of the longest substring without repeating characters. 查找最长的不重复子字符串 Examples:Given "abcabcbb...
阅读全文
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integ...
阅读全文
摘要:题目: 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 t...
阅读全文
摘要:原题: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their...
阅读全文
摘要:题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each inpu...
阅读全文
