c语言
韩韩韩韩韩美丽
这个作者很懒,什么都没留下…
展开
-
LeetCode 对称树 101
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3B...原创 2018-07-23 10:47:59 · 164 阅读 · 0 评论 -
LeetCode Contains Duplicate217
Given an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return false if every element i...原创 2018-07-29 15:23:24 · 135 阅读 · 0 评论 -
LeetCode First Bad Version278
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the...原创 2018-07-29 16:02:21 · 159 阅读 · 0 评论 -
c语言 杂记
1.从右往左读 碰到*读指向 碰到const读常量 int const *x;const int *x;x指向整型常量 常量指针 int *const x; x常量指向整型 指针常量2.浮点型判断abs(x - 1.0) < epson,不然会无限循环3.科学计数法:前面的数可以是整型或者浮点型 中间是E/e 后面的数字必须是整型4.数值在c语言中只有三种表示形式 十...原创 2018-07-21 10:50:34 · 530 阅读 · 0 评论 -
LeetCode Kth Smallest Element in a Sorted Matrix378
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not t...原创 2018-07-29 19:38:38 · 192 阅读 · 0 评论 -
LeetCode 两个排序数组的中位数4
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1, 3...原创 2018-07-22 20:04:24 · 142 阅读 · 0 评论 -
LeetCode 搜索插入位置 35
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array....原创 2018-07-22 20:06:15 · 141 阅读 · 0 评论 -
LeetCode 相同的树100
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example ...原创 2018-07-23 09:29:56 · 214 阅读 · 0 评论 -
Two Sum II
÷Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers...原创 2018-07-31 10:46:34 · 147 阅读 · 0 评论 -
LeetCode Merge Sorted Array 88
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assu...原创 2018-07-29 14:43:25 · 154 阅读 · 0 评论 -
LeetCode Merge Two Sorted Lists21
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.Example:Input: 1->2->4, 1->3->4Output: 1-...原创 2018-07-29 13:26:07 · 100 阅读 · 0 评论 -
LeetCode 树的最大深度104
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 farthest leaf node.Note: A leaf is a node with no childre...原创 2018-07-23 15:04:33 · 147 阅读 · 0 评论 -
LeetCode 反转二叉树 226
Invert a binary tree.Example:Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1思路1.如果树的根为空,直接返回NULL即可;2.当根的左子树或者右子树存在的时候,将左...原创 2018-07-24 16:29:06 · 136 阅读 · 0 评论 -
LeetCode 二叉树的最小深度 111
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 nearest leaf node.Note: A leaf is a node with no childre...原创 2018-07-24 16:46:18 · 149 阅读 · 0 评论 -
LeetCode 二进制搜索树的最低共同祖先235
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between ...原创 2018-07-24 17:25:33 · 282 阅读 · 0 评论 -
LeetCode 平衡二叉树 110
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...原创 2018-07-25 10:05:39 · 147 阅读 · 0 评论 -
LeetCode 路径总和112
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:...原创 2018-07-25 11:01:51 · 234 阅读 · 0 评论 -
LeetCode 二叉树路径257
Given a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: All ...原创 2018-07-25 18:01:09 · 208 阅读 · 0 评论 -
LeetCode count and say 38
count-and-say序列是整数序列,前五个术语如下:1. 12. 113. 214. 12115. 1112211作为"one 1"或读出11。11作为"two 1s"或读出21。21被读出"one 2,然后one 1"或1211。给定整数n,生成count-and-say序列的第n项。注意:整数序列的每个术语将表示为一个字符串。例1:输入: 1 输出:...原创 2018-07-29 12:36:47 · 109 阅读 · 0 评论 -
数据结构 排序 基数排序
#include <stdio.h>#include <stdlib.h>#include <string.h>#define lowbit(x) (x & 0xffff)#define highbit(x) ((x >> 16) & 0xffff)#define swap(a,b){ \ __typeof(a) _...原创 2018-07-28 12:15:51 · 105 阅读 · 0 评论