随笔分类 -  Algorithm

摘要:先给出一道很简单,喜闻乐见的二叉树算法题: 给出一个二叉查找树和一个目标值,如果其中有两个元素的和等于目标值则返回真,否则返回假。 例如: 什么是二叉树? 二叉树是每个节点最多有两个子树的树结构。 什么是二叉查找树(binary search tree) 二叉排序树或者是一棵空树,或者是具有下列性质 阅读全文
posted @ 2017-09-18 23:16 AshLeakey 阅读(1147) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi 阅读全文
posted @ 2016-07-28 01:19 AshLeakey 阅读(164) 评论(0) 推荐(0)
摘要:Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below 阅读全文
posted @ 2016-07-28 01:17 AshLeakey 阅读(169) 评论(0) 推荐(0)
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Difficulty: Easy My submission 1 rt:64ms My submission 2 rt 阅读全文
posted @ 2016-07-28 01:14 AshLeakey 阅读(125) 评论(0) 推荐(0)
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2016-07-25 18:02 AshLeakey 阅读(171) 评论(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 longes 阅读全文
posted @ 2016-07-25 16:12 AshLeakey 阅读(141) 评论(0) 推荐(0)
摘要:Difficulty: Hard here are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run ti 阅读全文
posted @ 2016-06-27 17:00 AshLeakey 阅读(179) 评论(0) 推荐(0)
摘要:Difficulty: Medium Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "a 阅读全文
posted @ 2016-06-26 22:18 AshLeakey 阅读(162) 评论(0) 推荐(0)
摘要:Difficulty: Medium You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their node 阅读全文
posted @ 2016-06-26 20:42 AshLeakey 阅读(191) 评论(4) 推荐(0)
摘要:Difficulty: Easy 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 in 阅读全文
posted @ 2016-06-26 20:37 AshLeakey 阅读(185) 评论(0) 推荐(0)