查看: 587| 回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

为期五天刷题打卡 9-28 ~10-2

全局:

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

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
打算从头捡起刷题..
9-28基本上跟着答案写了
containsDuplicate
mergeSortedArray
moveZeroes
reverseString
twoSum

note:
可以用系统自带的类型 比如set来判断array里面有没有重复的 e.g. new Set(nums)
一定要记得判断input valid不valid 为不为空
语言自带的function也可以用 .reverse().join("") 一类的,也算多解的一种方法

上一篇:年度计划 - 在职学习打卡
下一篇:SDE 找工作或跳槽刷题学习组队,一起战胜拖延症
🔗
 楼主| Scaffolding 2020-9-29 22:06:01 | 只看该作者
全局:
9-29
1480. Running Sum of 1d Array
firstReccuringNum
shuffleArray
greatestNumofCandies

note:
native methods such as Math.max and destructing can be helpeful
think about space and time trade off
you may just modify the input instead of creating a new variable
回复

使用道具 举报

🔗
 楼主| Scaffolding 2020-10-1 06:06:22 | 只看该作者
全局:
9-30

implemented linkedlist, stack, queue in native javascript
you understand more when you implement it yourself.
回复

使用道具 举报

🔗
 楼主| Scaffolding 2020-10-1 22:18:14 | 只看该作者
全局:
10-1

LC232 implement queue with stack
LC349 IntersectionofTwoArray




Note:
use two stacks to implement queue
new Set() and use new set to filter against array2
回复

使用道具 举报

🔗
 楼主| Scaffolding 2020-10-3 01:50:21 | 只看该作者
全局:
10-2
OA // write a code to move all the negative numbers before all positive numbers in an Array. The order of the numbers in a array must be same.
// eg. input is [5,2,7,-4,3,-8,-10] output: [-4,-8,-10,5,2,7,3];
const input = [5, 2, 7, -4, 3, -8, -10];
const processArray = (arr) => {
  let counter = 0;
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] < 0) {
      arr.splice(counter, 0, arr[i]);
      arr.splice(i + 1, 1);
      counter++;
    }
  }
};
processArray(input);
console.log(input);

LC 433 string compression

Note:
learnt splice, slice methods
had more thoughts on structures to use.
回复

使用道具 举报

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

本版积分规则

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