随笔分类 - 算法
摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in t
阅读全文
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999 解答:
阅读全文
摘要:题目: 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:[[
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given an array where elements are sorted in ascending order, convert it to BST 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary tree, determine if it is a valid Binary Search Tree (BST) 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a number represented as an array of digits, plus one to the number 解答:
阅读全文
摘要:题目: Reverse digits of an integer. For example: x = 123, return 321 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter
阅读全文

浙公网安备 33010602011771号