自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 中缀表达式、前缀表达式(波兰表达式)、后缀表达式(逆波兰表达式)算法分析与Java实现

在计算器中输入表达式,然后得出计算结果,是一个比较常见的过程,对于含有括号的运算表达式的运算顺序计算机需要自动识别,这里就涉及到表达式的转换。我们手写或者输入的都是中缀表达式,比如“1+(2-3)*45+41/(2*10)”,“1+(2-3)*45+41/2*10”。当然也可以支持其它函数表达式比如exp()等。通常要转化为波兰表达式或者逆波兰表达式,方便计算机进行运算。也就是说第一步是中缀表...

2019-07-14 17:35:05 455

原创 ProblemSet of Graph Algorithms

二分图算法import java.util.Scanner; public class Main{ public static int n_vertex; public static int n_edges; public static int[][] adjMatrix; public static int[] color; publi...

2019-07-30 16:22:45 239

原创 LeetCode--97. Interleaving String

97. Interleaving String算法一:暴力递归public static boolean isInterleave(String s1, String s2, String s3) { return recursive(s1, 0, s2, 0, "", s3); } public static boolean recursive(String...

2019-07-24 23:27:02 178

原创 LeetCode Week Contest 146

总结:这周周赛较难,但是非常有意思。1128. Number of Equivalent Domino Pairs这个问题我先用暴力解法,显然按照数据范围复杂度10^8过不了,然后就先统一骨牌形式(小,大),再排序,然后扫一遍计算:这个算法时间复杂度nlogn,不是很优雅,容易出错。class Solution { public int numEquivDominoPairs(int...

2019-07-22 15:50:53 261

原创 ProblemSet of Math and Number Theory

1041. Robot Bounded In Circle这个问题需要发现规律,就是将命令序列执行一遍,两遍,四遍,必然存在一次回到原点,如果没有就不可能回到起点。class Solution { public boolean isRobotBounded(String ins) { int[][] dirs={{0,1},{1,0},{0,-1},{...

2019-07-19 21:00:36 166

原创 ProblemSet of Binary Search Algorithms

二分的模板:真的很好用,谁用谁知道int bsearch_1(int l, int r){ while (l < r) { int mid = l + r >> 1; if (check(mid)) r = mid; else l = mid + 1; } return l;}int bse...

2019-07-18 21:10:13 137

原创 C语言可编程内存——静态存储区,堆区和栈区

静态存储区:内存在程序编译时已经分配好,这块内存在程序整个执行过程中都存在,主要存放静态数据、全局数据和常量。栈区:在执行函数时,函数内部局部变量的存储单元都在栈上创建,函数执行结束时这些存储单元会被自动释放,栈内存分配运算内置于处理器的指令集,效率很高,但是容量有限。堆区:也称为动态内存分配,程序在运行时用malloc或者new申请任意大小的内存,程序员自己负责在适当的时候用free或者de...

2019-07-18 09:40:15 671

原创 ProblemSet of Tree Algorithms

树算法尽量用递归来做。951. Flip Equivalent Binary Trees算法一:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int...

2019-07-17 19:38:14 136

原创 ProblemSet of Hash Algorithms

1044. Longest Duplicate Substringtypedef unsigned long long ULL;const int N=100010,base=131;ULL POW[N],HASH[N];set<ULL> record;int startIndex;using namespace std;class Solution { pu...

2019-07-16 21:46:45 151

原创 ProblemSet of Dynamic Programming Algorithms

44. Wildcard Matchingclass Solution { public boolean isMatch(String s, String p) { char[] text=s.toCharArray(); char[] pattern=p.toCharArray(); //模式串的简化 ...

2019-07-16 21:45:40 205

原创 LeetCode Biweekly Contest 4 & Week Contest 145

1118. Number of Days in a Monthclass Solution { public int numberOfDays(int Y, int M) { int[][] days={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};//平年28天,...

2019-07-14 00:11:59 237

原创 AcWing《算法竞赛进阶指南》哈希

138. 兔子与兔子#include <iostream>#include<algorithm>#include<string.h>using namespace std;typedef unsigned long long ULL;const int N = 1000010,base = 131;ULL HASH[N], POW[N];cha...

2019-07-10 16:51:51 617

原创 AcWing Google Kickstart

以前一直用java做算法题,总感觉代码十分臃肿,一点也不简洁,并不比C++简单,而且C++的stl更加灵活,所以决定拾起好久没写一直逃避的C++。这个博客专门放谷歌招聘的笔试算法题。546. 糖果#include<iostream>#include<set>#include<algorithm>using namespace std;typedef...

2019-07-09 22:22:51 196

原创 LeetCode Week Contest 144

1108. Defanging an IP Addressclass Solution { public String defangIPaddr(String address) { StringBuilder sb=new StringBuilder(); for(int i=0;i<address.length();i++){ ...

2019-07-07 12:17:57 230

原创 LeetCode--日常刷题

985. Sum of Even Numbers After Queriesclass Solution { public int[] sumEvenAfterQueries(int[] A, int[][] queries) { int oddSum=0,evenSum=0; for(int i=0;i<A.length;i++){ ...

2019-07-06 16:29:59 259

原创 LeetCode Week Contest 143

1103. Distribute Candies to People暴力模拟class Solution { public int[] distributeCandies(int candies, int num_people) { int i=0; int[] ans=new int[num_people]; whil...

2019-07-01 15:56:35 168

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除