随笔分类 -  算法

摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in t 阅读全文
posted @ 2019-02-24 15:39 林木声 阅读(322) 评论(0) 推荐(0)
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe 阅读全文
posted @ 2019-02-24 15:30 林木声 阅读(134) 评论(0) 推荐(0)
摘要:题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – R 阅读全文
posted @ 2019-02-24 15:19 林木声 阅读(116) 评论(0) 推荐(0)
摘要:题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999 解答: 阅读全文
posted @ 2019-02-23 15:49 林木声 阅读(239) 评论(0) 推荐(0)
摘要:题目: Given a matrix of m ✕ n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, given the following matrix:[[ 阅读全文
posted @ 2019-02-23 15:14 林木声 阅读(102) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example, given the below binary tree,1/ \2 4 阅读全文
posted @ 2019-02-23 14:56 林木声 阅读(103) 评论(0) 推荐(0)
摘要:题目: Given an array where elements are sorted in ascending order, convert it to BST 解答: 阅读全文
posted @ 2019-02-22 16:17 林木声 阅读(134) 评论(0) 推荐(0)
摘要:题目: 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 neares 阅读全文
posted @ 2019-02-22 15:47 林木声 阅读(112) 评论(0) 推荐(0)
摘要:题目: 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 farthes 阅读全文
posted @ 2019-02-22 15:42 林木声 阅读(92) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, determine if it is a valid Binary Search Tree (BST) 解答: 阅读全文
posted @ 2019-02-22 15:36 林木声 阅读(109) 评论(0) 推荐(0)
摘要:题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contains a si 阅读全文
posted @ 2019-02-21 14:52 林木声 阅读(118) 评论(0) 推荐(0)
摘要:题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists 解答: 阅读全文
posted @ 2019-02-21 14:34 林木声 阅读(275) 评论(0) 推荐(0)
摘要:题目: Determine whether an integer is a palindrome. Do this without extra space 解答: First, compare the first and last digit. If they are not the same, i 阅读全文
posted @ 2019-02-21 14:28 林木声 阅读(170) 评论(0) 推荐(0)
摘要:题目: Given a number represented as an array of digits, plus one to the number 解答: 阅读全文
posted @ 2019-02-21 14:15 林木声 阅读(139) 评论(0) 推荐(0)
摘要:题目: Reverse digits of an integer. For example: x = 123, return 321 解答: 阅读全文
posted @ 2019-02-19 20:29 林木声 阅读(102) 评论(0) 推荐(0)
摘要:题目: The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it r 阅读全文
posted @ 2019-02-19 20:19 林木声 阅读(136) 评论(0) 推荐(0)
摘要:题目: Given two strings S and T, determine if they are both one edit distance apart i. Modify operation – Modify a character to X in S.S = “abcde”T = “a 阅读全文
posted @ 2019-02-18 19:03 林木声 阅读(233) 评论(0) 推荐(0)
摘要:题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo 阅读全文
posted @ 2019-02-18 18:20 林木声 阅读(147) 评论(0) 推荐(0)
摘要:题目: Given a sorted integer array where the range of elements are [0, 99] inclusive, return its missing ranges.For example, given [0, 1, 3, 50, 75], re 阅读全文
posted @ 2019-02-17 12:51 林木声 阅读(243) 评论(0) 推荐(0)
摘要:题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter 阅读全文
posted @ 2019-02-16 19:18 林木声 阅读(268) 评论(0) 推荐(0)