[先说点出题背景] 这个题是为低年级同学.学C语言的同学准备的,因为,对这部分同学,这个题目编写起来略有一点复杂.如果是高年级.学过了正则表达式(Regular Expression)的同学或者学过了Java等OO语言的同学做这个题,应当发现这题比较简单吧.哦,对了,什么是tokenizer?请自行查询解决.反正在此处不应翻译成"令牌解析器". [正题] 四则运算表达式由运算数(必定包含数字,可能包含正或负符号.小数点).运算符(包括+.-.*./)以及小括号((和))组成,每个运算数…
我的程序: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 50 4 char token[]= {'+','-','*','/','(',')'}; 5 6 int istoken(char c) { 7 int i; 8 for(i=0; i<strlen(token); i++) { 9 if(token[i]==c) return 1; 10 } 11 return 0; 12 } 13 14 int main…
Contest 111 (题号941-944)(2019年1月19日,补充题解,主要是943题) 链接:https://leetcode.com/contest/weekly-contest-111 [941]Valid Mountain Array(第一题 3分)(google tag) 判断一个数组是不是 Mountain 数组. Mountain 数组的定义是 A.length >= 3There exists some i with 0 < i < A.length - 1 su…
JDK1.8 中Lambda 表达式的出现,基本可以取替原来的匿名类实现多线程的方式.下面列举常用的常用的三种情况. 一.普通开启异步线程   new Thread(() -> System.out.println("--" + "aaa")).start();1 二.线程池开启异步线程(不接收返回参数)   public static ExecutorService executor = Executors.newFixedThreadPool(10); e…
[LeetCode Weekly Contest 29][2017/04/23] 第17周 Binary Tree Tilt (3) Array Partition I (6) Longest Line of Consecutive One in Matrix (8) Find the Closest Palindrome (10) 第一题: 563. Binary Tree Tilt [easy] 别人写几行,我写的非常啰嗦==.树后序遍历.代码是重写过的. Given a binary tr…
Contest 71 () Contest 72 () Contest 73 (2019年1月30日模拟) 链接:https://leetcode.com/contest/weekly-contest-73 结果:2/4,会做第一题和第三题,第二题和第四题不会做. [788]Rotated Digits(第一题 4分)(谷歌tag) 给了一个 good number 的定义,X is a good number if after rotating each digit individually…
Contest 81 (2018年11月8日,周四,凌晨) 链接:https://leetcode.com/contest/weekly-contest-81 比赛情况记录:结果:3/4, ranking: 440/2797.这次题目似乎比较简单,因为我比赛的时候前三题全做出来了(1:12:39),然后第四题有思路,正在写,没写完,比赛完了写完提交也对了. [821]Shortest Distance to a Character(第一题 4分) 给了一个单词(字符串)s,和单词中的任意一个字母…
Contest 91 (2018年10月24日,周三) 链接:https://leetcode.com/contest/weekly-contest-91/ 模拟比赛情况记录:第一题柠檬摊的那题6分钟AC,然后是第二题树的距离K的结点那题比较久,大概写了30分钟,第三题翻转矩阵那题第一次提交错误了,列的优化方法思路错了,WA.后来比赛时间到了才改过来.最后一题最短子数组的和比K大的这题不会做. [860]Lemonade Change   (第一题) 一个柠檬摊,有一队人排队要买柠檬,一个5刀,…
Contest 121 (题号981-984)(2019年1月27日) 链接:https://leetcode.com/contest/weekly-contest-121 总结:2019年2月22日补充的报告.当时不想写.rank:1093/3924,AC:2/4.还是太慢了. [984]String Without AAA or BBB(第一题 4分)(Greedy, M) 给了两个数字,A 代表 A 个 ‘A’, B 代表 B 个‘B’ 在字符串里面.返回一个可行的字符串,字符串中包含 A…
为了简化匿名内部类的代码,具体定义: 例如将9.内部类中的匿名内部类例子: 原来代码: //Main.java public class Main { public static void main(String[] args){ ProcessArray ay = new ProcessArray(); int[] array = {1, 2, 3}; ay.process(array, new AddCommand() { @Override public void process(int[…