San Jose各个房价 <1.5m 区域买房总结

一亩三分地论坛

 找回密码
 Sign Up 注册获取更多干货
码农求职神器Triplebyte:
不用海投
内推多家公司面试
坐标湾区
Games Startup
招聘游戏开发工程师
游戏初创公司招聘工程师、UIUX Designer和游戏策划
把贵司招聘信息放这里
查看: 2223|回复: 3
收起左侧

[其他] 一个小公司的面试题

[复制链接] |试试Instant~ |关注本帖
muancy 发表于 2016-1-17 02:25:32 | 显示全部楼层 |阅读模式

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?Sign Up 注册获取更多干货

x
Please write Java code with mysql queries (as needed) for these 2 very simple problems. Note, try to have syntactically correct code.

Problem 1 :
You have a table called member which has 3 columns email, age_as_integer, gender - email is the primary key and age value is integer like 20, 30 , 40, 41, etc

a. We want to find out in this table which age has the most number of members
so let's say we have 50 records with age 20, and 60 with age 21, and 55 with age 23 and so on you need to get the answer 21 given that is the age for most number of members.

b. As a next step, we want to find a band of 5 years where we have most number of profiles so it can be age 1 to age 5 or age 2 to age 6 or age 15 to age 20 - any band of 5 yrs
where we have the most number of profiles (note number of members in a particular 5 year band are the sum of count of profiles associated with per year in that band of 5 years)


Problem 2 :

Write code to find elements in an array of integers that are not only duplicates but that are within 4 array index apart so in an example array of (1, 3, 4, 1, 2, 6, 1, 9, 8, 3)
we will get 1 as answer but not 3 because although 3 is duplicate the occurrence happens at more than 4 indices apart

求问大家,这个sql要怎么写~
本人只会写第一题的a
谢谢大家~~
samparly 发表于 2016-1-17 09:17:32 | 显示全部楼层
第二题用hashmap就搞定了呀,复杂度o(n)。有什么时间空间要求吗
回复 支持 反对

使用道具 举报

全球28万学生4.7分推荐
googlerr 发表于 2016-1-17 13:23:33 | 显示全部楼层
第2题似乎是LeetCode原题:https://leetcode.com/problems/contains-duplicate-ii/
回复 支持 反对

使用道具 举报

chaosMonkey 发表于 2016-9-27 14:25:41 | 显示全部楼层
第二题时固定长度的窗口类问题吧,用set记录索引,维护长度为4,在范围内看看有没有重复就好了。
回复 支持 反对

使用道具 举报

本版积分规则

提醒:发帖可以选择内容隐藏,部分板块支持匿名发帖。请认真读完以下全部说明:

■隐藏内容方法: [hide=200]你想要隐藏的内容比如面经[/hide]
■意思是:用户积分低于200则看不到被隐藏的内容
■可以自行设置积分值,不建议太高(200以上太多人看不到),也不建议太低(那就没必要隐藏了)
■建议只隐藏关键内容,比如具体的面试题目、涉及隐私的信息,大部分内容没必要隐藏。
■微信/QQ/电子邮件等,为防止将来被骚扰甚至人肉,以论坛私信方式发给对方最安全。
■匿名发帖的板块和方法:http://www.1point3acres.com/bbs/thread-405991-1-1.html

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2018-5-27 00:20

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表