12
返回列表 发新帖
楼主: ThinkDeeper2
跳转到指定楼层
上一主题 下一主题
收起左侧

Uber 电面+onsite

🔗
linixtest 2017-8-5 05:54:44 | 只看该作者
全局:
我想,可以用下一个月的第一天减掉60*60*24秒来计算这个月的最后一天。下个月的第一天就是当前日期的年月加1,注意12月翻年,再加上日期1就好了吧。
回复

使用道具 举报

🔗
f1371342385 2017-9-4 09:40:44 | 只看该作者
全局:
我咋感觉你这个和design uber差不多那种的。。。查询地理信息的
回复

使用道具 举报

全局:
试着写了一下第一题:
  1. public class DatePrinter {

  2.     static int[][] months = {
  3.         {0, 31,28,31,30,31,30,31,31,30,31,30,31},
  4.         {0, 31,29,31,30,31,30,31,31,30,31,30,31}
  5.     };
  6.     public static void main(String[] args) {
  7.         list(new int[]{2017,3,31}, new int[]{2017, 5, 29}).forEach(System.out::println);
  8.     }
  9.     private static String format = "%d/%d/%d-%d/%d/%d";

  10.     private static List<String> list(int[] start, int[] end) {
  11.         // year, month, day
  12.         int year = start[0];
  13.         int month = start[1];
  14.         int day = start[2];
  15.         List<String> res = new ArrayList<>();
  16.         res.toArray();
  17.         while (year <= end[0]) {
  18.             while (month < (year == end[0] ? end[1] : 13)) {
  19.                 res.add(String.format(format, month, day, year, month, months[isLeap(year)][month], year));
  20.                 month++;
  21.                 day = 1;
  22.             }
  23.             if (year == end[0] && month == end[1] && day <= end[2]) {
  24.                 res.add(String.format(format, month, day, year, end[1], end[2], end[0]));
  25.             }
  26.             month = 1;
  27.             year++;

  28.         }
  29.         return res;
  30.     }

  31.     private static int isLeap(int year) {
  32.         return ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)) ? 1 : 0;
  33.     }
  34. }
复制代码
回复

使用道具 举报

🔗
linlin1990 2017-10-18 11:29:52 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

🔗
gamesover 2019-2-23 09:55:45 | 只看该作者
全局:
f1371342385 发表于 2017-9-4 09:40
我咋感觉你这个和design uber差不多那种的。。。查询地理信息的

是的,要用到geohash方式,和查询汽车在地图上位置一样
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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