2018年3月9日

LeetCode 137 Single Number II 数组中除了一个数外,其他的数都出现了三次,找出这个只出现一次的数

摘要: Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm sho 阅读全文

posted @ 2018-03-09 22:40 lina2014 阅读(140) 评论(0) 推荐(0) 编辑

LeetCode 136 Single Number 数组中除一个数外其他数都出现两次,找出只出现一次的数

摘要: Given an array of integers, every element appears twice except for one. Find that single one. 阅读全文

posted @ 2018-03-09 22:18 lina2014 阅读(92) 评论(0) 推荐(0) 编辑

LeetCode 179 Largest Number 把数组排成最大的数

摘要: Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed nu 阅读全文

posted @ 2018-03-09 20:32 lina2014 阅读(133) 评论(0) 推荐(0) 编辑

LeetCode 225 Implement Stack using Queues 用队列实现栈

摘要: 1、两个队列实现,始终保持一个队列为空即可 2、一个队列实现栈 阅读全文

posted @ 2018-03-09 16:49 lina2014 阅读(114) 评论(0) 推荐(0) 编辑

LeetCode 232 Implement Queue using Stacks 两个栈实现队列

摘要: 1 class MyQueue { 2 public: 3 /** Initialize your data structure here. */ 4 MyQueue() { 5 6 } 7 8 /** Push element x to the back of queue. */ 9 void push(in... 阅读全文

posted @ 2018-03-09 16:24 lina2014 阅读(123) 评论(0) 推荐(0) 编辑

LeetCode 583 Delete Operation for Two Strings 删除两个字符串的不同部分使两个字符串相同,求删除的步数

摘要: Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one cha 阅读全文

posted @ 2018-03-09 14:07 lina2014 阅读(125) 评论(0) 推荐(0) 编辑

LeetCode 230 Kth Smallest Element in a BST 二叉搜索树中的第K个元素

摘要: 1、非递归解法 2、递归解法 阅读全文

posted @ 2018-03-09 12:00 lina2014 阅读(107) 评论(0) 推荐(0) 编辑

LeetCode 236 Lowest Common Ancestor of a Binary Tree 二叉树两个子节点的最低公共父节点

摘要: 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(N... 阅读全文

posted @ 2018-03-09 10:49 lina2014 阅读(104) 评论(0) 推荐(0) 编辑

2018年3月8日

LeetCode 148 Sort List 链表上的归并排序和快速排序

摘要: Sort a linked list in O(n log n) time using constant space complexity. 单链表排序 快排 & 归并排序 (1)归并排序 (2)快速排序 ①.使第一个节点为中心点;②.创建2个指针(first,second),first指向头结点, 阅读全文

posted @ 2018-03-08 19:06 lina2014 阅读(168) 评论(0) 推荐(0) 编辑

2018年3月7日

LeetCode 069 Sqrt(x) 求平方根

摘要: Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:In 阅读全文

posted @ 2018-03-07 23:26 lina2014 阅读(119) 评论(0) 推荐(0) 编辑

导航