- 博客(12)
- 资源 (6)
- 收藏
- 关注
原创 [leetcode](Add Binary C语言实现)
Add Binary Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”. 题意:求两个二进制字符串相加,并把结果保存为二进制字符串。 解题思路:动态申请一个数组用于保存相加后的二进制字符串,两个二进制相加有两种可能: 1
2015-04-21 12:55:39 2037
原创 [leetcode](Remove Duplicates from Sorted Array II C语言实现)
Remove Duplicates from Sorted Array II Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array A = [1,1,1,2,2,3],Your function should return
2015-04-20 00:30:59 718
原创 [leetcode](Remove Duplicates from Sorted List II C语言实现)
Remove Duplicates from Sorted List II Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4-
2015-04-19 23:06:36 816
原创 [百度2016实习 在线笔试 编程第一题 度度熊 C语言]
最粗暴的实现算法,没有考虑优化问题。#include<stdio.h>#include <string.h>int function(char *str);int main(){ int num,temp,i; char s[100][10002]; scanf("%d",&num); temp = num;i = 0; while(num--){
2015-04-19 21:57:21 1299
原创 [leetcode](Gray Code 格雷码 C语言实现)
Gray Code The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequen
2015-04-19 18:22:14 2920
原创 [leetcode]Reverse Linked List II (反转链表值 C语言实现)
Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n
2015-04-18 22:38:43 1039
原创 [leetcode]Validate Binary Search Tree (判断有效二叉搜索树 C语言实现)
Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less t
2015-04-17 00:57:35 1524
原创 [leetcode]Construct Binary Tree from Preorder and Inorder Traversal(根据前序、中序遍历确定一棵二叉树 C语言)
Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree. 题意:
2015-04-15 23:38:46 1058
原创 [leetcode]Convert Sorted Array to Binary Search Tree (有序数组转化为二叉搜索树 C语言)
Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题意:给定一颗有序数组,求出二叉搜素树 解题思路:二叉搜索树满足的条件是:左子树<根节点<右子树 采用递归思路
2015-04-15 00:58:45 651
原创 [leetcode]Construct Binary Tree from Inorder and Postorder Traversal (利用中序遍历和后续遍历确定一颗二叉树)
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.
2015-04-15 00:50:54 732
原创 读取一个字符串,输出它里面字符的所有组合
例如:abc,它的所有字符组合为a,b,c,ab,ac,bc,abc 对于这种类型的题,想到的第一思路就是采用递归进行求解。 首先我们申请一个与所求字符串一样大小的字符数组s,用于保存各个字符的组合。 对于abc这样字符串的进行递归实现: a,ab,abc,ac,b,bc,c 实现代码:#include <stdio.h>#include <string.h>int Recursion(
2015-04-12 17:12:50 2158 1
原创 给定一个数N,要求列出所有不大于N的素数
对于素数的定义,可以参考百度百科,素数(质数),除了可以被本身及1整除以外,不会再被其他数整除。典型的素数例如,2 3 5 7 11 13 17 19 23 …… 最简单的方法就是遍历这个整数m,遍历它可能存在的所有除数,例如对于11(1,2,3,4,5,6,7,8,9,10,11)只有1和11能被整除,所以判断11为素数,而对于12(1,2,3,4,5,6,7,8,9,10,11,12)可以被(
2015-04-12 14:07:43 4472 1
unpv13e.zip
2015-01-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人