面试/笔试经历--SQL(括号匹配问题)(jdk底层SuString)---weimob
2017-09-22 09:47
471 查看
一张数据表
1.查询所有成绩大于80分的学生的名字
select DISTINCT a.name from grade a
where a.name not in (
select DISTINCT s.name from grade s
where s.score < 80
)
加上DISTINCT(截然不同的) 意义为去掉重复项 在里面查询的表中 如果查到的是两个小红 所以里面的也要用到DISTINCT
2.查询平均成绩大于80分的学生姓名
select a.name,a.avg from (
select name,AVG(score) as avg from grade group by name
) a
where a.avg >80
注意:在AVG函数之后,要加上as avg 取上一个名字来代称 否则会报错
其他的类似于 最大值最小值 取不同的函数即可 MIN() MAX() 等等
一个经常见到的编程题
(从这个时候我才知道了java也是有stack栈的,枉费我学习java近乎两年,学习不精,实在该检讨)
那么接下来的问题,就与栈有关了
很常见的编程题 关于括号匹配
import java.util.Stack;
那么这就是考你的JDK底层到底看了多少东西了呢,实话是如果真没看过,那是真不会。最常见的也说不上来,先把遇到的贴上去把。
/**
* Returns a string that is a substring of this string. The
* substring begins at the specified {@code beginIndex} and
* extends to the character at index {@code endIndex - 1}.
* Thus the length of the substring is {@code endIndex-beginIndex}.
* <p>
* Examples:
* <blockquote><pre>
* "hamburger".substring(4, 8) returns "urge"
* "smiles".substring(1, 5) returns "mile"
* </pre></blockquote>
*
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified substring.
* @
4000
exception IndexOutOfBoundsException if the
* {@code beginIndex} is negative, or
* {@code endIndex} is larger than the length of
* this {@code String} object, or
* {@code beginIndex} is larger than
* {@code endIndex}.
*/
public String substring(int beginIndex, int endIndex) {
if (beginIndex < 0) {
throw new StringIndexOutOfBoundsException(beginIndex);
}
if (endIndex > value.length) {
throw new StringIndexOutOfBoundsException(endIndex);
}
int subLen = endIndex - beginIndex;
if (subLen < 0) {
throw new StringIndexOutOfBoundsException(subLen);
}
return ((beginIndex == 0) && (endIndex == value.length)) ? this
: new String(value, beginIndex, subLen);
}
但是整个提炼下来,我绝得面试 的人其实看的主要还是就一行代码
return ((beginIndex == 0) && (endIndex == value.length)) ? this
: new String(value, beginIndex, subLen);
自己尝试一下 return ((beginIndex==0) && (endIndex==value.length) ) ? this
: new String(value,beginIndex,sublen);
以上.......校招的漫长之路,就这样吧。
1.查询所有成绩大于80分的学生的名字
select DISTINCT a.name from grade a
where a.name not in (
select DISTINCT s.name from grade s
where s.score < 80
)
加上DISTINCT(截然不同的) 意义为去掉重复项 在里面查询的表中 如果查到的是两个小红 所以里面的也要用到DISTINCT
2.查询平均成绩大于80分的学生姓名
select a.name,a.avg from (
select name,AVG(score) as avg from grade group by name
) a
where a.avg >80
注意:在AVG函数之后,要加上as avg 取上一个名字来代称 否则会报错
其他的类似于 最大值最小值 取不同的函数即可 MIN() MAX() 等等
一个经常见到的编程题
(从这个时候我才知道了java也是有stack栈的,枉费我学习java近乎两年,学习不精,实在该检讨)
那么接下来的问题,就与栈有关了
很常见的编程题 关于括号匹配
import java.util.Stack;
public class StackProblem { public static void main(String[] args) { String str = "(())、()"; boolean flag= new StackProblem().check(str); System.out.println("这个字符串为:"+flag); } public boolean check(String str){ int length = str.length(); Stack<Character> stack = new Stack<Character>(); for(int i=0;i<length;i++){ if(str.charAt(i)==')'){ stack.pop(); }else if(str.charAt(i)=='('){ stack.push(str.charAt(i)); }else if(str.charAt(i)=='、'){ //则遇到的就是、了 此时如果栈里有元素 那么一定不匹配 没有元素就可以继续了 if(!stack.empty()){ //非空 直接返回false return false; } } } if(stack.empty()){ return true; }else{ return false; } } }3.String.substring(beginIndex,endIndex);
那么这就是考你的JDK底层到底看了多少东西了呢,实话是如果真没看过,那是真不会。最常见的也说不上来,先把遇到的贴上去把。
/**
* Returns a string that is a substring of this string. The
* substring begins at the specified {@code beginIndex} and
* extends to the character at index {@code endIndex - 1}.
* Thus the length of the substring is {@code endIndex-beginIndex}.
* <p>
* Examples:
* <blockquote><pre>
* "hamburger".substring(4, 8) returns "urge"
* "smiles".substring(1, 5) returns "mile"
* </pre></blockquote>
*
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified substring.
* @
4000
exception IndexOutOfBoundsException if the
* {@code beginIndex} is negative, or
* {@code endIndex} is larger than the length of
* this {@code String} object, or
* {@code beginIndex} is larger than
* {@code endIndex}.
*/
public String substring(int beginIndex, int endIndex) {
if (beginIndex < 0) {
throw new StringIndexOutOfBoundsException(beginIndex);
}
if (endIndex > value.length) {
throw new StringIndexOutOfBoundsException(endIndex);
}
int subLen = endIndex - beginIndex;
if (subLen < 0) {
throw new StringIndexOutOfBoundsException(subLen);
}
return ((beginIndex == 0) && (endIndex == value.length)) ? this
: new String(value, beginIndex, subLen);
}
但是整个提炼下来,我绝得面试 的人其实看的主要还是就一行代码
return ((beginIndex == 0) && (endIndex == value.length)) ? this
: new String(value, beginIndex, subLen);
自己尝试一下 return ((beginIndex==0) && (endIndex==value.length) ) ? this
: new String(value,beginIndex,sublen);
以上.......校招的漫长之路,就这样吧。
相关文章推荐
- 括号匹配问题与经典笔试面试题目解析
- 括号匹配问题与经典笔试面试题目解析
- Java面试绕不开的问题: Java中HashMap底层实现原理(JDK1.8)源码分析
- 笔试面试算法经典--最长括号匹配
- 面试笔试整理7:SQL问题整理
- 网易2016实习笔试:括号匹配问题
- 关于Java面试中sql优化的问题浅析
- 数据库常见笔试面试问题
- 括号匹配问题
- 括号匹配问题--栈实现
- 面试/笔试第一弹 —— 计算机网络面试问题集锦
- 总结一下:运维工程师面试的经历及面试相关问题(会持续更新) 推荐
- 括号匹配问题,用栈实现
- 面试/笔试第三弹 —— 数据库面试问题集锦
- java--一道简单的括号匹配问题
- 排队游戏(括号匹配问题2)
- 九度oj1153括号匹配问题
- 腾讯2014年实习生招聘笔试面试经历
- 嵌套括号匹配问题/不使用比较运算求出两个数的最大值和最小值问题
- FZU 2030 括号问题 (括号匹配)