From ac3ae9e89dfd2e023472e54280e8efe846cfc74b Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Fri, 19 Oct 2018 00:44:08 -0700 Subject: [PATCH 01/50] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 19d8d2f..ab16197 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -##Play with Python and Leetcode +## Play with Python and Leetcode -###说给自己的话 +### 说给自己的话 从14年四月开始准备跳槽, 到现在已经四个月了. @@ -12,7 +12,7 @@ 2014/08/16 -###后记 +### 后记 今天早上拿到了FB的offer, 非常开心这几个月以来的辛苦没有白费, 这一路面试一路跪过来, 最终被自己最向往的公司所认可, 也算是一种缘分, 否则以现在的我的心情, 无论多小的公司要我我都可能随时从了人家, 于是也就会跟我梦寐以求的公司失之交臂, 所以也要感谢那些跪了我的公司们, 要不是你们给我的"Mock Interview", 要不是你们恰到好处的跪了我激励我不断努力, 我也不会有今天这样的结果. @@ -28,10 +28,10 @@ 2014/10/10 -###Tips +### Tips Please click [here](./tips.md) for some tips to start. -###About This Repository +### About This Repository [leetcode.py](./leetcode.py) is my first pass for leetcode, started from March, 2014. Didn't complete all of them and code weren't submitted to OJ. @@ -56,7 +56,7 @@ Please click [here](./tips.md) for some tips to start. * Generate the frequency map to [Frequency](./frequency.md) -###Reference +### Reference 由衷的感谢这些无私分享的人, 没有你们的帮助, 我没法完成这152/152. * [AnnieKim](https://github.com/AnnieKim/LeetCode) Very good and simple leetcode implementation in C. @@ -73,13 +73,13 @@ Please click [here](./tips.md) for some tips to start. * [九章算法题解站](http://www.jiuzhang.com/solutions/) Leetcode solution from NineChapter in Java. -###Methodology +### Methodology * [Dynamic Programming: From novice to advanced](http://hawstein.com/posts/dp-novice-to-advanced.html) Chinese translation. * [Knapsack problem](http://hawstein.com/posts/dp-knapsack.html) Another discussion about DP. -###Sharing +### Sharing If you feel my solutions are helpful, I'll be happy. If you find problems or have better solutions, I'll be more than happy if you can discuss with me. You can reach me at [cyandterry at gmail.com](mailto:cyandterry@gmail.com) From b8b651ff6ac1826dcb0a164e5e425c0f601c4384 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 15:07:09 -0700 Subject: [PATCH 02/50] Update tips.md --- tips.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tips.md b/tips.md index a2b01df..68533df 100644 --- a/tips.md +++ b/tips.md @@ -1,4 +1,4 @@ -##Tips +## Tips 这个repository的资料都是网上搜索+自己的总结经验, 我也不是什么大牛, 只是一介卖油翁, 无他, 唯手熟尔. 至于资料的正确性, 不敢有百分百的把握, 希望看官也能边看边帮我挑错, 有问题可以create ticket或者联系我, 非常欢迎! @@ -12,7 +12,7 @@ * 有些题目理解困难就不要揪着, 看看别的先, 没事的时候多多思考. 但是也不要放着太多甚至觉得这个题太难肯定不会考, leetcode没有真正意义上的难题, 只有比较难AC的题(需要优化算法). * 记忆是需要反复刺激的, 题目理解后的corner case也是需要反复做的. 公司们虽然嘴上说不想把面试弄得跟应试一样, 但是身体上却很老实... 3. [System Design](./system_design.md)网上的资料很多, 面试起来感觉还是蛮看运气的, 比如我准备了很多large scale的东西最后面试聊的根本不沾边, 很难准备, 但是即使这样也不能掉以轻心, 平时没事抽午饭时间看看资料, 多总结多记笔记会很有帮助. -4. 除了以上两点, 对于自己过去的project也要__十分__熟悉, 每一个细节都要分析到位, 为什么project用了这个tech, 好处坏处, 有没有alternative way, 重新做会不会继续用这种方法, 有没有提升空间都要提前演练好. 对于project甚至简历上的每一个key word都不能放过. 大致可以参见我个人的[总结](./about.md). +4. 除了以上两点, 对于自己过去的project也要**十分**熟悉, 每一个细节都要分析到位, 为什么project用了这个tech, 好处坏处, 有没有alternative way, 重新做会不会继续用这种方法, 有没有提升空间都要提前演练好. 对于project甚至简历上的每一个key word都不能放过. 大致可以参见我个人的[总结](./about.md). 5. 对于CS专业知识还有强项语言的知识一定要把握住. 如果java不是强项语言, 最好再稍微准备下java的非常基础的知识, 因为java太火太基础了, 有些公司会默认java的基础知识大家都会. * CS的专业知识可以参见[Knowledge](./knowledge.md), 这里只是列举了一些基本的. * 强项语言的知识就更细了, 我是做Python的, yield, generator 这种东西必须懂. 也可参见[Knowledge](./knowledge.md). From b9e17de8a54c0652739322c7828a3d9f22de0ddd Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 15:10:19 -0700 Subject: [PATCH 03/50] Update system_design.md --- system_design.md | 98 ++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/system_design.md b/system_design.md index 49a82ab..c0e3bf2 100644 --- a/system_design.md +++ b/system_design.md @@ -1,15 +1,15 @@ -#System Design +# System Design -##Table of Content -####[1. Design Process](#design-process) -####[2. Statistic Numbers](#statistic-numbers) -####[3. Basic Knowledge](#basic-knowledge) -####[4. Topics](#topics) -####[5. 海量数据](#海量数据) +## Table of Content +#### [1. Design Process](#design-process) +#### [2. Statistic Numbers](#statistic-numbers) +#### [3. Basic Knowledge](#basic-knowledge) +#### [4. Topics](#topics) +#### [5. 海量数据](#海量数据) ----- -##Design Process +## Design Process 1. 按照网上的[步骤](http://www.hiredintech.com/app#system-design)走 1. Constrains and use cases - 分析问题框架 2. Abstract Design - 设计service/storage layer @@ -27,22 +27,22 @@ ----- -##Statistic Numbers -####公司 +## Statistic Numbers +#### 公司 -#####[Facebook](http://newsroom.fb.com/company-info/) +##### [Facebook](http://newsroom.fb.com/company-info/) * 1.3 billion active user per month * 1.07 billion mobile user per month * 829 million daily active user per day (远大于Monthly因为monthly的active user不能重复计算) -#####[Twitter](https://about.twitter.com/company) +##### [Twitter](https://about.twitter.com/company) * 271 million monthly active users * 500 million Tweets are sent per day -#####[Amazon](http://www.statista.com/topics/846/amazon/) +##### [Amazon](http://www.statista.com/topics/846/amazon/) * 237 million active customer accounts worldwide -####程序内 +#### 程序内 * 一个char是1 byte, 一个int/float/long是4 bytes, 一个double是 8 bytes * 1 Million = 10^6, 1 Million char = 1MB, 1 Million int = 4MB, 1 Million double = 8MB * 1 Billion = 10^9, 1 Billion char = 1GB, 1 Billion int = 4GB, 1 Million double = 8GB @@ -64,18 +64,18 @@ | IP Address(IPv4) | 2**8 * 4 = 4 bytes | 4 KB | 4 MB | 4 GB | | IP Address(IPv6) | 128 bits = 16 bytes | 16 KB | 16 MB | 16 GB | -####Computer +#### Computer * SSD 50~200MB/s * DRAM 2-20GB/s -####Note +#### Note 1. 所有IP是能放进内存的,因为一共2^32个ip地址 ------ -##Basic Knowledge +## Basic Knowledge -###[Harvard Class](https://www.youtube.com/watch?v=-W9F__D3oY4) +### [Harvard Class](https://www.youtube.com/watch?v=-W9F__D3oY4) 1. 形式: Multi-tier architecture ![Multi-tier architecture](./img/arch-anganguera.png) ![Another Pic](./img/perfpatrol.png) @@ -113,7 +113,7 @@ ------ -###NoSQL vs Relational SQL +### NoSQL vs Relational SQL * NoSQL * MongoDB(Document) * Google Big Table (Column) @@ -133,7 +133,7 @@ * A General Lack of Maturity * Performance and Scaling > Consistency - Performance and Scaling is good, lack of Consistency -###[Sharding](http://docs.mongodb.org/manual/core/sharding-introduction/) +### [Sharding](http://docs.mongodb.org/manual/core/sharding-introduction/) * Storing data across multiple machines * Purpose - horizontal scaling * Advantages @@ -149,7 +149,7 @@ * Splitting * Balancing -###[MapReduce](http://michaelnielsen.org/blog/write-your-first-mapreduce-program-in-20-minutes/) +### [MapReduce](http://michaelnielsen.org/blog/write-your-first-mapreduce-program-in-20-minutes/) 拿[word count](./Concept_Implement/MapReduce.py)作为栗子 * Map is a step to convert each chapter to a dict * 实际栗子里是把combine这步放到这里,把多个chapter组成一个intermediate list @@ -161,7 +161,7 @@ 2. Apply function to the pieces in parallel without communication to each other between the analyzers 3. Apply another function to combine the results -###[Consistent Hashing](http://blog.csdn.net/sparkliang/article/details/5279393) +### [Consistent Hashing](http://blog.csdn.net/sparkliang/article/details/5279393) * Naive way to do: hash(k) % n * four important keys * Balancing @@ -183,7 +183,7 @@ * 正常hash就直接hash ip就行了 hash('192.168.1.1'), 如果是hash virtual node可以 hash('192.168.1.1#1') ![consistent_hashing](/img/consistent_hashing.jpg) -###[Storm](https://storm.incubator.apache.org/documentation/Home.html) +### [Storm](https://storm.incubator.apache.org/documentation/Home.html) Storm is a distributed realtime computation system. Similar to how Hadoop provides a set of general primitives for doing batch processing, Storm provides a set of general primitives for doing realtime computation. [Another introduction](http://www.slideshare.net/ptgoetz/storm-hadoop-summit2014?next_slideshow=1) @@ -194,19 +194,19 @@ Storm is a distributed realtime computation system. Similar to how Hadoop provid * Trident -###[Spark](https://www.youtube.com/watch?v=cs3_3LdCny8) +### [Spark](https://www.youtube.com/watch?v=cs3_3LdCny8) * Builds on top of HDFS * Not tied to two-stage Mapreduce * Proivde in-memory cluster computing * Use Cases: Machine Learning algorithms and Interactive analytics. -###[Hadoop](http://www-01.ibm.com/software/data/infosphere/hadoop/) +### [Hadoop](http://www-01.ibm.com/software/data/infosphere/hadoop/) * 最重要的两个是YARN and HDFS * 其他还有HBase database, the Apache Mahout machine learning system, and the Apache Hive Data Warehouse system -###[Yet Another Resource Negotiator(YARN)](http://www.slideshare.net/hortonworks/apache-hadoop-yarn-understanding-the-data-operating-system-of-hadoop) (Cluster Resource Mangement) +### [Yet Another Resource Negotiator(YARN)](http://www.slideshare.net/hortonworks/apache-hadoop-yarn-understanding-the-data-operating-system-of-hadoop) (Cluster Resource Mangement) -####[Hadoop Distributed File System (HDFS)](http://hortonworks.com/hadoop/hdfs/) (Redundate, Reliable Storage) +#### [Hadoop Distributed File System (HDFS)](http://hortonworks.com/hadoop/hdfs/) (Redundate, Reliable Storage) * Rack awareness allows consideration of a node’s physical location, when allocating storage and scheduling tasks * Minimal data motion. MapReduce moves compute processes to the data on HDFS and not the other way around. Processing tasks can occur on the physical node where the data resides. This significantly reduces the network I/O patterns and keeps most of the I/O on the local disk or within the same rack and provides very high aggregate read/write bandwidth. * Utilities diagnose the health of the files system and can rebalance the data on different nodes @@ -214,16 +214,16 @@ Storm is a distributed realtime computation system. Similar to how Hadoop provid * Standby NameNode provides redundancy and supports high availability * Highly operable. Hadoop handles different types of cluster that might otherwise require operator intervention. This design allows a single operator to maintain a cluster of 1000s of nodes. -###[ZooKeeper](http://zookeeper.apache.org/doc/trunk/zookeeperOver.html) +### [ZooKeeper](http://zookeeper.apache.org/doc/trunk/zookeeperOver.html) A Distributed Coordination Service for Distributed Applications -###[DevOps](http://www.infoq.com/cn/articles/devops-is-not-equal-chef-puppet) +### [DevOps](http://www.infoq.com/cn/articles/devops-is-not-equal-chef-puppet) ----- -##Topics +## Topics -###[Tiny URL](http://www.hiredintech.com/app#the-system-design-process) +### [Tiny URL](http://www.hiredintech.com/app#the-system-design-process) 1. Constrains and Use Cases 1. Use Cases - What do we use the system for? 1. Shortening: take a url => return a much shorter url @@ -246,7 +246,7 @@ A Distributed Coordination Service for Distributed Applications 4. 1BN request per month 5. request by second 400+per second(40 shorten 360 redirects) 6. Total url 5 years * 12 * 100M: 6Billion url in 5 years - 7. 每个url长度 500bytes: __1 char = 1 byte__ 这个太重要了(ASCII是128=2**7个, 1byte就够了, 但是UTF-8是1~4bytes一个字符) + 7. 每个url长度 500bytes: __1 char = 1 byte__ 这个太重要了(ASCII是`128=2**7`个, 1byte就够了, 但是UTF-8是1~4bytes一个字符) 8. __url是case sensitive的__ 9. 6 bytes per hash 10. 注意, 10^3 K->kb, 10^6 M->MB, 10^9 B->GB, 10^12 ->TB @@ -299,7 +299,7 @@ A Distributed Coordination Service for Distributed Applications ----- -###[Image Hosting Applicaiton](http://www.aosabook.org/en/distsys.html) +### [Image Hosting Applicaiton](http://www.aosabook.org/en/distsys.html) * Services * Dedundancy * Partitions @@ -380,7 +380,7 @@ A Distributed Coordination Service for Distributed Applications ----- -###[News Feed](http://www.quora.com/What-are-best-practices-for-building-something-like-a-News-Feed) +### [News Feed](http://www.quora.com/What-are-best-practices-for-building-something-like-a-News-Feed) * Load Test: peak/non-peak * Services * User update - Write @@ -403,7 +403,7 @@ Also see [this](./img/Facebook_News_Feed.pdf) ----- -###[Facebook Chat](./img/Facebook_Chat.pdf) +### [Facebook Chat](./img/Facebook_Chat.pdf) * Client Side * Regular AJAX for sending messages * Regular AJAX for pull list of friends @@ -422,7 +422,7 @@ Also see [this](./img/Facebook_News_Feed.pdf) * Web Tier -> via thrift <- Chat logger * Presence和Channel talk(via thrift) 用来获得在线列表 -###[Messaging System](http://www.slideshare.net/brizzzdotcom/facebook-messages-hbase) +### [Messaging System](http://www.slideshare.net/brizzzdotcom/facebook-messages-hbase) * Use HBase * High write throughput * `````` @@ -441,13 +441,13 @@ Also see [this](./img/Facebook_News_Feed.pdf) * Social Graph * 1st Degree Graph Connection -#####Services +##### Services * FoF Friend of Friend * OoF Object of Friend * Global (Remove some sensitive stuff) * Aggregator - Merging, Ranking, Returning -#####Three Way Trade-off +##### Three Way Trade-off * Pre-compute * Trie - Keep users first-degree connection. Waste space. * 问题是如何Keep Sync @@ -457,24 +457,24 @@ Also see [this](./img/Facebook_News_Feed.pdf) ----- -###[POI](http://1.znku.sinaapp.com/?p=331) +### [POI](http://1.znku.sinaapp.com/?p=331) * [GeoHash](http://en.wikipedia.org/wiki/Geohash) * 一个5位的char -> base32变成 5*5bit(包括奇数位经度偶数位纬度) -> 0表示在low~mid, 1表示mid~high转成纬度 -#####Implement second/minute/hour/day counters +##### Implement second/minute/hour/day counters -#####Photo Storage +##### Photo Storage * 比较普遍的见上面[Image hosting application](#image-hosting-applicaiton) * Facebook的是用Haystack ----- -##[海量数据](http://blog.csdn.net/v_july_v/article/category/1106578) +## [海量数据](http://blog.csdn.net/v_july_v/article/category/1106578) ----- -##Others +## Others -#####[Facebook](./img/Facebook_Architecture.pdf) +##### [Facebook](./img/Facebook_Architecture.pdf) * Web Tier * PHP - hiphop * Storage Tier @@ -490,12 +490,12 @@ Also see [this](./img/Facebook_News_Feed.pdf) * Inefficient and messy - access hundreds of machines - nightly cron jobs * Build specialized services -#####Note +##### Note 1. Similar to web server or CDN edge server ----- -###NC 笔记 +### NC 笔记 * Concurrency * Thread * Deadlock @@ -510,12 +510,12 @@ Also see [this](./img/Facebook_News_Feed.pdf) 2. 长链接 3. chunk传输 * 访问google - __Client Side__ + **Client Side** 1. DNS: 把domain name转化成ip address, use cache 2. HTTP: 80, GET/POST, request header, response header, content-length, accept type, etag, cookie-session 3. 7 layer, 封包 解包 过程,tcp 3次握手协议 4. rendering. html - __Server Side__ + **Server Side** GET /index.jsp?username=xxx, cookie (client端叫cookie, server端叫session) static, dynamic区分 cdn(content delivery network): @@ -575,7 +575,7 @@ Also see [this](./img/Facebook_News_Feed.pdf) storage: consistant hashing: http://www.programering.com/a/MzN2MjMwATI.html 4. Locale: router -###TODO +### TODO * [ ] 总结下Twitter Pinterest Facebook题目 * [ ] 精细化数据 From 9716644878fa07c7530e9b0f04a578488b00f44f Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 15:13:14 -0700 Subject: [PATCH 04/50] Update about.md --- about.md | 108 +++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/about.md b/about.md index 8b37139..d6c25d8 100644 --- a/about.md +++ b/about.md @@ -1,14 +1,14 @@ -##关于面试 +## 关于面试 -####1. 跳槽目的: +#### 1. 跳槽目的: * GF got a job in SF, so decided to move to a larger city * Like your company and interested about what your company is doing. -####2. 工作类型: +#### 2. 工作类型: * 70% dealing with back-end, including 15% of database work. Mostly Python. * 30% dealing with front-end, working with Coffeescript or Javascript, html & less. -####3. 工作内容: +#### 3. 工作内容: * In Hosting System Support Team, mostly develop and support internal tools. I work with other 3 developers making full stack development. * I work with other 3 developers. We are using Python and Oracle to build a Sales application that connects with Salesforce and we are achieveing that by gathering requirements from sales team directly and build these enhancements right into the application. @@ -23,16 +23,16 @@ Become fire fighter, internal user report there's issue for systems that we support, then dive into the systems and find traceback and try to fix. * Working closely with our Sales Team to constantly improve and update internal systems for them. -####4. Mercury特点 +#### 4. Mercury特点 * Provide our sales team a faster, more stable, more flexible platform and give them better user experience. 1. Navisite is the king of customization. Our customer can buy whatever they want in whatever way as long as we have profit on the order. This is the goal for us. To build a tool that won't limit our sales people's creativity. 2. A lot of procedures are data-driven, e.g. some approval rules are just a row of data in our database, we can react very fast if there's any need for us to change the rule, without touching the code base. 3. We work closely with our Sales team and we listen to their feedback and make quick improvements based on their feedback. -##Detail about Mercury +## Detail about Mercury -####1. Tornado, Python's adv, why python +#### 1. Tornado, Python's adv, why python * RESTful by dispatch file * Tornado handler receive API call * Memcached @@ -43,11 +43,11 @@ * Oracle Database * Nginx -####2. SpineJS's adv, why SpineJS. v1.3.2 +#### 2. SpineJS's adv, why SpineJS. v1.3.2 * MVC - talk about this * grunt -####3. Unit Test, TDD, why not +#### 3. Unit Test, TDD, why not * sinon * sinon-qunit @@ -58,9 +58,9 @@ * You think the test case would cover all the mistakes, but not always * Have limitation, like database(what about back-end pull data from database) and front-end, ui layout -####4. Libraries: +#### 4. Libraries: -#####Back-End +##### Back-End * MPS sqlio, validation, logger, format, config, dateutil. Wrapper lib for pthon. handy functions. sqlio is similar for SQLAlchemy. @@ -68,7 +68,7 @@ * SalesForce * Memcached -#####Some numbers to show this is not a easy project +##### Some numbers to show this is not a easy project * List of modals we have * Queues * Two Engines @@ -77,13 +77,13 @@ * Main table names * Users, and no. of roles & permissions -#####A lot of comparing +##### A lot of comparing * Python's pros and cons, and comparing to other programming languages. * Front-end frame work * Back-end frame work * Memcached comparing to other DB -#####Front-End +##### Front-End * LESS * jquery v 2.1 * Bootstrap v3.2.0 @@ -94,58 +94,58 @@ ----- -####Memcached +#### Memcached * Default size is 64MB * Default object size if 1MB * Very fast * service memecached restart * config file /etc/memcached.conf -####RESTful vs SOAP +#### RESTful vs SOAP -####Nginx vs Apache2 -* __Nginx__ is a http request and load balancing server. +#### Nginx vs Apache2 +* **Nginx** is a http request and load balancing server. Nginx is faster. -* __Apache2__ used to be not good at scale. Had some memory problem. +* **Apache2** used to be not good at scale. Had some memory problem. ```sudo nginx -t``` 查看config file 有无错误 记住千万不能有两个default server -####Python Back-end Framework Comparison -#####Django (Powerful) +#### Python Back-end Framework Comparison +##### Django (Powerful) * Perfect documentation * Full-stack framework - cache, session, feed, [orm](http://stackoverflow.com/questions/53428/what-are-some-good-python-orm-solutions), geo, auth * MVC on the back end, have the template system * System functions laid on each other. If you don't like the Django's ORM, hard to use your own. * Not good at customization. -#####Tornado (Flexible) (Good for Scale) +##### Tornado (Flexible) (Good for Scale) * We have many libraries in our company. MPS. -* __Non-blocking__ network I/O +* **Non-blocking** network I/O * Only provides what a basic web server needs. Like url dispatch -####Reason for Tornado +#### Reason for Tornado Tornado is flexible and light weight. Since we are putting all the MVC part to our front-end, we don't need that powerful framework like Django. #####Flask & Bottle (Nimble) (Not non-blocking so not good for scale) * Flask + Jinja + SQLAlchemy Framework + Template + ORM -#####[Twisted](http://stackoverflow.com/questions/5458631/whats-so-cool-about-twisted) +##### [Twisted](http://stackoverflow.com/questions/5458631/whats-so-cool-about-twisted) * Include a lot of protocols implementation. * Event-driven networking engine -#####[Blocking and Non-blocking I/O](http://stackoverflow.com/questions/8362794/networked-systems-whats-the-difference-between-a-blocking-and-a-non-blocki) -######Blocking - Synchronous vs Non-blocking - Asynchronous +##### [Blocking and Non-blocking I/O](http://stackoverflow.com/questions/8362794/networked-systems-whats-the-difference-between-a-blocking-and-a-non-blocki) +###### Blocking - Synchronous vs Non-blocking - Asynchronous A "blocking" call "blocks" the program that calls it until it completes. Your program has to wait for it to do (whatever) before the next statement runs. A "non-blocking" or asynchronous method usually, instead, either deposits its results in a "mailbox" or "queue" of some kind, or (more commonly) will call back a function that you provide when it completes. -####Javascript Front-end Framework Comparison -#####References +#### Javascript Front-end Framework Comparison +##### References * [CodeBrief](http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/) * [InfoQ](http://www.infoq.com/research/top-javascript-mvc-frameworks/) -#####Spine.js +##### Spine.js * MVC * Asynchronous interfaces * Simplicity @@ -153,12 +153,12 @@ A "non-blocking" or asynchronous method usually, instead, either deposits its re * Spine stores and renders everything client-side, communicating with the server asynchronously. * Coffee -####Reason for Spine +#### Reason for Spine Fits well with our user's workflow. * Most of the time, user are inputing data and choosing options. Like selecting parts, play with price. Data are changed frequently. We don't want our users wait everytime when they input anything, so doing async is the best solution, where SpineJS is good at. * User opens up the app, load principle models ahead, and later on do async calls to the back-end. User can't even feel that this app is talking with it's back-end because there's non-block IO. -####Redesign Project +#### Redesign Project 1. Use more popular front-end, like Angular - SpineJS's documentation is neat but not enough, we have been suffered from I found a problem, don't know how to solve, so I asked my teammate who is more focused on the front-end, and helped me with that. After that, I asked him, how did you know that? He said because I had a same problem and I dived into the source code 2. We had to worry too much about security. But since this is internal tool, we think this is not a big problem to us. But we still have to face the problem 3. Too much rely on client side may cause problem. You don't know what the user's browser is, you don't what's user's box's performance. Local storage size and other's system attribute will cause all kinds of headache if you do it too much. @@ -166,25 +166,25 @@ Fits well with our user's workflow. 5. For backend, there are a lot of things that we can improve, like reduce the piping to the front-end, make some of the data fetch loaded later. 6. But not anything we need to redesign. Tornado is pretty good, python web development is pretty good. Maybe get more async funcs on back-end but I cannot come up with a great use case for async. -#####Backbone.js / Ember.js / Angular.js +##### Backbone.js / Ember.js / Angular.js -####MVC +#### MVC * Model stores the data object. Spine can easily bind model change event with api-call the update on the back-end * View is the template to be rendered to users. * Controller controls all the logic. Render Views and modify Model. -####Coffeescript vs Javascript +#### Coffeescript vs Javascript -####Grunt +#### Grunt * Javascript task runner, or automation. Helps you to do automated compile, build and test. * 最重要的两个file: package.json & Gruntfile.js/cofffee -###Bower +### Bower * Package Manger. Helps you to manage and update package. Used with Grunt. Like if you have a package update, and tested by team member, grunt-bower will help you to install that package. * 重要的file: bower.json -###Other Key Words: +### Other Key Words: * LESS * Bootstrap * Salesforce @@ -192,19 +192,19 @@ Fits well with our user's workflow. ----- -#####4. My Jobs: -#####Back-End +##### 4. My Jobs: +##### Back-End * Permissions * Sessions * Part Catalog with ten thousands of rows of data, stored in Memcached * Nginx - gzip -#####Front-End +##### Front-End * Add Part Info * Part Wiki * Solutions -#####5. Challenges: +##### 5. Challenges: 1. Started from scratch and everyone works full-stack. 2. The Memcache problem 3. Support for different browsers on different OS. Especially on mobile device. Had a problem about memory using on iOS device. @@ -212,14 +212,14 @@ Fits well with our user's workflow. * Cannot trust user's input, need to validate everything from the front-end. * Need to be careful about the render process since it's async. For example, user submit a quote for approval, after clicked submit button, if they close the window immediately, it won't actually submit. So need to move process a bit earlier. -#####6. About Team and Workflow +##### 6. About Team and Workflow 1. We don't have a QA, we are our own QAs. We don't have a PM but we like grokking the business from the ground up, helping to steer our strategy, and defining and prioritizing our business. 2. Use remedy and redmine as our bug tracker 3. We work in iterative agile way. We wanted to work like Scrum and actually currently my manager's role is almost same as Scrum Master, but since we are in a small team, we are not tight to the sprints. ----- -###Questions: +### Questions: * What do you think is the most challenging part of the work * What makes the best candidate * How do you different your product with ... @@ -229,13 +229,13 @@ Fits well with our user's workflow. * ... 闲来没事可以问的问题: -#####Question to HR: +##### Question to HR: * How would you describe the company culture? * What type of employees tend to excel at this company? * Can you tell me more about the interview process? * How would you describe the work enviroment here—collaborative or independent? -#####Hiring Manager: Your Future Boss +##### Hiring Manager: Your Future Boss * What is the ideal candidate? * What are some challenges one might face in this position? * What are the most important skill set for the job? @@ -244,30 +244,30 @@ Fits well with our user's workflow. * If I am luck enough to get the job, what preparation would you suggest me do? * Learning/training opportunities -#####The Executive or high level expert +##### The Executive or high level expert * How do you think this industry will change in the next five years? * What do you think is the competitive advantage of our company? * What's the company's biggest challenge? How is it planning to meet that challenge? -#####The Coworker +##### The Coworker * Could you please describe a typical day? * How would you describe the work environment at the company? * Share something about your background. -#####普适的问题: +##### 普适的问题: * What do you particularly like about the company? * What do you dislike about the company if there is any? * Could you tell me something about the projects that you are working on? The size of the team. The language the team is adopting? -###References that I follow +### References that I follow * V2EX * InfoQ * The Hacker News * TechCrunch * Web Design Inspiration -###Behaviors Question +### Behaviors Question * Give me some examples that you've worked in the past that show you are a team player. * In some way to help to improve the chance to success * Work in late to fix a problem. @@ -279,7 +279,7 @@ Fits well with our user's workflow. * How would you describe a challenging group from which you have to gain cooperation from. You need to get to work together. How to lead them together. * Use action. If I work very hard, others see me working hard and will be inspired to work hard as well. -####普适的一个例子 +#### 普适的一个例子 Two month ago, we just released our project to production. Some of our user reporting that they are stucked at the loading bar. There were several users reporting the same problem so we think it's pretty serious and it was already 5:00PM. @@ -295,7 +295,7 @@ After all, we found out this was a combination of several stuff. 6. Front-end guy also used gzip to zip the data stored in user's local storage. 7. We did more test on windows browser and Mac OS and iOS devices make sure it works fine. -#####具体收获 +##### 具体收获 1. Production和Staging一定要确定data的大小一样, 最好在做这种release之前refresh staging database to make them sync. 2. Team work, 5 of us we worked until 11 and no one left before we are sure the production is working fine. 3. Test on different platform. @@ -303,4 +303,4 @@ After all, we found out this was a combination of several stuff. 最后再问I hope I've answered that question to your satisfaction? -######[Some Other Tricky Ones](https://www.facebook.com/notes/egyptian-recruiter/are-you-prepared-for-tricky-behavioral-interview-questions/359902444038414) +###### [Some Other Tricky Ones](https://www.facebook.com/notes/egyptian-recruiter/are-you-prepared-for-tricky-behavioral-interview-questions/359902444038414) From 9fbfa27e7dd1d24ff2c1a6d45d7cfd6a80d84dd8 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 15:36:28 -0700 Subject: [PATCH 05/50] Renanme about to Jedi --- about.md => old_jedi.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename about.md => old_jedi.md (100%) diff --git a/about.md b/old_jedi.md similarity index 100% rename from about.md rename to old_jedi.md From 307e0baf17272e622288f28f6c17a7db16f1db1e Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 15:38:44 -0700 Subject: [PATCH 06/50] fixed a typo --- old_jedi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/old_jedi.md b/old_jedi.md index d6c25d8..d0b3484 100644 --- a/old_jedi.md +++ b/old_jedi.md @@ -126,7 +126,7 @@ #### Reason for Tornado Tornado is flexible and light weight. Since we are putting all the MVC part to our front-end, we don't need that powerful framework like Django. -#####Flask & Bottle (Nimble) (Not non-blocking so not good for scale) +##### Flask & Bottle (Nimble) (Not non-blocking so not good for scale) * Flask + Jinja + SQLAlchemy Framework + Template + ORM From f6b096de8166c4be864c82e6d0e31c333d6f2eda Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 17:56:02 -0700 Subject: [PATCH 07/50] Update zz_coding_index.md --- zz_coding_index.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zz_coding_index.md b/zz_coding_index.md index 37504bb..678ccf7 100644 --- a/zz_coding_index.md +++ b/zz_coding_index.md @@ -1,6 +1,6 @@ -#zz Coding Summary +# zz Coding Summary -##Two Pointers +## Two Pointers 1. 两个pointers从头往后走:感觉绝大多数的linked list的题目都涉及到这个操作,当然还有array。这类题目很多时候又可以称为sliding window。 * Implement strStr() * Longest Substring Without Repeating Characters @@ -32,25 +32,25 @@ * Multiply Strings * Partition List -##Permutation and Combination -######Permutation +## Permutation and Combination +###### Permutation * 输入没有重复:Permutations, CC150 9.5, PIE Chapter7 Permutations of a String * 输入有重复,输出不能有重复:Permutations II * Next Permutation: 经典算法,背吧 * Permutation Sequence: 非常有意思的题目 * Combination -######纯粹的subset +###### 纯粹的subset * 输入没有重复:Subsets, CC150 9.4, PIE Chapter7 Combinations of a String * 输入有重复,输出不能有重复:Subsets II -######需要满足一定要求的组合 +###### 需要满足一定要求的组合 * 一个元素只能取一次(输入没有重复): Combinations * 一个元素可以取多次(输入没有重复): Combination Sum, CC150, 9.8 * 一个元素只能取一次(输入有重复,输出不能有重复): Combination Sum II * Gray Code: 具有subset的序列特点 (考虑CC150 9.4 Solution#2: Combinatorics) -##Binary Search and Divide and Conquer +## Binary Search and Divide and Conquer Binary search非常tricky,虽说道理简单,但是面试的时候却很容易出bug,因此总结一下是必须的。假设i=0,j=A.length-1, 我做了一下LeetCode上的所有binary search的题目,发现了以下几点值得注意。 @@ -76,7 +76,7 @@ Questions * Pow(x, n) * Sqrt(x):其实算是一道典型的binary search题目,不过里边包括了几个tricky的地方,很难一次写对 -##Linked List +## Linked List 首先LeetCode上几乎所有的Linked list的题目都可以用two pointers来解决,或者会用到two pointers这个基本编程技巧。因此two pointers跟linked list是紧密相关的。因为two pointers以前已经总结过了,就不多讲了。 其次,因为LinkedList和Array/ArrayList一样都具备有List的特性,因此很多题目都出现在了两种数据结构上,或者说很多题目都是可以把这两种数据结构互换的。比如: @@ -123,7 +123,7 @@ Leetcode上graph的题目涉及的很少,不过从算法和coding来说DFS,B (这题原题在CC150是一道双向链表题,不知道Leetcode上怎么改单向了。双向链表应该更复杂一些,大家要注意一下) -##数据结构 +## 数据结构 * Array, ArrayList * String, StringBuffer * LinkedList From 423c8cbcfe2ec3fe298d9d35b3dddd8504d64118 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 18:01:04 -0700 Subject: [PATCH 08/50] Update coding_index.md --- coding_index.md | 138 ++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/coding_index.md b/coding_index.md index 7698e7c..0730849 100644 --- a/coding_index.md +++ b/coding_index.md @@ -1,6 +1,6 @@ ## Coding Summary by Keywords and Type -###Permutation & Combination Type +### Permutation & Combination Type * [x] Permutations * [x] Permutations II * [x] Permutation Sequence @@ -23,7 +23,7 @@ ----- -####总结 +#### 总结 [Permutations](./Leetcode/Permutations.py) [II](./Leetcode/Permutations_II.py), [Combinations](./Leetcode/Combinations.py), [Combinations Sum](./Leetcode/Combination_Sum.py) [II](./Leetcode/Combination_Sum_II.py) @@ -43,7 +43,7 @@ * Subsets - ```sub_helper(S[i+1:], res, ret)```(S[i+1:]) ```S[i+1:]``决定了res内是不会有重复项的(除非S本身就有重复), ```S[i:]```让当前元素可以重复使用 -#####Note +##### Note * II类去重题相比较I类题唯一的差别就是在循环的第一行需要check```if i > 0 and S[i] == S[i-1]: continue``` * 注意II类题都需要先```sort```, 因为去重是判断前项相等否 * 普通题目看情况如果要求输入时```res```内的元素有序那也需要```sort``` @@ -52,7 +52,7 @@ 所以是```comb_sum_II_helper(num[i+1:], target - n, res, ret)``` * 记得尽量用```enumerate``` -#####复杂度O(n) +##### 复杂度O(n) * Permutation: ```T(n) = n * T(n-1) + O(1)```所以是O(n!) * Combination and Subsets 运用递归公式 @@ -84,7 +84,7 @@ * [x] Palindrome Partitioning * [x] Palindrome Partitioning II -###Tree Traversal +### Tree Traversal * [x] Binary Tree Inorder Traversal * [x] Binary Tree Preorder Traversal * [x] Binary Tree Postorder Traversal @@ -112,7 +112,7 @@ _____ * [x] Validate Binary Search Tree * [x] Recover Binary Search Tree -###类Tree(以tree作为Data Structure的题目) +### 类Tree(以tree作为Data Structure的题目) * [x] Path Sum * [x] Path Sum II * [x] Populating Next Right Pointers in Each Node @@ -121,7 +121,7 @@ _____ * [x] Flatten Binary Tree to Linked List * [x] Binary Tree Maximum Path Sum -###Array(意义不大) +### Array(意义不大) * [x] Maximum Subarray * [x] Convert Sorted Array to Binary Search Tree * [x] Merge Sorted Array @@ -132,7 +132,7 @@ _____ * [x] Median of Two Sorted Arrays * [x] Remove Element -###List(意义不大) +### List(意义不大) * [x] Linked List Cycle * [x] Linked List Cycle II * [x] Remove Duplicates from Sorted List @@ -149,11 +149,11 @@ _____ * [x] Reorder List * [x] Reverse Nodes in k-Group -######Dup with tree +###### Dup with tree * [ ] Flatten Binary Tree to Linked List * [ ] Convert Sorted List to Binary Search Tree -###Matrix +### Matrix * [x] Search a 2D Matrix * [x] Spiral Matrix * [x] Spiral Matrix II @@ -161,7 +161,7 @@ _____ * [x] Valid Sudoku * [x] Sudoku Solver -###Play With Math +### Play With Math * [x] Reverse Integer * [x] Roman to Integer * [x] Intger to Roman @@ -170,7 +170,7 @@ _____ ----- -###Dynamic Programming +### Dynamic Programming * [x] Unique Paths * [x] Unique Paths II * [x] Minimum Path Sum @@ -205,43 +205,43 @@ _____ ----- -##From NC DP Class +## From NC DP Class -###模板 +### 模板 * 状态 state: 灵感, 创造力, 储存小规模问题的结果 * 转移方程 transfer function: 状态之间的联系, 怎么通过小的状态来算大的状态 * 初始化 initialization: 最极限的小状态是什么 * 答案 answer: 最大的那个状态是什么 -###Clues +### Clues 1. Cannot sort, or swap 2. Satisfy: * Find a maximum/minimum result * Decide whether something is possible or not * Count all possible solutions(Doesn't care about solution details, only care about the count or possibility) -###Types of DP +### Types of DP -####1. Matrix DP 20% (Triangle, Unique Path, ...) +#### 1. Matrix DP 20% (Triangle, Unique Path, ...) * state: ```dp[x][y]```表示从起点走到坐标 (x,y) 的xxx * function: 研究下一步怎么走 * initialize: 起点 * answer: 终点 * 复杂度一般为O(n^2) -#####[Triangle](./Leetcode/Triangle.py) +##### [Triangle](./Leetcode/Triangle.py) * status: ```dp[x][y]```表示从bottom走到top每个坐标的最短路径 * function: ```dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j]``` * initialize: ```dp[-1][j] = triangle[-1][j]``` * answer: ```dp[0][0]``` (比较奇怪,因为是由下至上) -#####[Unique Path](./Leetcode/Unique_Paths.py) | [Unique Path II](./Leetcode/Unique_Paths_II.py) +##### [Unique Path](./Leetcode/Unique_Paths.py) | [Unique Path II](./Leetcode/Unique_Paths_II.py) * state: ```dp[x][y]```表示从起点走到 (x,y) 的path数 * function: ```dp[x][y] = dp[x-1][y] + dp[x][y-1]``` | ```if 障碍, dp[x][y] = 0``` * initialize: ```dp[0][y] = 1, dp[x][0] = 1``` * answer: ```dp[M-1][N-1]``` -#####[Minimum Path Sum](./Leetcode/Minimum_Path_Sum.py) +##### [Minimum Path Sum](./Leetcode/Minimum_Path_Sum.py) * state: ```dp[x][y]```表示从起点走到x,y的minimum path sum * function: ```dp[x][y] = min(dp[x-1][y], dp[x][y-1]) + grid[x][y]``` * initialize: ```dp[0][0] = grid[0][0], dp[x][0] = dp[x-1][0] + grid[x][0], dp[0][y] = dp[0][y-1] + grid[0][y]``` @@ -249,32 +249,32 @@ _____ ----- -####2. One Sequence DP 40% +#### 2. One Sequence DP 40% * state: ```dp[i]```表示前i个位置/数字/字母,以第i个为... * function: ```dp[i] = dp[j] ...j``` 是i之前的一个位置 * initialize: ```dp[0] = ...``` * answer: ```dp[N-1]``` * 复杂度一般为O(n^2) -######[Climbing Stairs](./Leetcode/Climbing_Stairs.py) +###### [Climbing Stairs](./Leetcode/Climbing_Stairs.py) * state: ```dp[i]```表示爬到前i个台阶时的方法数 * function: ```dp[i] = dp[i-1] + dp[i-2]``` * initialize: ```dp[0] = 1, dp[1] = 2``` * answer: ```dp[N-1]``` -######[Jump Game](./Leetcode/Jump_Game.py) | [Jump Game II](./Leetcode/Jump_Game_II.py) +###### [Jump Game](./Leetcode/Jump_Game.py) | [Jump Game II](./Leetcode/Jump_Game_II.py) * state: ```dp[i]```表示能否跳到第i个位置O(n^2) (还有一种O(n)的dp, 见方法2) | dp[i]表示跳到这个位置最少需要多少步. * function: ```dp[i] = for j in (i-1 ... 0) if dp[j] and j能跳到i)``` | ```min(dp[j] + 1, j < i and j能跳到i)``` * initialize: ```dp[0] = True``` | ```dp[0] = 0``` * answer: ```dp[N-1]``` -######[Palindrome Partitioning II](./Leetcode/Palindrome_Partitioning_II.py) +###### [Palindrome Partitioning II](./Leetcode/Palindrome_Partitioning_II.py) * state: ```dp[i]```表示前i-1个字符组成的字符串需要最少几次cut * function: ```dp[i] = min( dp[j]+1, j 枚举单词长度 O(NL) N: 字符串长度 L:最长单词的长度 -######[Longest Increasing Subsequence 最长上升子序列](./Interviews/Longest_Increasing_Subsequence.py) [(Not in Leetcode)](http://www.geeksforgeeks.org/dynamic-programming-set-3-longest-increasing-subsequence/) +###### [Longest Increasing Subsequence 最长上升子序列](./Interviews/Longest_Increasing_Subsequence.py) [(Not in Leetcode)](http://www.geeksforgeeks.org/dynamic-programming-set-3-longest-increasing-subsequence/) * state: ~~```dp[i]```表示前i个数字中最长的LIS长度(错误)~~ ```dp[i]```表示第i个数字结尾的LIS长度(正确) * function: ```dp[i] = max(dp[j]+1, j Find kth in two Sorted Arrays -######From zz +###### From zz * [x] Divide Two Integers (This is not binary search since not allowed to use multiply. Bit calculation) * Pow(x, n) * Sqrt(x) -####Three steps reverse +#### Three steps reverse * Recover Rotated Array * -> Recover Rotated String * -> Rotate String @@ -473,7 +473,7 @@ def binary_search(target, A): return -1 ``` -###Divide & Conquer (Most BT Problem) +### Divide & Conquer (Most BT Problem) * Merge Sort * Quick Sort * Tree Traverse @@ -493,7 +493,7 @@ Binary Tree Level Order Traversal 3 ways Check BFS and DFS template -####Not in Leetcode +#### Not in Leetcode * Print BST Keys in Give Range * __Implement Iterator of BST__ * Insert a Node in a Binary Search Tree @@ -502,9 +502,9 @@ Check BFS and DFS template 这个和CC150不太一样, 是从底走, NC答案是Divide an Conquer, CC150是recursion * (tarjan算法) -###DFS +### DFS 主要想法是先搜索到不能再底层然后再往上走 -#####复杂度问题 +##### 复杂度问题 * 组合的话就是O(n^2) * 排列的话就是(n!) @@ -520,19 +520,19 @@ Check BFS and DFS template __无向图求最短路径用BFS, 用Level Order搜索法__ 注意, 因为是单词, 所以做搜索的时候是按字母变化来 -#####[Word Ladder II](./Leetcode/Word_Ladder_II.py) +##### [Word Ladder II](./Leetcode/Word_Ladder_II.py) 1. 最短的是什么 2. 所有最短的是啥 1. 对所有点进行分层BFS 2. 对DFS层进行搜索 -###Graph +### Graph * 图上的BFS需要用HashTable去重 -#####[Clone Graph](./Leetcode/Clone_Graph.py) +##### [Clone Graph](./Leetcode/Clone_Graph.py) -#####[拓扑排序Topological sorting](http://www.geeksforgeeks.org/topological-sorting/) +##### [拓扑排序Topological sorting](http://www.geeksforgeeks.org/topological-sorting/) 主要是入度为零 ``` Q.offer(....) @@ -547,35 +547,35 @@ while (!Q.empty()) { } ``` -###DFS vs BFS -#####DFS - O(2^n), O(n!) +### DFS vs BFS +##### DFS - O(2^n), O(n!) 1. Find all solutions 2. Permutations / Subsets -#####BFS - O(m) O(n) +##### BFS - O(m) O(n) 1. Graph Traversal(每个点都遍历一次) 2. Find shorted path in a simple graph ----- -###Data Structure +### Data Structure -####Stack implement +#### Stack implement * [Min Stack](./Interview/Min_Stack.py) * [Queue by Two Stacks](./Interview/Queue_by_Two_Stacks.py) * Mid Stack * Sort Stack -####Heap -#####Median Number(应该是CC150)里的题 +#### Heap +##### Median Number(应该是CC150)里的题 * 要求插入一个数 * 要求return median number -#####Majority Number +##### Majority Number __去想关于数据结构的题目的时候, 只需要考虑数据结构里处理的次数就行了__ -##Definetly Redo +## Definetly Redo * [x] Regular Expression Matching (Redo) * [x] Wildcard Matching (Redo) * [x] Max Points on a Line (Redo) @@ -628,7 +628,7 @@ __去想关于数据结构的题目的时候, 只需要考虑数据结构里处 * [x] Median of Two Sorted Arrays * [x] Insertion Sort / Merge Sort Linked List -##记忆思考方式 +## 记忆思考方式 * [x] Validate Binary Search Tree (需要记忆如何思考这题) * [x] Trapping Water (especially the way to think) * [x] Container With Most Water @@ -637,7 +637,7 @@ __去想关于数据结构的题目的时候, 只需要考虑数据结构里处 * [x] Divde two integers * [x] Single Number II -##Need Understand +## Need Understand * [ ] 最大子矩阵(NC wechat) * [ ] 最大子矩阵乘积 * [ ] 子数组最大差(NC wechat) @@ -648,9 +648,9 @@ __去想关于数据结构的题目的时候, 只需要考虑数据结构里处 * [ ] NC DP 最小调整代价 * [ ] BACKPACK -##New +## New * [x] [Absolute Minimum](./Interviews/Absolute_Minimum.py) -##Some Note +## Some Note 1. 一定要看清题,比如这次就被问了find all palindrome,但是理解成palindrome partitioning了,所以错了 2. 再仔细确认下怎么算recursion的big O From afc9420cd09f5eeb523403fde4e4995b42de6005 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 18:04:51 -0700 Subject: [PATCH 09/50] test --- coding_index.md | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/coding_index.md b/coding_index.md index 0730849..63e31ce 100644 --- a/coding_index.md +++ b/coding_index.md @@ -1,13 +1,12 @@ -## Coding Summary by Keywords and Type +# Coding Summary by Keywords and Type -### Permutation & Combination Type +## Permutation & Combination Type +### Questions * [x] Permutations * [x] Permutations II * [x] Permutation Sequence * [x] Next Permutation ------ - * [x] Combinations * [x] Combination Sum * [x] Combination Sum II @@ -15,15 +14,10 @@ * [x] 找零钱 I == Combination Sum I * [x] 找零钱 II 求ways最好就不要用dfs了,最好方法是O(m*n) - ------ - * [x] Subset * [x] Subset II ------ - -#### 总结 +### 总结 [Permutations](./Leetcode/Permutations.py) [II](./Leetcode/Permutations_II.py), [Combinations](./Leetcode/Combinations.py), [Combinations Sum](./Leetcode/Combination_Sum.py) [II](./Leetcode/Combination_Sum_II.py) @@ -37,13 +31,13 @@ 前三种题存过结果只后程序应该return 2. 循环内call recursion时的输入变量不一样 - * Permu - ```permu_helper(num[:i] + num[i+i:], res, ret)```(除了S[i]) - * Combin - ```comb_helper(i+1, n, k, res, ret)```(S[i+1:]) - * Combin Sum - ```comb_sum_helper(num[i:], target - n, res, ret)```(S[i:]) - * Subsets - ```sub_helper(S[i+1:], res, ret)```(S[i+1:]) - ```S[i+1:]``决定了res内是不会有重复项的(除非S本身就有重复), ```S[i:]```让当前元素可以重复使用 + * Permu - `permu_helper(num[:i] + num[i+i:], res, ret)`(除了S[i]) + * Combin - `comb_helper(i+1, n, k, res, ret)`(S[i+1:]) + * Combin Sum - `comb_sum_helper(num[i:], target - n, res, ret)`(S[i:]) + * Subsets - `sub_helper(S[i+1:], res, ret)`(S[i+1:]) + `S[i+1:]`决定了res内是不会有重复项的(除非S本身就有重复), `S[i:]`让当前元素可以重复使用 -##### Note +### Note * II类去重题相比较I类题唯一的差别就是在循环的第一行需要check```if i > 0 and S[i] == S[i-1]: continue``` * 注意II类题都需要先```sort```, 因为去重是判断前项相等否 * 普通题目看情况如果要求输入时```res```内的元素有序那也需要```sort``` @@ -52,7 +46,7 @@ 所以是```comb_sum_II_helper(num[i+1:], target - n, res, ret)``` * 记得尽量用```enumerate``` -##### 复杂度O(n) +### 复杂度O(n) * Permutation: ```T(n) = n * T(n-1) + O(1)```所以是O(n!) * Combination and Subsets 运用递归公式 @@ -105,7 +99,7 @@ _____ * [x] Maximum Depth of Binary Tree * [x] Minimum Depth of Binary Tree -###Binary Search Tree +### Binary Search Tree * [x] Convert Sorted Array to Binary Search Tree * [x] Unique Binary Search Trees * [x] Unique Binary Search Trees II From d00cfd283c514c78f727692c2ce825482714a36c Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 18:06:18 -0700 Subject: [PATCH 10/50] test --- coding_index.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/coding_index.md b/coding_index.md index 63e31ce..6a03d14 100644 --- a/coding_index.md +++ b/coding_index.md @@ -2,20 +2,21 @@ ## Permutation & Combination Type ### Questions -* [x] Permutations -* [x] Permutations II -* [x] Permutation Sequence -* [x] Next Permutation - -* [x] Combinations -* [x] Combination Sum -* [x] Combination Sum II -* [x] Letter Combination of a Phone Number -* [x] 找零钱 I == Combination Sum I -* [x] 找零钱 II 求ways最好就不要用dfs了,最好方法是O(m*n) - -* [x] Subset -* [x] Subset II +* Permutations + * [x] Permutations + * [x] Permutations II + * [x] Permutation Sequence + * [x] Next Permutation +* Combinations + * [x] Combinations + * [x] Combination Sum + * [x] Combination Sum II + * [x] Letter Combination of a Phone Number + * [x] 找零钱 I == Combination Sum I + * [x] 找零钱 II 求ways最好就不要用dfs了,最好方法是O(m*n) +* Subset + * [x] Subset + * [x] Subset II ### 总结 [Permutations](./Leetcode/Permutations.py) [II](./Leetcode/Permutations_II.py), From 5bee930edd3daf9b5170d4b356bf8f5b8ad4c2c0 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 20 Oct 2018 18:23:20 -0700 Subject: [PATCH 11/50] rollback --- coding_index.md | 61 ++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/coding_index.md b/coding_index.md index 6a03d14..0730849 100644 --- a/coding_index.md +++ b/coding_index.md @@ -1,24 +1,29 @@ -# Coding Summary by Keywords and Type - -## Permutation & Combination Type -### Questions -* Permutations - * [x] Permutations - * [x] Permutations II - * [x] Permutation Sequence - * [x] Next Permutation -* Combinations - * [x] Combinations - * [x] Combination Sum - * [x] Combination Sum II - * [x] Letter Combination of a Phone Number - * [x] 找零钱 I == Combination Sum I - * [x] 找零钱 II 求ways最好就不要用dfs了,最好方法是O(m*n) -* Subset - * [x] Subset - * [x] Subset II +## Coding Summary by Keywords and Type -### 总结 +### Permutation & Combination Type +* [x] Permutations +* [x] Permutations II +* [x] Permutation Sequence +* [x] Next Permutation + +----- + +* [x] Combinations +* [x] Combination Sum +* [x] Combination Sum II +* [x] Letter Combination of a Phone Number +* [x] 找零钱 I == Combination Sum I +* [x] 找零钱 II 求ways最好就不要用dfs了,最好方法是O(m*n) + + +----- + +* [x] Subset +* [x] Subset II + +----- + +#### 总结 [Permutations](./Leetcode/Permutations.py) [II](./Leetcode/Permutations_II.py), [Combinations](./Leetcode/Combinations.py), [Combinations Sum](./Leetcode/Combination_Sum.py) [II](./Leetcode/Combination_Sum_II.py) @@ -32,13 +37,13 @@ 前三种题存过结果只后程序应该return 2. 循环内call recursion时的输入变量不一样 - * Permu - `permu_helper(num[:i] + num[i+i:], res, ret)`(除了S[i]) - * Combin - `comb_helper(i+1, n, k, res, ret)`(S[i+1:]) - * Combin Sum - `comb_sum_helper(num[i:], target - n, res, ret)`(S[i:]) - * Subsets - `sub_helper(S[i+1:], res, ret)`(S[i+1:]) - `S[i+1:]`决定了res内是不会有重复项的(除非S本身就有重复), `S[i:]`让当前元素可以重复使用 + * Permu - ```permu_helper(num[:i] + num[i+i:], res, ret)```(除了S[i]) + * Combin - ```comb_helper(i+1, n, k, res, ret)```(S[i+1:]) + * Combin Sum - ```comb_sum_helper(num[i:], target - n, res, ret)```(S[i:]) + * Subsets - ```sub_helper(S[i+1:], res, ret)```(S[i+1:]) + ```S[i+1:]``决定了res内是不会有重复项的(除非S本身就有重复), ```S[i:]```让当前元素可以重复使用 -### Note +##### Note * II类去重题相比较I类题唯一的差别就是在循环的第一行需要check```if i > 0 and S[i] == S[i-1]: continue``` * 注意II类题都需要先```sort```, 因为去重是判断前项相等否 * 普通题目看情况如果要求输入时```res```内的元素有序那也需要```sort``` @@ -47,7 +52,7 @@ 所以是```comb_sum_II_helper(num[i+1:], target - n, res, ret)``` * 记得尽量用```enumerate``` -### 复杂度O(n) +##### 复杂度O(n) * Permutation: ```T(n) = n * T(n-1) + O(1)```所以是O(n!) * Combination and Subsets 运用递归公式 @@ -100,7 +105,7 @@ _____ * [x] Maximum Depth of Binary Tree * [x] Minimum Depth of Binary Tree -### Binary Search Tree +###Binary Search Tree * [x] Convert Sorted Array to Binary Search Tree * [x] Unique Binary Search Trees * [x] Unique Binary Search Trees II From 4ffb2f39e1e847e1fb77d9949ae79ec843a368c6 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 14 Jul 2019 19:02:48 -0700 Subject: [PATCH 12/50] Reorg the folder --- tips.md => Archive/tips.md | 0 old_jedi.md => Jedi/old_jedi.md | 0 .../Concept_Implement}/Binary_Search.py | 0 .../Concept_Implement}/Cache.py | 0 .../Concept_Implement}/Closures.md | 0 .../Concept_Implement}/ConsistentHashing.py | 0 .../Concept_Implement}/HashTable.py | 0 .../Concept_Implement}/MapReduce.py | 0 .../Concept_Implement}/OOD.py | 0 .../Concept_Implement}/Trie.py | 0 .../Leetcode Order by Frequency.xlsx | Bin {Leetcode => Ninja/Leetcode}/3Sum.py | 0 {Leetcode => Ninja/Leetcode}/3Sum_Closest.py | 0 {Leetcode => Ninja/Leetcode}/4Sum.py | 0 {Leetcode => Ninja/Leetcode}/Add_Binary.py | 0 .../Leetcode}/Add_Two_Numbers.py | 0 {Leetcode => Ninja/Leetcode}/Anagrams.py | 0 .../Leetcode}/Balanced_Binary_Tree.py | 0 .../Best_Time_to_Buy_and_Sell_Stock.py | 0 .../Best_Time_to_Buy_and_Sell_Stock_II.py | 0 .../Best_Time_to_Buy_and_Sell_Stock_III.py | 0 .../Binary_Tree_Inorder_Traversal.py | 0 .../Binary_Tree_Level_Order_Traversal.py | 0 .../Binary_Tree_Level_Order_Traversal_II.py | 0 .../Leetcode}/Binary_Tree_Maximum_Path_Sum.py | 0 .../Binary_Tree_Postorder_Traversal.py | 0 .../Binary_Tree_Preorder_Traversal.py | 0 ...inary_Tree_Zigzag_Level_Order_Traversal.py | 0 {Leetcode => Ninja/Leetcode}/Candy.py | 0 .../Leetcode}/Climbing_Stairs.py | 0 {Leetcode => Ninja/Leetcode}/Clone_Graph.py | 0 .../Leetcode}/Combination_Sum.py | 0 .../Leetcode}/Combination_Sum_II.py | 0 {Leetcode => Ninja/Leetcode}/Combinations.py | 0 ...ee_from_Inorder_and_Postorder_Traversal.py | 0 ...ree_from_Preorder_and_Inorder_Traversal.py | 0 .../Leetcode}/Container_With_Most_Water.py | 0 ...vert_Sorted_Array_to_Binary_Search_Tree.py | 0 ...nvert_Sorted_List_to_Binary_Search_Tree.py | 0 .../Copy_List_with_Random_Pointer.py | 0 {Leetcode => Ninja/Leetcode}/Count_and_Say.py | 0 {Leetcode => Ninja/Leetcode}/Decode_Ways.py | 0 .../Leetcode}/Distinct_Subsequences.py | 0 .../Leetcode}/Divide_Two_Integers.py | 0 {Leetcode => Ninja/Leetcode}/Edit_Distance.py | 0 .../Evaluate_Reverse_Polish_Notation.py | 0 .../Leetcode}/First_Missing_Positive.py | 0 .../Flatten_Binary_Tree_to_Linked_List.py | 0 {Leetcode => Ninja/Leetcode}/Gas_Station.py | 0 .../Leetcode}/Generate_Parentheses.py | 0 {Leetcode => Ninja/Leetcode}/Gray_Code.py | 0 .../Leetcode}/Implement_strStr.py | 0 .../Leetcode}/Insert_Interval.py | 0 .../Leetcode}/Insertion_Sort_List.py | 0 .../Leetcode}/Integer_to_Roman.py | 0 .../Leetcode}/Interleaving_String.py | 0 {Leetcode => Ninja/Leetcode}/Jump_Game.py | 0 {Leetcode => Ninja/Leetcode}/Jump_Game_II.py | 0 {Leetcode => Ninja/Leetcode}/LRU_Cache.py | 0 .../Largest_Rectangle_in_Histogram.py | 0 .../Leetcode}/Length_of_Last_Word.py | 0 .../Letter_Combinations_of_a_Phone_Number.py | 0 .../Leetcode}/Linked_List_Cycle.py | 0 .../Leetcode}/Linked_List_Cycle_II.py | 0 .../Leetcode}/Longest_Common_Prefix.py | 0 .../Leetcode}/Longest_Consecutive_Sequence.py | 0 .../Longest_Palindromic_Substring.py | 0 ..._Substring_Without_Repeating_Characters.py | 0 .../Leetcode}/Longest_Valid_Parentheses.py | 0 .../Leetcode}/Max_Points_on_a_Line.py | 0 .../Leetcode}/Maximal_Rectangle.py | 0 .../Leetcode}/Maximum_Depth_of_Binary_Tree.py | 0 .../Leetcode}/Maximum_Product_Subarray.py | 0 .../Leetcode}/Maximum_Subarray.py | 0 .../Leetcode}/Median_of_Two_Sorted_Arrays.py | 0 .../Leetcode}/Merge_Intervals.py | 0 .../Leetcode}/Merge_Sorted_Array.py | 0 .../Leetcode}/Merge_Two_Sorted_Lists.py | 0 .../Leetcode}/Merge_k_Sorted_Lists.py | 0 .../Leetcode}/Minimum_Depth_of_Binary_Tree.py | 0 .../Leetcode}/Minimum_Path_Sum.py | 0 .../Leetcode}/Minimum_Window_Substring.py | 0 .../Leetcode}/Multiply_Strings.py | 0 {Leetcode => Ninja/Leetcode}/N-Queens.py | 0 {Leetcode => Ninja/Leetcode}/N-Queens_II.py | 0 .../Leetcode}/Next_Permutation.py | 0 .../Leetcode}/Palindrome_Number.py | 0 .../Leetcode}/Palindrome_Partitioning.py | 0 .../Leetcode}/Palindrome_Partitioning_II.py | 0 .../Leetcode}/Partition_List.py | 0 .../Leetcode}/Pascals_Triangle.py | 0 .../Leetcode}/Pascals_Triangle_II.py | 0 {Leetcode => Ninja/Leetcode}/Path_Sum.py | 0 {Leetcode => Ninja/Leetcode}/Path_Sum_II.py | 0 .../Leetcode}/Permutation_Sequence.py | 0 {Leetcode => Ninja/Leetcode}/Permutations.py | 0 .../Leetcode}/Permutations_II.py | 0 {Leetcode => Ninja/Leetcode}/Plus_One.py | 0 ...lating_Next_Right_Pointers_in_Each_Node.py | 0 ...ing_Next_Right_Pointers_in_Each_Node_II.py | 0 {Leetcode => Ninja/Leetcode}/Powx-n.py | 0 .../Leetcode}/Recover_Binary_Search_Tree.py | 0 .../Leetcode}/Regular_Expression_Matching.py | 0 .../Remove_Duplicates_from_Sorted_Array.py | 0 .../Remove_Duplicates_from_Sorted_Array_II.py | 0 .../Remove_Duplicates_from_Sorted_List.py | 0 .../Remove_Duplicates_from_Sorted_List_II.py | 0 .../Leetcode}/Remove_Element.py | 0 .../Remove_Nth_Node_From_End_of_List.py | 0 {Leetcode => Ninja/Leetcode}/Reorder_List.py | 0 .../Leetcode}/Restore_IP_Addresses.py | 0 .../Leetcode}/Reverse_Integer.py | 0 .../Leetcode}/Reverse_Linked_List_II.py | 0 .../Leetcode}/Reverse_Nodes_in_k-Group.py | 0 .../Leetcode}/Reverse_Words_in_a_String.py | 0 .../Leetcode}/Roman_to_Integer.py | 0 {Leetcode => Ninja/Leetcode}/Rotate_Image.py | 0 {Leetcode => Ninja/Leetcode}/Rotate_List.py | 0 {Leetcode => Ninja/Leetcode}/Same_Tree.py | 0 .../Leetcode}/Scramble_String.py | 0 .../Leetcode}/Search_Insert_Position.py | 0 .../Leetcode}/Search_a_2D_Matrix.py | 0 .../Leetcode}/Search_for_a_Range.py | 0 .../Search_in_Rotated_Sorted_Array.py | 0 .../Search_in_Rotated_Sorted_Array_II.py | 0 .../Leetcode}/Set_Matrix_Zeroes.py | 0 {Leetcode => Ninja/Leetcode}/Simplify_Path.py | 0 {Leetcode => Ninja/Leetcode}/Single_Number.py | 0 .../Leetcode}/Single_Number_II.py | 0 {Leetcode => Ninja/Leetcode}/Sort_Colors.py | 0 {Leetcode => Ninja/Leetcode}/Sort_List.py | 0 {Leetcode => Ninja/Leetcode}/Spiral_Matrix.py | 0 .../Leetcode}/Spiral_Matrix_II.py | 0 {Leetcode => Ninja/Leetcode}/Sqrtx.py | 0 .../Leetcode}/String_to_Integer_atoi.py | 0 {Leetcode => Ninja/Leetcode}/Subsets.py | 0 {Leetcode => Ninja/Leetcode}/Subsets_II.py | 0 ...bstring_with_Concatenation_of_All_Words.py | 0 {Leetcode => Ninja/Leetcode}/Sudoku_Solver.py | 0 .../Leetcode}/Sum_Root_to_Leaf_Numbers.py | 0 .../Leetcode}/Surrounded_Regions.py | 0 .../Leetcode}/Swap_Nodes_in_Pairs.py | 0 .../Leetcode}/Symmetric_Tree.py | 0 .../Leetcode}/Text_Justification.py | 0 .../Leetcode}/Trapping_Rain_Water.py | 0 {Leetcode => Ninja/Leetcode}/Triangle.py | 0 {Leetcode => Ninja/Leetcode}/Two_Sum.py | 0 .../Leetcode}/Unique_Binary_Search_Trees.py | 0 .../Unique_Binary_Search_Trees_II.py | 0 {Leetcode => Ninja/Leetcode}/Unique_Paths.py | 0 .../Leetcode}/Unique_Paths_II.py | 0 {Leetcode => Ninja/Leetcode}/Valid_Number.py | 0 .../Leetcode}/Valid_Palindrome.py | 0 .../Leetcode}/Valid_Parentheses.py | 0 {Leetcode => Ninja/Leetcode}/Valid_Sudoku.py | 0 .../Leetcode}/Validate_Binary_Search_Tree.py | 0 .../Leetcode}/Wildcard_Matching.py | 0 {Leetcode => Ninja/Leetcode}/Word_Break.py | 0 {Leetcode => Ninja/Leetcode}/Word_Break_II.py | 0 {Leetcode => Ninja/Leetcode}/Word_Ladder.py | 0 .../Leetcode}/Word_Ladder_II.py | 0 {Leetcode => Ninja/Leetcode}/Word_Search.py | 0 .../Leetcode}/ZigZag_Conversion.py | 0 {Leetcode => Ninja/Leetcode}/__init__.py | 0 {WhiteBook => Ninja/WhiteBook}/array_str.py | 0 {WhiteBook => Ninja/WhiteBook}/bst.py | 0 {WhiteBook => Ninja/WhiteBook}/bt.py | 0 {WhiteBook => Ninja/WhiteBook}/node.py | 0 .../WhiteBook}/search_n_sort.py | 0 {WhiteBook => Ninja/WhiteBook}/stack_q.py | 0 {WhiteBook => Ninja/WhiteBook}/tree_node.py | 0 coding_index.md => Ninja/coding_index.md | 0 frequency.md => Ninja/frequency.md | 0 leetcode.py => Ninja/leetcode.py | 0 Ninja/playground.py | 67 ++++++++++++++++++ .../zz_coding_index.md | 0 knowledge.md => Pirate/knowledge.md | 0 system_design.md => Pirate/system_design.md | 0 run.py | 10 --- 179 files changed, 67 insertions(+), 10 deletions(-) rename tips.md => Archive/tips.md (100%) rename old_jedi.md => Jedi/old_jedi.md (100%) rename {Concept_Implement => Ninja/Concept_Implement}/Binary_Search.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/Cache.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/Closures.md (100%) rename {Concept_Implement => Ninja/Concept_Implement}/ConsistentHashing.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/HashTable.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/MapReduce.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/OOD.py (100%) rename {Concept_Implement => Ninja/Concept_Implement}/Trie.py (100%) rename Leetcode Order by Frequency.xlsx => Ninja/Leetcode Order by Frequency.xlsx (100%) rename {Leetcode => Ninja/Leetcode}/3Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/3Sum_Closest.py (100%) rename {Leetcode => Ninja/Leetcode}/4Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Add_Binary.py (100%) rename {Leetcode => Ninja/Leetcode}/Add_Two_Numbers.py (100%) rename {Leetcode => Ninja/Leetcode}/Anagrams.py (100%) rename {Leetcode => Ninja/Leetcode}/Balanced_Binary_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Best_Time_to_Buy_and_Sell_Stock.py (100%) rename {Leetcode => Ninja/Leetcode}/Best_Time_to_Buy_and_Sell_Stock_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Best_Time_to_Buy_and_Sell_Stock_III.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Inorder_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Level_Order_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Level_Order_Traversal_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Maximum_Path_Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Postorder_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Preorder_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Binary_Tree_Zigzag_Level_Order_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Candy.py (100%) rename {Leetcode => Ninja/Leetcode}/Climbing_Stairs.py (100%) rename {Leetcode => Ninja/Leetcode}/Clone_Graph.py (100%) rename {Leetcode => Ninja/Leetcode}/Combination_Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Combination_Sum_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Combinations.py (100%) rename {Leetcode => Ninja/Leetcode}/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py (100%) rename {Leetcode => Ninja/Leetcode}/Container_With_Most_Water.py (100%) rename {Leetcode => Ninja/Leetcode}/Convert_Sorted_Array_to_Binary_Search_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Convert_Sorted_List_to_Binary_Search_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Copy_List_with_Random_Pointer.py (100%) rename {Leetcode => Ninja/Leetcode}/Count_and_Say.py (100%) rename {Leetcode => Ninja/Leetcode}/Decode_Ways.py (100%) rename {Leetcode => Ninja/Leetcode}/Distinct_Subsequences.py (100%) rename {Leetcode => Ninja/Leetcode}/Divide_Two_Integers.py (100%) rename {Leetcode => Ninja/Leetcode}/Edit_Distance.py (100%) rename {Leetcode => Ninja/Leetcode}/Evaluate_Reverse_Polish_Notation.py (100%) rename {Leetcode => Ninja/Leetcode}/First_Missing_Positive.py (100%) rename {Leetcode => Ninja/Leetcode}/Flatten_Binary_Tree_to_Linked_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Gas_Station.py (100%) rename {Leetcode => Ninja/Leetcode}/Generate_Parentheses.py (100%) rename {Leetcode => Ninja/Leetcode}/Gray_Code.py (100%) rename {Leetcode => Ninja/Leetcode}/Implement_strStr.py (100%) rename {Leetcode => Ninja/Leetcode}/Insert_Interval.py (100%) rename {Leetcode => Ninja/Leetcode}/Insertion_Sort_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Integer_to_Roman.py (100%) rename {Leetcode => Ninja/Leetcode}/Interleaving_String.py (100%) rename {Leetcode => Ninja/Leetcode}/Jump_Game.py (100%) rename {Leetcode => Ninja/Leetcode}/Jump_Game_II.py (100%) rename {Leetcode => Ninja/Leetcode}/LRU_Cache.py (100%) rename {Leetcode => Ninja/Leetcode}/Largest_Rectangle_in_Histogram.py (100%) rename {Leetcode => Ninja/Leetcode}/Length_of_Last_Word.py (100%) rename {Leetcode => Ninja/Leetcode}/Letter_Combinations_of_a_Phone_Number.py (100%) rename {Leetcode => Ninja/Leetcode}/Linked_List_Cycle.py (100%) rename {Leetcode => Ninja/Leetcode}/Linked_List_Cycle_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Longest_Common_Prefix.py (100%) rename {Leetcode => Ninja/Leetcode}/Longest_Consecutive_Sequence.py (100%) rename {Leetcode => Ninja/Leetcode}/Longest_Palindromic_Substring.py (100%) rename {Leetcode => Ninja/Leetcode}/Longest_Substring_Without_Repeating_Characters.py (100%) rename {Leetcode => Ninja/Leetcode}/Longest_Valid_Parentheses.py (100%) rename {Leetcode => Ninja/Leetcode}/Max_Points_on_a_Line.py (100%) rename {Leetcode => Ninja/Leetcode}/Maximal_Rectangle.py (100%) rename {Leetcode => Ninja/Leetcode}/Maximum_Depth_of_Binary_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Maximum_Product_Subarray.py (100%) rename {Leetcode => Ninja/Leetcode}/Maximum_Subarray.py (100%) rename {Leetcode => Ninja/Leetcode}/Median_of_Two_Sorted_Arrays.py (100%) rename {Leetcode => Ninja/Leetcode}/Merge_Intervals.py (100%) rename {Leetcode => Ninja/Leetcode}/Merge_Sorted_Array.py (100%) rename {Leetcode => Ninja/Leetcode}/Merge_Two_Sorted_Lists.py (100%) rename {Leetcode => Ninja/Leetcode}/Merge_k_Sorted_Lists.py (100%) rename {Leetcode => Ninja/Leetcode}/Minimum_Depth_of_Binary_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Minimum_Path_Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Minimum_Window_Substring.py (100%) rename {Leetcode => Ninja/Leetcode}/Multiply_Strings.py (100%) rename {Leetcode => Ninja/Leetcode}/N-Queens.py (100%) rename {Leetcode => Ninja/Leetcode}/N-Queens_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Next_Permutation.py (100%) rename {Leetcode => Ninja/Leetcode}/Palindrome_Number.py (100%) rename {Leetcode => Ninja/Leetcode}/Palindrome_Partitioning.py (100%) rename {Leetcode => Ninja/Leetcode}/Palindrome_Partitioning_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Partition_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Pascals_Triangle.py (100%) rename {Leetcode => Ninja/Leetcode}/Pascals_Triangle_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Path_Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Path_Sum_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Permutation_Sequence.py (100%) rename {Leetcode => Ninja/Leetcode}/Permutations.py (100%) rename {Leetcode => Ninja/Leetcode}/Permutations_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Plus_One.py (100%) rename {Leetcode => Ninja/Leetcode}/Populating_Next_Right_Pointers_in_Each_Node.py (100%) rename {Leetcode => Ninja/Leetcode}/Populating_Next_Right_Pointers_in_Each_Node_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Powx-n.py (100%) rename {Leetcode => Ninja/Leetcode}/Recover_Binary_Search_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Regular_Expression_Matching.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Duplicates_from_Sorted_Array.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Duplicates_from_Sorted_Array_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Duplicates_from_Sorted_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Duplicates_from_Sorted_List_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Element.py (100%) rename {Leetcode => Ninja/Leetcode}/Remove_Nth_Node_From_End_of_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Reorder_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Restore_IP_Addresses.py (100%) rename {Leetcode => Ninja/Leetcode}/Reverse_Integer.py (100%) rename {Leetcode => Ninja/Leetcode}/Reverse_Linked_List_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Reverse_Nodes_in_k-Group.py (100%) rename {Leetcode => Ninja/Leetcode}/Reverse_Words_in_a_String.py (100%) rename {Leetcode => Ninja/Leetcode}/Roman_to_Integer.py (100%) rename {Leetcode => Ninja/Leetcode}/Rotate_Image.py (100%) rename {Leetcode => Ninja/Leetcode}/Rotate_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Same_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Scramble_String.py (100%) rename {Leetcode => Ninja/Leetcode}/Search_Insert_Position.py (100%) rename {Leetcode => Ninja/Leetcode}/Search_a_2D_Matrix.py (100%) rename {Leetcode => Ninja/Leetcode}/Search_for_a_Range.py (100%) rename {Leetcode => Ninja/Leetcode}/Search_in_Rotated_Sorted_Array.py (100%) rename {Leetcode => Ninja/Leetcode}/Search_in_Rotated_Sorted_Array_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Set_Matrix_Zeroes.py (100%) rename {Leetcode => Ninja/Leetcode}/Simplify_Path.py (100%) rename {Leetcode => Ninja/Leetcode}/Single_Number.py (100%) rename {Leetcode => Ninja/Leetcode}/Single_Number_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Sort_Colors.py (100%) rename {Leetcode => Ninja/Leetcode}/Sort_List.py (100%) rename {Leetcode => Ninja/Leetcode}/Spiral_Matrix.py (100%) rename {Leetcode => Ninja/Leetcode}/Spiral_Matrix_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Sqrtx.py (100%) rename {Leetcode => Ninja/Leetcode}/String_to_Integer_atoi.py (100%) rename {Leetcode => Ninja/Leetcode}/Subsets.py (100%) rename {Leetcode => Ninja/Leetcode}/Subsets_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Substring_with_Concatenation_of_All_Words.py (100%) rename {Leetcode => Ninja/Leetcode}/Sudoku_Solver.py (100%) rename {Leetcode => Ninja/Leetcode}/Sum_Root_to_Leaf_Numbers.py (100%) rename {Leetcode => Ninja/Leetcode}/Surrounded_Regions.py (100%) rename {Leetcode => Ninja/Leetcode}/Swap_Nodes_in_Pairs.py (100%) rename {Leetcode => Ninja/Leetcode}/Symmetric_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Text_Justification.py (100%) rename {Leetcode => Ninja/Leetcode}/Trapping_Rain_Water.py (100%) rename {Leetcode => Ninja/Leetcode}/Triangle.py (100%) rename {Leetcode => Ninja/Leetcode}/Two_Sum.py (100%) rename {Leetcode => Ninja/Leetcode}/Unique_Binary_Search_Trees.py (100%) rename {Leetcode => Ninja/Leetcode}/Unique_Binary_Search_Trees_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Unique_Paths.py (100%) rename {Leetcode => Ninja/Leetcode}/Unique_Paths_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Valid_Number.py (100%) rename {Leetcode => Ninja/Leetcode}/Valid_Palindrome.py (100%) rename {Leetcode => Ninja/Leetcode}/Valid_Parentheses.py (100%) rename {Leetcode => Ninja/Leetcode}/Valid_Sudoku.py (100%) rename {Leetcode => Ninja/Leetcode}/Validate_Binary_Search_Tree.py (100%) rename {Leetcode => Ninja/Leetcode}/Wildcard_Matching.py (100%) rename {Leetcode => Ninja/Leetcode}/Word_Break.py (100%) rename {Leetcode => Ninja/Leetcode}/Word_Break_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Word_Ladder.py (100%) rename {Leetcode => Ninja/Leetcode}/Word_Ladder_II.py (100%) rename {Leetcode => Ninja/Leetcode}/Word_Search.py (100%) rename {Leetcode => Ninja/Leetcode}/ZigZag_Conversion.py (100%) rename {Leetcode => Ninja/Leetcode}/__init__.py (100%) rename {WhiteBook => Ninja/WhiteBook}/array_str.py (100%) rename {WhiteBook => Ninja/WhiteBook}/bst.py (100%) rename {WhiteBook => Ninja/WhiteBook}/bt.py (100%) rename {WhiteBook => Ninja/WhiteBook}/node.py (100%) rename {WhiteBook => Ninja/WhiteBook}/search_n_sort.py (100%) rename {WhiteBook => Ninja/WhiteBook}/stack_q.py (100%) rename {WhiteBook => Ninja/WhiteBook}/tree_node.py (100%) rename coding_index.md => Ninja/coding_index.md (100%) rename frequency.md => Ninja/frequency.md (100%) rename leetcode.py => Ninja/leetcode.py (100%) create mode 100644 Ninja/playground.py rename zz_coding_index.md => Ninja/zz_coding_index.md (100%) rename knowledge.md => Pirate/knowledge.md (100%) rename system_design.md => Pirate/system_design.md (100%) delete mode 100755 run.py diff --git a/tips.md b/Archive/tips.md similarity index 100% rename from tips.md rename to Archive/tips.md diff --git a/old_jedi.md b/Jedi/old_jedi.md similarity index 100% rename from old_jedi.md rename to Jedi/old_jedi.md diff --git a/Concept_Implement/Binary_Search.py b/Ninja/Concept_Implement/Binary_Search.py similarity index 100% rename from Concept_Implement/Binary_Search.py rename to Ninja/Concept_Implement/Binary_Search.py diff --git a/Concept_Implement/Cache.py b/Ninja/Concept_Implement/Cache.py similarity index 100% rename from Concept_Implement/Cache.py rename to Ninja/Concept_Implement/Cache.py diff --git a/Concept_Implement/Closures.md b/Ninja/Concept_Implement/Closures.md similarity index 100% rename from Concept_Implement/Closures.md rename to Ninja/Concept_Implement/Closures.md diff --git a/Concept_Implement/ConsistentHashing.py b/Ninja/Concept_Implement/ConsistentHashing.py similarity index 100% rename from Concept_Implement/ConsistentHashing.py rename to Ninja/Concept_Implement/ConsistentHashing.py diff --git a/Concept_Implement/HashTable.py b/Ninja/Concept_Implement/HashTable.py similarity index 100% rename from Concept_Implement/HashTable.py rename to Ninja/Concept_Implement/HashTable.py diff --git a/Concept_Implement/MapReduce.py b/Ninja/Concept_Implement/MapReduce.py similarity index 100% rename from Concept_Implement/MapReduce.py rename to Ninja/Concept_Implement/MapReduce.py diff --git a/Concept_Implement/OOD.py b/Ninja/Concept_Implement/OOD.py similarity index 100% rename from Concept_Implement/OOD.py rename to Ninja/Concept_Implement/OOD.py diff --git a/Concept_Implement/Trie.py b/Ninja/Concept_Implement/Trie.py similarity index 100% rename from Concept_Implement/Trie.py rename to Ninja/Concept_Implement/Trie.py diff --git a/Leetcode Order by Frequency.xlsx b/Ninja/Leetcode Order by Frequency.xlsx similarity index 100% rename from Leetcode Order by Frequency.xlsx rename to Ninja/Leetcode Order by Frequency.xlsx diff --git a/Leetcode/3Sum.py b/Ninja/Leetcode/3Sum.py similarity index 100% rename from Leetcode/3Sum.py rename to Ninja/Leetcode/3Sum.py diff --git a/Leetcode/3Sum_Closest.py b/Ninja/Leetcode/3Sum_Closest.py similarity index 100% rename from Leetcode/3Sum_Closest.py rename to Ninja/Leetcode/3Sum_Closest.py diff --git a/Leetcode/4Sum.py b/Ninja/Leetcode/4Sum.py similarity index 100% rename from Leetcode/4Sum.py rename to Ninja/Leetcode/4Sum.py diff --git a/Leetcode/Add_Binary.py b/Ninja/Leetcode/Add_Binary.py similarity index 100% rename from Leetcode/Add_Binary.py rename to Ninja/Leetcode/Add_Binary.py diff --git a/Leetcode/Add_Two_Numbers.py b/Ninja/Leetcode/Add_Two_Numbers.py similarity index 100% rename from Leetcode/Add_Two_Numbers.py rename to Ninja/Leetcode/Add_Two_Numbers.py diff --git a/Leetcode/Anagrams.py b/Ninja/Leetcode/Anagrams.py similarity index 100% rename from Leetcode/Anagrams.py rename to Ninja/Leetcode/Anagrams.py diff --git a/Leetcode/Balanced_Binary_Tree.py b/Ninja/Leetcode/Balanced_Binary_Tree.py similarity index 100% rename from Leetcode/Balanced_Binary_Tree.py rename to Ninja/Leetcode/Balanced_Binary_Tree.py diff --git a/Leetcode/Best_Time_to_Buy_and_Sell_Stock.py b/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock.py similarity index 100% rename from Leetcode/Best_Time_to_Buy_and_Sell_Stock.py rename to Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock.py diff --git a/Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py b/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py similarity index 100% rename from Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py rename to Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py diff --git a/Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py b/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py similarity index 100% rename from Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py rename to Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py diff --git a/Leetcode/Binary_Tree_Inorder_Traversal.py b/Ninja/Leetcode/Binary_Tree_Inorder_Traversal.py similarity index 100% rename from Leetcode/Binary_Tree_Inorder_Traversal.py rename to Ninja/Leetcode/Binary_Tree_Inorder_Traversal.py diff --git a/Leetcode/Binary_Tree_Level_Order_Traversal.py b/Ninja/Leetcode/Binary_Tree_Level_Order_Traversal.py similarity index 100% rename from Leetcode/Binary_Tree_Level_Order_Traversal.py rename to Ninja/Leetcode/Binary_Tree_Level_Order_Traversal.py diff --git a/Leetcode/Binary_Tree_Level_Order_Traversal_II.py b/Ninja/Leetcode/Binary_Tree_Level_Order_Traversal_II.py similarity index 100% rename from Leetcode/Binary_Tree_Level_Order_Traversal_II.py rename to Ninja/Leetcode/Binary_Tree_Level_Order_Traversal_II.py diff --git a/Leetcode/Binary_Tree_Maximum_Path_Sum.py b/Ninja/Leetcode/Binary_Tree_Maximum_Path_Sum.py similarity index 100% rename from Leetcode/Binary_Tree_Maximum_Path_Sum.py rename to Ninja/Leetcode/Binary_Tree_Maximum_Path_Sum.py diff --git a/Leetcode/Binary_Tree_Postorder_Traversal.py b/Ninja/Leetcode/Binary_Tree_Postorder_Traversal.py similarity index 100% rename from Leetcode/Binary_Tree_Postorder_Traversal.py rename to Ninja/Leetcode/Binary_Tree_Postorder_Traversal.py diff --git a/Leetcode/Binary_Tree_Preorder_Traversal.py b/Ninja/Leetcode/Binary_Tree_Preorder_Traversal.py similarity index 100% rename from Leetcode/Binary_Tree_Preorder_Traversal.py rename to Ninja/Leetcode/Binary_Tree_Preorder_Traversal.py diff --git a/Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py b/Ninja/Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py similarity index 100% rename from Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py rename to Ninja/Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py diff --git a/Leetcode/Candy.py b/Ninja/Leetcode/Candy.py similarity index 100% rename from Leetcode/Candy.py rename to Ninja/Leetcode/Candy.py diff --git a/Leetcode/Climbing_Stairs.py b/Ninja/Leetcode/Climbing_Stairs.py similarity index 100% rename from Leetcode/Climbing_Stairs.py rename to Ninja/Leetcode/Climbing_Stairs.py diff --git a/Leetcode/Clone_Graph.py b/Ninja/Leetcode/Clone_Graph.py similarity index 100% rename from Leetcode/Clone_Graph.py rename to Ninja/Leetcode/Clone_Graph.py diff --git a/Leetcode/Combination_Sum.py b/Ninja/Leetcode/Combination_Sum.py similarity index 100% rename from Leetcode/Combination_Sum.py rename to Ninja/Leetcode/Combination_Sum.py diff --git a/Leetcode/Combination_Sum_II.py b/Ninja/Leetcode/Combination_Sum_II.py similarity index 100% rename from Leetcode/Combination_Sum_II.py rename to Ninja/Leetcode/Combination_Sum_II.py diff --git a/Leetcode/Combinations.py b/Ninja/Leetcode/Combinations.py similarity index 100% rename from Leetcode/Combinations.py rename to Ninja/Leetcode/Combinations.py diff --git a/Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py b/Ninja/Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py similarity index 100% rename from Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py rename to Ninja/Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py diff --git a/Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py b/Ninja/Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py similarity index 100% rename from Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py rename to Ninja/Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py diff --git a/Leetcode/Container_With_Most_Water.py b/Ninja/Leetcode/Container_With_Most_Water.py similarity index 100% rename from Leetcode/Container_With_Most_Water.py rename to Ninja/Leetcode/Container_With_Most_Water.py diff --git a/Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py b/Ninja/Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py similarity index 100% rename from Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py rename to Ninja/Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py diff --git a/Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py b/Ninja/Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py similarity index 100% rename from Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py rename to Ninja/Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py diff --git a/Leetcode/Copy_List_with_Random_Pointer.py b/Ninja/Leetcode/Copy_List_with_Random_Pointer.py similarity index 100% rename from Leetcode/Copy_List_with_Random_Pointer.py rename to Ninja/Leetcode/Copy_List_with_Random_Pointer.py diff --git a/Leetcode/Count_and_Say.py b/Ninja/Leetcode/Count_and_Say.py similarity index 100% rename from Leetcode/Count_and_Say.py rename to Ninja/Leetcode/Count_and_Say.py diff --git a/Leetcode/Decode_Ways.py b/Ninja/Leetcode/Decode_Ways.py similarity index 100% rename from Leetcode/Decode_Ways.py rename to Ninja/Leetcode/Decode_Ways.py diff --git a/Leetcode/Distinct_Subsequences.py b/Ninja/Leetcode/Distinct_Subsequences.py similarity index 100% rename from Leetcode/Distinct_Subsequences.py rename to Ninja/Leetcode/Distinct_Subsequences.py diff --git a/Leetcode/Divide_Two_Integers.py b/Ninja/Leetcode/Divide_Two_Integers.py similarity index 100% rename from Leetcode/Divide_Two_Integers.py rename to Ninja/Leetcode/Divide_Two_Integers.py diff --git a/Leetcode/Edit_Distance.py b/Ninja/Leetcode/Edit_Distance.py similarity index 100% rename from Leetcode/Edit_Distance.py rename to Ninja/Leetcode/Edit_Distance.py diff --git a/Leetcode/Evaluate_Reverse_Polish_Notation.py b/Ninja/Leetcode/Evaluate_Reverse_Polish_Notation.py similarity index 100% rename from Leetcode/Evaluate_Reverse_Polish_Notation.py rename to Ninja/Leetcode/Evaluate_Reverse_Polish_Notation.py diff --git a/Leetcode/First_Missing_Positive.py b/Ninja/Leetcode/First_Missing_Positive.py similarity index 100% rename from Leetcode/First_Missing_Positive.py rename to Ninja/Leetcode/First_Missing_Positive.py diff --git a/Leetcode/Flatten_Binary_Tree_to_Linked_List.py b/Ninja/Leetcode/Flatten_Binary_Tree_to_Linked_List.py similarity index 100% rename from Leetcode/Flatten_Binary_Tree_to_Linked_List.py rename to Ninja/Leetcode/Flatten_Binary_Tree_to_Linked_List.py diff --git a/Leetcode/Gas_Station.py b/Ninja/Leetcode/Gas_Station.py similarity index 100% rename from Leetcode/Gas_Station.py rename to Ninja/Leetcode/Gas_Station.py diff --git a/Leetcode/Generate_Parentheses.py b/Ninja/Leetcode/Generate_Parentheses.py similarity index 100% rename from Leetcode/Generate_Parentheses.py rename to Ninja/Leetcode/Generate_Parentheses.py diff --git a/Leetcode/Gray_Code.py b/Ninja/Leetcode/Gray_Code.py similarity index 100% rename from Leetcode/Gray_Code.py rename to Ninja/Leetcode/Gray_Code.py diff --git a/Leetcode/Implement_strStr.py b/Ninja/Leetcode/Implement_strStr.py similarity index 100% rename from Leetcode/Implement_strStr.py rename to Ninja/Leetcode/Implement_strStr.py diff --git a/Leetcode/Insert_Interval.py b/Ninja/Leetcode/Insert_Interval.py similarity index 100% rename from Leetcode/Insert_Interval.py rename to Ninja/Leetcode/Insert_Interval.py diff --git a/Leetcode/Insertion_Sort_List.py b/Ninja/Leetcode/Insertion_Sort_List.py similarity index 100% rename from Leetcode/Insertion_Sort_List.py rename to Ninja/Leetcode/Insertion_Sort_List.py diff --git a/Leetcode/Integer_to_Roman.py b/Ninja/Leetcode/Integer_to_Roman.py similarity index 100% rename from Leetcode/Integer_to_Roman.py rename to Ninja/Leetcode/Integer_to_Roman.py diff --git a/Leetcode/Interleaving_String.py b/Ninja/Leetcode/Interleaving_String.py similarity index 100% rename from Leetcode/Interleaving_String.py rename to Ninja/Leetcode/Interleaving_String.py diff --git a/Leetcode/Jump_Game.py b/Ninja/Leetcode/Jump_Game.py similarity index 100% rename from Leetcode/Jump_Game.py rename to Ninja/Leetcode/Jump_Game.py diff --git a/Leetcode/Jump_Game_II.py b/Ninja/Leetcode/Jump_Game_II.py similarity index 100% rename from Leetcode/Jump_Game_II.py rename to Ninja/Leetcode/Jump_Game_II.py diff --git a/Leetcode/LRU_Cache.py b/Ninja/Leetcode/LRU_Cache.py similarity index 100% rename from Leetcode/LRU_Cache.py rename to Ninja/Leetcode/LRU_Cache.py diff --git a/Leetcode/Largest_Rectangle_in_Histogram.py b/Ninja/Leetcode/Largest_Rectangle_in_Histogram.py similarity index 100% rename from Leetcode/Largest_Rectangle_in_Histogram.py rename to Ninja/Leetcode/Largest_Rectangle_in_Histogram.py diff --git a/Leetcode/Length_of_Last_Word.py b/Ninja/Leetcode/Length_of_Last_Word.py similarity index 100% rename from Leetcode/Length_of_Last_Word.py rename to Ninja/Leetcode/Length_of_Last_Word.py diff --git a/Leetcode/Letter_Combinations_of_a_Phone_Number.py b/Ninja/Leetcode/Letter_Combinations_of_a_Phone_Number.py similarity index 100% rename from Leetcode/Letter_Combinations_of_a_Phone_Number.py rename to Ninja/Leetcode/Letter_Combinations_of_a_Phone_Number.py diff --git a/Leetcode/Linked_List_Cycle.py b/Ninja/Leetcode/Linked_List_Cycle.py similarity index 100% rename from Leetcode/Linked_List_Cycle.py rename to Ninja/Leetcode/Linked_List_Cycle.py diff --git a/Leetcode/Linked_List_Cycle_II.py b/Ninja/Leetcode/Linked_List_Cycle_II.py similarity index 100% rename from Leetcode/Linked_List_Cycle_II.py rename to Ninja/Leetcode/Linked_List_Cycle_II.py diff --git a/Leetcode/Longest_Common_Prefix.py b/Ninja/Leetcode/Longest_Common_Prefix.py similarity index 100% rename from Leetcode/Longest_Common_Prefix.py rename to Ninja/Leetcode/Longest_Common_Prefix.py diff --git a/Leetcode/Longest_Consecutive_Sequence.py b/Ninja/Leetcode/Longest_Consecutive_Sequence.py similarity index 100% rename from Leetcode/Longest_Consecutive_Sequence.py rename to Ninja/Leetcode/Longest_Consecutive_Sequence.py diff --git a/Leetcode/Longest_Palindromic_Substring.py b/Ninja/Leetcode/Longest_Palindromic_Substring.py similarity index 100% rename from Leetcode/Longest_Palindromic_Substring.py rename to Ninja/Leetcode/Longest_Palindromic_Substring.py diff --git a/Leetcode/Longest_Substring_Without_Repeating_Characters.py b/Ninja/Leetcode/Longest_Substring_Without_Repeating_Characters.py similarity index 100% rename from Leetcode/Longest_Substring_Without_Repeating_Characters.py rename to Ninja/Leetcode/Longest_Substring_Without_Repeating_Characters.py diff --git a/Leetcode/Longest_Valid_Parentheses.py b/Ninja/Leetcode/Longest_Valid_Parentheses.py similarity index 100% rename from Leetcode/Longest_Valid_Parentheses.py rename to Ninja/Leetcode/Longest_Valid_Parentheses.py diff --git a/Leetcode/Max_Points_on_a_Line.py b/Ninja/Leetcode/Max_Points_on_a_Line.py similarity index 100% rename from Leetcode/Max_Points_on_a_Line.py rename to Ninja/Leetcode/Max_Points_on_a_Line.py diff --git a/Leetcode/Maximal_Rectangle.py b/Ninja/Leetcode/Maximal_Rectangle.py similarity index 100% rename from Leetcode/Maximal_Rectangle.py rename to Ninja/Leetcode/Maximal_Rectangle.py diff --git a/Leetcode/Maximum_Depth_of_Binary_Tree.py b/Ninja/Leetcode/Maximum_Depth_of_Binary_Tree.py similarity index 100% rename from Leetcode/Maximum_Depth_of_Binary_Tree.py rename to Ninja/Leetcode/Maximum_Depth_of_Binary_Tree.py diff --git a/Leetcode/Maximum_Product_Subarray.py b/Ninja/Leetcode/Maximum_Product_Subarray.py similarity index 100% rename from Leetcode/Maximum_Product_Subarray.py rename to Ninja/Leetcode/Maximum_Product_Subarray.py diff --git a/Leetcode/Maximum_Subarray.py b/Ninja/Leetcode/Maximum_Subarray.py similarity index 100% rename from Leetcode/Maximum_Subarray.py rename to Ninja/Leetcode/Maximum_Subarray.py diff --git a/Leetcode/Median_of_Two_Sorted_Arrays.py b/Ninja/Leetcode/Median_of_Two_Sorted_Arrays.py similarity index 100% rename from Leetcode/Median_of_Two_Sorted_Arrays.py rename to Ninja/Leetcode/Median_of_Two_Sorted_Arrays.py diff --git a/Leetcode/Merge_Intervals.py b/Ninja/Leetcode/Merge_Intervals.py similarity index 100% rename from Leetcode/Merge_Intervals.py rename to Ninja/Leetcode/Merge_Intervals.py diff --git a/Leetcode/Merge_Sorted_Array.py b/Ninja/Leetcode/Merge_Sorted_Array.py similarity index 100% rename from Leetcode/Merge_Sorted_Array.py rename to Ninja/Leetcode/Merge_Sorted_Array.py diff --git a/Leetcode/Merge_Two_Sorted_Lists.py b/Ninja/Leetcode/Merge_Two_Sorted_Lists.py similarity index 100% rename from Leetcode/Merge_Two_Sorted_Lists.py rename to Ninja/Leetcode/Merge_Two_Sorted_Lists.py diff --git a/Leetcode/Merge_k_Sorted_Lists.py b/Ninja/Leetcode/Merge_k_Sorted_Lists.py similarity index 100% rename from Leetcode/Merge_k_Sorted_Lists.py rename to Ninja/Leetcode/Merge_k_Sorted_Lists.py diff --git a/Leetcode/Minimum_Depth_of_Binary_Tree.py b/Ninja/Leetcode/Minimum_Depth_of_Binary_Tree.py similarity index 100% rename from Leetcode/Minimum_Depth_of_Binary_Tree.py rename to Ninja/Leetcode/Minimum_Depth_of_Binary_Tree.py diff --git a/Leetcode/Minimum_Path_Sum.py b/Ninja/Leetcode/Minimum_Path_Sum.py similarity index 100% rename from Leetcode/Minimum_Path_Sum.py rename to Ninja/Leetcode/Minimum_Path_Sum.py diff --git a/Leetcode/Minimum_Window_Substring.py b/Ninja/Leetcode/Minimum_Window_Substring.py similarity index 100% rename from Leetcode/Minimum_Window_Substring.py rename to Ninja/Leetcode/Minimum_Window_Substring.py diff --git a/Leetcode/Multiply_Strings.py b/Ninja/Leetcode/Multiply_Strings.py similarity index 100% rename from Leetcode/Multiply_Strings.py rename to Ninja/Leetcode/Multiply_Strings.py diff --git a/Leetcode/N-Queens.py b/Ninja/Leetcode/N-Queens.py similarity index 100% rename from Leetcode/N-Queens.py rename to Ninja/Leetcode/N-Queens.py diff --git a/Leetcode/N-Queens_II.py b/Ninja/Leetcode/N-Queens_II.py similarity index 100% rename from Leetcode/N-Queens_II.py rename to Ninja/Leetcode/N-Queens_II.py diff --git a/Leetcode/Next_Permutation.py b/Ninja/Leetcode/Next_Permutation.py similarity index 100% rename from Leetcode/Next_Permutation.py rename to Ninja/Leetcode/Next_Permutation.py diff --git a/Leetcode/Palindrome_Number.py b/Ninja/Leetcode/Palindrome_Number.py similarity index 100% rename from Leetcode/Palindrome_Number.py rename to Ninja/Leetcode/Palindrome_Number.py diff --git a/Leetcode/Palindrome_Partitioning.py b/Ninja/Leetcode/Palindrome_Partitioning.py similarity index 100% rename from Leetcode/Palindrome_Partitioning.py rename to Ninja/Leetcode/Palindrome_Partitioning.py diff --git a/Leetcode/Palindrome_Partitioning_II.py b/Ninja/Leetcode/Palindrome_Partitioning_II.py similarity index 100% rename from Leetcode/Palindrome_Partitioning_II.py rename to Ninja/Leetcode/Palindrome_Partitioning_II.py diff --git a/Leetcode/Partition_List.py b/Ninja/Leetcode/Partition_List.py similarity index 100% rename from Leetcode/Partition_List.py rename to Ninja/Leetcode/Partition_List.py diff --git a/Leetcode/Pascals_Triangle.py b/Ninja/Leetcode/Pascals_Triangle.py similarity index 100% rename from Leetcode/Pascals_Triangle.py rename to Ninja/Leetcode/Pascals_Triangle.py diff --git a/Leetcode/Pascals_Triangle_II.py b/Ninja/Leetcode/Pascals_Triangle_II.py similarity index 100% rename from Leetcode/Pascals_Triangle_II.py rename to Ninja/Leetcode/Pascals_Triangle_II.py diff --git a/Leetcode/Path_Sum.py b/Ninja/Leetcode/Path_Sum.py similarity index 100% rename from Leetcode/Path_Sum.py rename to Ninja/Leetcode/Path_Sum.py diff --git a/Leetcode/Path_Sum_II.py b/Ninja/Leetcode/Path_Sum_II.py similarity index 100% rename from Leetcode/Path_Sum_II.py rename to Ninja/Leetcode/Path_Sum_II.py diff --git a/Leetcode/Permutation_Sequence.py b/Ninja/Leetcode/Permutation_Sequence.py similarity index 100% rename from Leetcode/Permutation_Sequence.py rename to Ninja/Leetcode/Permutation_Sequence.py diff --git a/Leetcode/Permutations.py b/Ninja/Leetcode/Permutations.py similarity index 100% rename from Leetcode/Permutations.py rename to Ninja/Leetcode/Permutations.py diff --git a/Leetcode/Permutations_II.py b/Ninja/Leetcode/Permutations_II.py similarity index 100% rename from Leetcode/Permutations_II.py rename to Ninja/Leetcode/Permutations_II.py diff --git a/Leetcode/Plus_One.py b/Ninja/Leetcode/Plus_One.py similarity index 100% rename from Leetcode/Plus_One.py rename to Ninja/Leetcode/Plus_One.py diff --git a/Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py b/Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py similarity index 100% rename from Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py rename to Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py diff --git a/Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py b/Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py similarity index 100% rename from Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py rename to Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py diff --git a/Leetcode/Powx-n.py b/Ninja/Leetcode/Powx-n.py similarity index 100% rename from Leetcode/Powx-n.py rename to Ninja/Leetcode/Powx-n.py diff --git a/Leetcode/Recover_Binary_Search_Tree.py b/Ninja/Leetcode/Recover_Binary_Search_Tree.py similarity index 100% rename from Leetcode/Recover_Binary_Search_Tree.py rename to Ninja/Leetcode/Recover_Binary_Search_Tree.py diff --git a/Leetcode/Regular_Expression_Matching.py b/Ninja/Leetcode/Regular_Expression_Matching.py similarity index 100% rename from Leetcode/Regular_Expression_Matching.py rename to Ninja/Leetcode/Regular_Expression_Matching.py diff --git a/Leetcode/Remove_Duplicates_from_Sorted_Array.py b/Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array.py similarity index 100% rename from Leetcode/Remove_Duplicates_from_Sorted_Array.py rename to Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array.py diff --git a/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py b/Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py similarity index 100% rename from Leetcode/Remove_Duplicates_from_Sorted_Array_II.py rename to Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py diff --git a/Leetcode/Remove_Duplicates_from_Sorted_List.py b/Ninja/Leetcode/Remove_Duplicates_from_Sorted_List.py similarity index 100% rename from Leetcode/Remove_Duplicates_from_Sorted_List.py rename to Ninja/Leetcode/Remove_Duplicates_from_Sorted_List.py diff --git a/Leetcode/Remove_Duplicates_from_Sorted_List_II.py b/Ninja/Leetcode/Remove_Duplicates_from_Sorted_List_II.py similarity index 100% rename from Leetcode/Remove_Duplicates_from_Sorted_List_II.py rename to Ninja/Leetcode/Remove_Duplicates_from_Sorted_List_II.py diff --git a/Leetcode/Remove_Element.py b/Ninja/Leetcode/Remove_Element.py similarity index 100% rename from Leetcode/Remove_Element.py rename to Ninja/Leetcode/Remove_Element.py diff --git a/Leetcode/Remove_Nth_Node_From_End_of_List.py b/Ninja/Leetcode/Remove_Nth_Node_From_End_of_List.py similarity index 100% rename from Leetcode/Remove_Nth_Node_From_End_of_List.py rename to Ninja/Leetcode/Remove_Nth_Node_From_End_of_List.py diff --git a/Leetcode/Reorder_List.py b/Ninja/Leetcode/Reorder_List.py similarity index 100% rename from Leetcode/Reorder_List.py rename to Ninja/Leetcode/Reorder_List.py diff --git a/Leetcode/Restore_IP_Addresses.py b/Ninja/Leetcode/Restore_IP_Addresses.py similarity index 100% rename from Leetcode/Restore_IP_Addresses.py rename to Ninja/Leetcode/Restore_IP_Addresses.py diff --git a/Leetcode/Reverse_Integer.py b/Ninja/Leetcode/Reverse_Integer.py similarity index 100% rename from Leetcode/Reverse_Integer.py rename to Ninja/Leetcode/Reverse_Integer.py diff --git a/Leetcode/Reverse_Linked_List_II.py b/Ninja/Leetcode/Reverse_Linked_List_II.py similarity index 100% rename from Leetcode/Reverse_Linked_List_II.py rename to Ninja/Leetcode/Reverse_Linked_List_II.py diff --git a/Leetcode/Reverse_Nodes_in_k-Group.py b/Ninja/Leetcode/Reverse_Nodes_in_k-Group.py similarity index 100% rename from Leetcode/Reverse_Nodes_in_k-Group.py rename to Ninja/Leetcode/Reverse_Nodes_in_k-Group.py diff --git a/Leetcode/Reverse_Words_in_a_String.py b/Ninja/Leetcode/Reverse_Words_in_a_String.py similarity index 100% rename from Leetcode/Reverse_Words_in_a_String.py rename to Ninja/Leetcode/Reverse_Words_in_a_String.py diff --git a/Leetcode/Roman_to_Integer.py b/Ninja/Leetcode/Roman_to_Integer.py similarity index 100% rename from Leetcode/Roman_to_Integer.py rename to Ninja/Leetcode/Roman_to_Integer.py diff --git a/Leetcode/Rotate_Image.py b/Ninja/Leetcode/Rotate_Image.py similarity index 100% rename from Leetcode/Rotate_Image.py rename to Ninja/Leetcode/Rotate_Image.py diff --git a/Leetcode/Rotate_List.py b/Ninja/Leetcode/Rotate_List.py similarity index 100% rename from Leetcode/Rotate_List.py rename to Ninja/Leetcode/Rotate_List.py diff --git a/Leetcode/Same_Tree.py b/Ninja/Leetcode/Same_Tree.py similarity index 100% rename from Leetcode/Same_Tree.py rename to Ninja/Leetcode/Same_Tree.py diff --git a/Leetcode/Scramble_String.py b/Ninja/Leetcode/Scramble_String.py similarity index 100% rename from Leetcode/Scramble_String.py rename to Ninja/Leetcode/Scramble_String.py diff --git a/Leetcode/Search_Insert_Position.py b/Ninja/Leetcode/Search_Insert_Position.py similarity index 100% rename from Leetcode/Search_Insert_Position.py rename to Ninja/Leetcode/Search_Insert_Position.py diff --git a/Leetcode/Search_a_2D_Matrix.py b/Ninja/Leetcode/Search_a_2D_Matrix.py similarity index 100% rename from Leetcode/Search_a_2D_Matrix.py rename to Ninja/Leetcode/Search_a_2D_Matrix.py diff --git a/Leetcode/Search_for_a_Range.py b/Ninja/Leetcode/Search_for_a_Range.py similarity index 100% rename from Leetcode/Search_for_a_Range.py rename to Ninja/Leetcode/Search_for_a_Range.py diff --git a/Leetcode/Search_in_Rotated_Sorted_Array.py b/Ninja/Leetcode/Search_in_Rotated_Sorted_Array.py similarity index 100% rename from Leetcode/Search_in_Rotated_Sorted_Array.py rename to Ninja/Leetcode/Search_in_Rotated_Sorted_Array.py diff --git a/Leetcode/Search_in_Rotated_Sorted_Array_II.py b/Ninja/Leetcode/Search_in_Rotated_Sorted_Array_II.py similarity index 100% rename from Leetcode/Search_in_Rotated_Sorted_Array_II.py rename to Ninja/Leetcode/Search_in_Rotated_Sorted_Array_II.py diff --git a/Leetcode/Set_Matrix_Zeroes.py b/Ninja/Leetcode/Set_Matrix_Zeroes.py similarity index 100% rename from Leetcode/Set_Matrix_Zeroes.py rename to Ninja/Leetcode/Set_Matrix_Zeroes.py diff --git a/Leetcode/Simplify_Path.py b/Ninja/Leetcode/Simplify_Path.py similarity index 100% rename from Leetcode/Simplify_Path.py rename to Ninja/Leetcode/Simplify_Path.py diff --git a/Leetcode/Single_Number.py b/Ninja/Leetcode/Single_Number.py similarity index 100% rename from Leetcode/Single_Number.py rename to Ninja/Leetcode/Single_Number.py diff --git a/Leetcode/Single_Number_II.py b/Ninja/Leetcode/Single_Number_II.py similarity index 100% rename from Leetcode/Single_Number_II.py rename to Ninja/Leetcode/Single_Number_II.py diff --git a/Leetcode/Sort_Colors.py b/Ninja/Leetcode/Sort_Colors.py similarity index 100% rename from Leetcode/Sort_Colors.py rename to Ninja/Leetcode/Sort_Colors.py diff --git a/Leetcode/Sort_List.py b/Ninja/Leetcode/Sort_List.py similarity index 100% rename from Leetcode/Sort_List.py rename to Ninja/Leetcode/Sort_List.py diff --git a/Leetcode/Spiral_Matrix.py b/Ninja/Leetcode/Spiral_Matrix.py similarity index 100% rename from Leetcode/Spiral_Matrix.py rename to Ninja/Leetcode/Spiral_Matrix.py diff --git a/Leetcode/Spiral_Matrix_II.py b/Ninja/Leetcode/Spiral_Matrix_II.py similarity index 100% rename from Leetcode/Spiral_Matrix_II.py rename to Ninja/Leetcode/Spiral_Matrix_II.py diff --git a/Leetcode/Sqrtx.py b/Ninja/Leetcode/Sqrtx.py similarity index 100% rename from Leetcode/Sqrtx.py rename to Ninja/Leetcode/Sqrtx.py diff --git a/Leetcode/String_to_Integer_atoi.py b/Ninja/Leetcode/String_to_Integer_atoi.py similarity index 100% rename from Leetcode/String_to_Integer_atoi.py rename to Ninja/Leetcode/String_to_Integer_atoi.py diff --git a/Leetcode/Subsets.py b/Ninja/Leetcode/Subsets.py similarity index 100% rename from Leetcode/Subsets.py rename to Ninja/Leetcode/Subsets.py diff --git a/Leetcode/Subsets_II.py b/Ninja/Leetcode/Subsets_II.py similarity index 100% rename from Leetcode/Subsets_II.py rename to Ninja/Leetcode/Subsets_II.py diff --git a/Leetcode/Substring_with_Concatenation_of_All_Words.py b/Ninja/Leetcode/Substring_with_Concatenation_of_All_Words.py similarity index 100% rename from Leetcode/Substring_with_Concatenation_of_All_Words.py rename to Ninja/Leetcode/Substring_with_Concatenation_of_All_Words.py diff --git a/Leetcode/Sudoku_Solver.py b/Ninja/Leetcode/Sudoku_Solver.py similarity index 100% rename from Leetcode/Sudoku_Solver.py rename to Ninja/Leetcode/Sudoku_Solver.py diff --git a/Leetcode/Sum_Root_to_Leaf_Numbers.py b/Ninja/Leetcode/Sum_Root_to_Leaf_Numbers.py similarity index 100% rename from Leetcode/Sum_Root_to_Leaf_Numbers.py rename to Ninja/Leetcode/Sum_Root_to_Leaf_Numbers.py diff --git a/Leetcode/Surrounded_Regions.py b/Ninja/Leetcode/Surrounded_Regions.py similarity index 100% rename from Leetcode/Surrounded_Regions.py rename to Ninja/Leetcode/Surrounded_Regions.py diff --git a/Leetcode/Swap_Nodes_in_Pairs.py b/Ninja/Leetcode/Swap_Nodes_in_Pairs.py similarity index 100% rename from Leetcode/Swap_Nodes_in_Pairs.py rename to Ninja/Leetcode/Swap_Nodes_in_Pairs.py diff --git a/Leetcode/Symmetric_Tree.py b/Ninja/Leetcode/Symmetric_Tree.py similarity index 100% rename from Leetcode/Symmetric_Tree.py rename to Ninja/Leetcode/Symmetric_Tree.py diff --git a/Leetcode/Text_Justification.py b/Ninja/Leetcode/Text_Justification.py similarity index 100% rename from Leetcode/Text_Justification.py rename to Ninja/Leetcode/Text_Justification.py diff --git a/Leetcode/Trapping_Rain_Water.py b/Ninja/Leetcode/Trapping_Rain_Water.py similarity index 100% rename from Leetcode/Trapping_Rain_Water.py rename to Ninja/Leetcode/Trapping_Rain_Water.py diff --git a/Leetcode/Triangle.py b/Ninja/Leetcode/Triangle.py similarity index 100% rename from Leetcode/Triangle.py rename to Ninja/Leetcode/Triangle.py diff --git a/Leetcode/Two_Sum.py b/Ninja/Leetcode/Two_Sum.py similarity index 100% rename from Leetcode/Two_Sum.py rename to Ninja/Leetcode/Two_Sum.py diff --git a/Leetcode/Unique_Binary_Search_Trees.py b/Ninja/Leetcode/Unique_Binary_Search_Trees.py similarity index 100% rename from Leetcode/Unique_Binary_Search_Trees.py rename to Ninja/Leetcode/Unique_Binary_Search_Trees.py diff --git a/Leetcode/Unique_Binary_Search_Trees_II.py b/Ninja/Leetcode/Unique_Binary_Search_Trees_II.py similarity index 100% rename from Leetcode/Unique_Binary_Search_Trees_II.py rename to Ninja/Leetcode/Unique_Binary_Search_Trees_II.py diff --git a/Leetcode/Unique_Paths.py b/Ninja/Leetcode/Unique_Paths.py similarity index 100% rename from Leetcode/Unique_Paths.py rename to Ninja/Leetcode/Unique_Paths.py diff --git a/Leetcode/Unique_Paths_II.py b/Ninja/Leetcode/Unique_Paths_II.py similarity index 100% rename from Leetcode/Unique_Paths_II.py rename to Ninja/Leetcode/Unique_Paths_II.py diff --git a/Leetcode/Valid_Number.py b/Ninja/Leetcode/Valid_Number.py similarity index 100% rename from Leetcode/Valid_Number.py rename to Ninja/Leetcode/Valid_Number.py diff --git a/Leetcode/Valid_Palindrome.py b/Ninja/Leetcode/Valid_Palindrome.py similarity index 100% rename from Leetcode/Valid_Palindrome.py rename to Ninja/Leetcode/Valid_Palindrome.py diff --git a/Leetcode/Valid_Parentheses.py b/Ninja/Leetcode/Valid_Parentheses.py similarity index 100% rename from Leetcode/Valid_Parentheses.py rename to Ninja/Leetcode/Valid_Parentheses.py diff --git a/Leetcode/Valid_Sudoku.py b/Ninja/Leetcode/Valid_Sudoku.py similarity index 100% rename from Leetcode/Valid_Sudoku.py rename to Ninja/Leetcode/Valid_Sudoku.py diff --git a/Leetcode/Validate_Binary_Search_Tree.py b/Ninja/Leetcode/Validate_Binary_Search_Tree.py similarity index 100% rename from Leetcode/Validate_Binary_Search_Tree.py rename to Ninja/Leetcode/Validate_Binary_Search_Tree.py diff --git a/Leetcode/Wildcard_Matching.py b/Ninja/Leetcode/Wildcard_Matching.py similarity index 100% rename from Leetcode/Wildcard_Matching.py rename to Ninja/Leetcode/Wildcard_Matching.py diff --git a/Leetcode/Word_Break.py b/Ninja/Leetcode/Word_Break.py similarity index 100% rename from Leetcode/Word_Break.py rename to Ninja/Leetcode/Word_Break.py diff --git a/Leetcode/Word_Break_II.py b/Ninja/Leetcode/Word_Break_II.py similarity index 100% rename from Leetcode/Word_Break_II.py rename to Ninja/Leetcode/Word_Break_II.py diff --git a/Leetcode/Word_Ladder.py b/Ninja/Leetcode/Word_Ladder.py similarity index 100% rename from Leetcode/Word_Ladder.py rename to Ninja/Leetcode/Word_Ladder.py diff --git a/Leetcode/Word_Ladder_II.py b/Ninja/Leetcode/Word_Ladder_II.py similarity index 100% rename from Leetcode/Word_Ladder_II.py rename to Ninja/Leetcode/Word_Ladder_II.py diff --git a/Leetcode/Word_Search.py b/Ninja/Leetcode/Word_Search.py similarity index 100% rename from Leetcode/Word_Search.py rename to Ninja/Leetcode/Word_Search.py diff --git a/Leetcode/ZigZag_Conversion.py b/Ninja/Leetcode/ZigZag_Conversion.py similarity index 100% rename from Leetcode/ZigZag_Conversion.py rename to Ninja/Leetcode/ZigZag_Conversion.py diff --git a/Leetcode/__init__.py b/Ninja/Leetcode/__init__.py similarity index 100% rename from Leetcode/__init__.py rename to Ninja/Leetcode/__init__.py diff --git a/WhiteBook/array_str.py b/Ninja/WhiteBook/array_str.py similarity index 100% rename from WhiteBook/array_str.py rename to Ninja/WhiteBook/array_str.py diff --git a/WhiteBook/bst.py b/Ninja/WhiteBook/bst.py similarity index 100% rename from WhiteBook/bst.py rename to Ninja/WhiteBook/bst.py diff --git a/WhiteBook/bt.py b/Ninja/WhiteBook/bt.py similarity index 100% rename from WhiteBook/bt.py rename to Ninja/WhiteBook/bt.py diff --git a/WhiteBook/node.py b/Ninja/WhiteBook/node.py similarity index 100% rename from WhiteBook/node.py rename to Ninja/WhiteBook/node.py diff --git a/WhiteBook/search_n_sort.py b/Ninja/WhiteBook/search_n_sort.py similarity index 100% rename from WhiteBook/search_n_sort.py rename to Ninja/WhiteBook/search_n_sort.py diff --git a/WhiteBook/stack_q.py b/Ninja/WhiteBook/stack_q.py similarity index 100% rename from WhiteBook/stack_q.py rename to Ninja/WhiteBook/stack_q.py diff --git a/WhiteBook/tree_node.py b/Ninja/WhiteBook/tree_node.py similarity index 100% rename from WhiteBook/tree_node.py rename to Ninja/WhiteBook/tree_node.py diff --git a/coding_index.md b/Ninja/coding_index.md similarity index 100% rename from coding_index.md rename to Ninja/coding_index.md diff --git a/frequency.md b/Ninja/frequency.md similarity index 100% rename from frequency.md rename to Ninja/frequency.md diff --git a/leetcode.py b/Ninja/leetcode.py similarity index 100% rename from leetcode.py rename to Ninja/leetcode.py diff --git a/Ninja/playground.py b/Ninja/playground.py new file mode 100644 index 0000000..104a58b --- /dev/null +++ b/Ninja/playground.py @@ -0,0 +1,67 @@ +class TreeNode: + def __init__(self, data=None): + self.left = None + self.right = None + self.data = data + +class LinkedListNode: + def __init__(self, data=None): + self.data = data + self.next = None + + +def binary_search(root_node, target): + while(root_node.left or root_node.right): + if root_node.data == target: + return True + elif root_node.data < target: + root_node = root_node.right + else: + root_node = root_node.left + return False + +def binary_search(search_list, target): + left_index = 0 + right_index = len(list) - 1 + while left_index < right_index: + mid = (left_index + right_index) / 2 + if target == search_list[mid]: + return True + elif target < search_list[mid]: + right_index = mid - 1 + else: + left_index = mid + 1 + + return False + +def bfs(tree_node, target): + q = [] + q.append(tree_node) + while q: + current = q.popleft() + if not current: + continue + if current.data == target: + return True + q.append(current.left) + q.append(current.right) + return False + +def permute(self, n): + self.result = [] + self.permute_helper([], n) + return self.result + +def permute_helper(self, current_result, n): + if len(current_result) == n: + self.result.append(current_result) + return + + cannot_permute_R = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'R' + cannot_permute_B = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'B' + + if not cannot_permute_R: + self.permute_helper(current_result + ['R'], n) + + if not cannot_permute_B: + self.permute_helper(current_result + ['B'], n) diff --git a/zz_coding_index.md b/Ninja/zz_coding_index.md similarity index 100% rename from zz_coding_index.md rename to Ninja/zz_coding_index.md diff --git a/knowledge.md b/Pirate/knowledge.md similarity index 100% rename from knowledge.md rename to Pirate/knowledge.md diff --git a/system_design.md b/Pirate/system_design.md similarity index 100% rename from system_design.md rename to Pirate/system_design.md diff --git a/run.py b/run.py deleted file mode 100755 index 2452a6d..0000000 --- a/run.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python - -file_name = 'Maximal_Rectangle' -func_name = 'maximalRectangle' - -import importlib -module = importlib.import_module('Leetcode.%s' % file_name) -instance = module.Solution() - -print getattr(instance, func_name)(["1"]) From 08f92bf422d584c1870bea18312d84c9f1d812bb Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 14 Jul 2019 19:44:11 -0700 Subject: [PATCH 13/50] Added Push vs Pull --- Pirate/push_vs_pull.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Pirate/push_vs_pull.md diff --git a/Pirate/push_vs_pull.md b/Pirate/push_vs_pull.md new file mode 100644 index 0000000..3549f9b --- /dev/null +++ b/Pirate/push_vs_pull.md @@ -0,0 +1,40 @@ +# Push VS Pull Design in News Feed + +## Problem +Push和Pull是两种不同的system design approach,主要应用于feed design或者类似的应用场景例如Live comment. + +## Main Differences + +### Data Structure Differences +一般来讲, 实现Push和Pull时需要的data structure是不一样的. 以feed design为例, 最naive的feed design是至少需要一个timeline table的, 就是用户所有的post按照chronological order的一个 list. +在Pull model中, 只需实现一个 +``` +def getUserFeed(user_id: int, start_at: Optional[int] = None, ..., last_feed_item_id: Optional[int] = None): + following_list = getFollowingList(user_id) + feed = [] + for following in following_list: + recent_posts = getRecentPost(following.user_id) + if start_at or last_feed_item_id: + for post in recent_posts: + if post.timestamp >= start_at and post.id < last_feed_item_id: + feed.add(post) + + return feed +``` +具体这个function中的getRecentPost其实只需要做一个`select * from timeline_table where user_id = user_id`. 于是我们只需要一个`timeline_table`就可以实现pull model了. + +对比push model, 需要除了maintain一个`timeline_table`, 还需要maintain一个`news_feed_table` keyed by `feed_owner`, 也就是这个newsfeed reader. + +### Process Differences +* Pull approach + * Distribute actions by writer + * Write one location(对应`timeline_table`), read gathers(对应每个人的`timeline_table`) +* Push approach + * Distribute actions by reader + * Write broadcasts(对应每个人的`news_feed_table`), read one location(对应某个人的`news_feed_table`) + +ML ranking应该是发生在 read path. + +### Reference +* 九章黄药师 - https://www.jiuzhang.com/qa/2074/ +* Facebook architecture slides - http://itsumomono.blogspot.com/2015/07/news-feed-approaches-push-vs-pull.html From f7c10c41eec58287aa2669d3e16326a52fc91bab Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 14 Jul 2019 19:46:29 -0700 Subject: [PATCH 14/50] Update push_vs_pull.md Add language detection --- Pirate/push_vs_pull.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pirate/push_vs_pull.md b/Pirate/push_vs_pull.md index 3549f9b..e3f9e23 100644 --- a/Pirate/push_vs_pull.md +++ b/Pirate/push_vs_pull.md @@ -8,7 +8,7 @@ Push和Pull是两种不同的system design approach,主要应用于feed design ### Data Structure Differences 一般来讲, 实现Push和Pull时需要的data structure是不一样的. 以feed design为例, 最naive的feed design是至少需要一个timeline table的, 就是用户所有的post按照chronological order的一个 list. 在Pull model中, 只需实现一个 -``` +```python def getUserFeed(user_id: int, start_at: Optional[int] = None, ..., last_feed_item_id: Optional[int] = None): following_list = getFollowingList(user_id) feed = [] From b6cbb3083daaee0fe1fdeb1b3574cb0efc51ba7c Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 6 Oct 2019 22:52:41 -0700 Subject: [PATCH 15/50] Update zz_coding_index.md --- Ninja/zz_coding_index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ninja/zz_coding_index.md b/Ninja/zz_coding_index.md index 678ccf7..999528f 100644 --- a/Ninja/zz_coding_index.md +++ b/Ninja/zz_coding_index.md @@ -33,18 +33,18 @@ * Partition List ## Permutation and Combination -###### Permutation +### Permutation * 输入没有重复:Permutations, CC150 9.5, PIE Chapter7 Permutations of a String * 输入有重复,输出不能有重复:Permutations II * Next Permutation: 经典算法,背吧 * Permutation Sequence: 非常有意思的题目 * Combination -###### 纯粹的subset +### 纯粹的subset * 输入没有重复:Subsets, CC150 9.4, PIE Chapter7 Combinations of a String * 输入有重复,输出不能有重复:Subsets II -###### 需要满足一定要求的组合 +### 需要满足一定要求的组合 * 一个元素只能取一次(输入没有重复): Combinations * 一个元素可以取多次(输入没有重复): Combination Sum, CC150, 9.8 * 一个元素只能取一次(输入有重复,输出不能有重复): Combination Sum II @@ -94,7 +94,7 @@ Questions 第五,今天做了一遍LinkedList的题目,发现两个地方容易出bug。一是two pointers loop完之后常常会有一个收尾的工作,比如Add Two Numbers需要处理carrier>0的情况。二是在swap了nodes之后,新的tail需要把next置空,不然就出现死循环了。 -##Tree +## Tree 1. Recursive DFS 2. Iterative DFS 3. BFS From 8de31989d12a4d38008dcd2f4b622a240bdc07a4 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 7 Oct 2019 01:06:57 -0700 Subject: [PATCH 16/50] Update solutions.md --- solutions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions.md b/solutions.md index 10361b6..1dad6df 100644 --- a/solutions.md +++ b/solutions.md @@ -1,4 +1,4 @@ -##[1. 3Sum](https://oj.leetcode.com/problems/3sum/) +## [1. 3Sum](https://oj.leetcode.com/problems/3sum/) Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. From 889ec29d50d581df052969a39e324893d73a2c03 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 7 Oct 2019 01:07:15 -0700 Subject: [PATCH 17/50] Update solutions.md --- solutions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions.md b/solutions.md index 1dad6df..0cb6d27 100644 --- a/solutions.md +++ b/solutions.md @@ -1,4 +1,4 @@ -## [1. 3Sum](https://oj.leetcode.com/problems/3sum/) +### [1. 3Sum](https://oj.leetcode.com/problems/3sum/) Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. From 6d83032eb064ebd824f7b19db4f1c6dc0237491d Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 7 Oct 2019 01:30:43 -0700 Subject: [PATCH 18/50] Update the tool and rerun tool.py script to get a new cheatsheet --- solutions.md | 366 +++++++++++++++++++++++++-------------------------- tool.py | 16 +-- 2 files changed, 191 insertions(+), 191 deletions(-) diff --git a/solutions.md b/solutions.md index 0cb6d27..d17c0ec 100644 --- a/solutions.md +++ b/solutions.md @@ -1,4 +1,4 @@ -### [1. 3Sum](https://oj.leetcode.com/problems/3sum/) +## [1. 3Sum](https://oj.leetcode.com/problems/3sum/) Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. @@ -45,7 +45,7 @@ class Solution: ``` ----- -##[2. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) +## [2. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. @@ -82,7 +82,7 @@ class Solution: ``` ----- -##[3. 4Sum](https://oj.leetcode.com/problems/4sum/) +## [3. 4Sum](https://oj.leetcode.com/problems/4sum/) Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. @@ -158,7 +158,7 @@ class Solution: ``` ----- -##[4. Add Binary](https://oj.leetcode.com/problems/add-binary/) +## [4. Add Binary](https://oj.leetcode.com/problems/add-binary/) Given two binary strings, return their sum (also a binary string). @@ -196,7 +196,7 @@ class Solution: ``` ----- -##[5. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) +## [5. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. @@ -232,7 +232,7 @@ class Solution: ``` ----- -##[6. Anagrams](https://oj.leetcode.com/problems/anagrams/) +## [6. Anagrams](https://oj.leetcode.com/problems/anagrams/) Given an array of strings, return all groups of strings that are anagrams. @@ -264,7 +264,7 @@ class Solution: ``` ----- -##[7. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) +## [7. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) Given a binary tree, determine if it is height-balanced. @@ -321,7 +321,7 @@ class Solution: ``` ----- -##[8. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) +## [8. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -344,7 +344,7 @@ class Solution: ``` ----- -##[9. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) +## [9. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -366,7 +366,7 @@ class Solution: ``` ----- -##[10. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) +## [10. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -407,7 +407,7 @@ class Solution: ``` ----- -##[11. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) +## [11. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) Given a binary tree, return the inorder traversal of its nodes' values. @@ -467,7 +467,7 @@ class Solution: ``` ----- -##[12. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) +## [12. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). @@ -523,7 +523,7 @@ class Solution: ``` ----- -##[13. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) +## [13. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). @@ -580,7 +580,7 @@ class Solution: ``` ----- -##[14. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) +## [14. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) Given a binary tree, find the maximum path sum. @@ -629,7 +629,7 @@ class Solution: ``` ----- -##[15. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) +## [15. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) Given a binary tree, return the postorder traversal of its nodes' values. @@ -709,7 +709,7 @@ class Solution: ``` ----- -##[16. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) +## [16. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) Given a binary tree, return the preorder traversal of its nodes' values. @@ -769,7 +769,7 @@ class Solution: ``` ----- -##[17. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) +## [17. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). @@ -830,7 +830,7 @@ class Solution: ``` ----- -##[18. Candy](https://oj.leetcode.com/problems/candy/) +## [18. Candy](https://oj.leetcode.com/problems/candy/) There are N children standing in a line. Each child is assigned a rating value. @@ -861,7 +861,7 @@ class Solution: ``` ----- -##[19. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) +## [19. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) You are climbing a stair case. It takes n steps to reach to the top. @@ -912,7 +912,7 @@ class Solution: ``` ----- -##[20. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) +## [20. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. @@ -975,7 +975,7 @@ class Solution: ``` ----- -##[21. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) +## [21. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. @@ -1016,7 +1016,7 @@ class Solution: ``` ----- -##[22. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) +## [22. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. @@ -1061,7 +1061,7 @@ class Solution: ``` ----- -##[23. Combinations](https://oj.leetcode.com/problems/combinations/) +## [23. Combinations](https://oj.leetcode.com/problems/combinations/) Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. @@ -1098,7 +1098,7 @@ class Solution: ``` ----- -##[24. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) +## [24. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) Given inorder and postorder traversal of a tree, construct the binary tree. @@ -1131,7 +1131,7 @@ class Solution: ``` ----- -##[25. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) +## [25. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) Given preorder and inorder traversal of a tree, construct the binary tree. @@ -1164,7 +1164,7 @@ class Solution: ``` ----- -##[26. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) +## [26. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. @@ -1190,7 +1190,7 @@ class Solution: ``` ----- -##[27. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) +## [27. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) Given an array where elements are sorted in ascending order, convert it to a height balanced BST. @@ -1222,7 +1222,7 @@ class Solution: ``` ----- -##[28. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) +## [28. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. @@ -1272,7 +1272,7 @@ class Solution: ``` ----- -##[29. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) +## [29. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. @@ -1317,7 +1317,7 @@ class Solution: ``` ----- -##[30. Count and Say](https://oj.leetcode.com/problems/count-and-say/) +## [30. Count and Say](https://oj.leetcode.com/problems/count-and-say/) The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... @@ -1351,7 +1351,7 @@ class Solution: ``` ----- -##[31. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) +## [31. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) A message containing letters from A-Z is being encoded to numbers using the following mapping: @@ -1418,7 +1418,7 @@ class Solution: ``` ----- -##[32. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) +## [32. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) Given a string S and a string T, count the number of distinct subsequences of T in S. @@ -1474,7 +1474,7 @@ class Solution: ``` ----- -##[33. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) +## [33. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) Divide two integers without using multiplication, division and mod operator. @@ -1507,7 +1507,7 @@ class Solution: ``` ----- -##[34. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) +## [34. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) @@ -1560,7 +1560,7 @@ class Solution: ``` ----- -##[35. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) +## [35. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) Evaluate the value of an arithmetic expression in Reverse Polish Notation. @@ -1599,7 +1599,7 @@ class Solution: ``` ----- -##[36. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) +## [36. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) Given an unsorted integer array, find the first missing positive integer. @@ -1641,7 +1641,7 @@ class Solution: ``` ----- -##[37. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) +## [37. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) Given a binary tree, flatten it to a linked list in-place. @@ -1747,7 +1747,7 @@ class Solution: ``` ----- -##[38. Gas Station](https://oj.leetcode.com/problems/gas-station/) +## [38. Gas Station](https://oj.leetcode.com/problems/gas-station/) There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. @@ -1784,7 +1784,7 @@ class Solution: ``` ----- -##[39. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) +## [39. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. @@ -1813,7 +1813,7 @@ class Solution: ``` ----- -##[40. Gray Code](https://oj.leetcode.com/problems/gray-code/) +## [40. Gray Code](https://oj.leetcode.com/problems/gray-code/) The gray code is a binary numeral system where two successive values differ in only one bit. @@ -1894,7 +1894,7 @@ class Solution: ``` ----- -##[41. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) +## [41. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) Implement strStr(). @@ -1934,7 +1934,7 @@ class Solution: ``` ----- -##[42. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) +## [42. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). @@ -1986,7 +1986,7 @@ class Solution: ``` ----- -##[43. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) +## [43. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) Sort a linked list using insertion sort. @@ -2025,7 +2025,7 @@ class Solution: ``` ----- -##[44. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) +## [44. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) Given an integer, convert it to a roman numeral. @@ -2050,7 +2050,7 @@ class Solution: ``` ----- -##[45. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) +## [45. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. @@ -2114,7 +2114,7 @@ class Solution: ``` ----- -##[46. Jump Game](https://oj.leetcode.com/problems/jump-game/) +## [46. Jump Game](https://oj.leetcode.com/problems/jump-game/) Given an array of non-negative integers, you are initially positioned at the first index of the array. @@ -2181,7 +2181,7 @@ class Solution: ``` ----- -##[47. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) +## [47. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) Given an array of non-negative integers, you are initially positioned at the first index of the array. @@ -2231,7 +2231,7 @@ class Solution: ``` ----- -##[48. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) +## [48. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. @@ -2303,7 +2303,7 @@ class LRUCache: ``` ----- -##[49. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) +## [49. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. @@ -2343,7 +2343,7 @@ class Solution: ``` ----- -##[50. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) +## [50. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. @@ -2391,7 +2391,7 @@ class Solution: ``` ----- -##[51. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) +## [51. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) Given a digit string, return all possible letter combinations that the number could represent. @@ -2445,7 +2445,7 @@ class Solution: ``` ----- -##[52. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) +## [52. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) Given a linked list, determine if it has a cycle in it. @@ -2475,7 +2475,7 @@ class Solution: ``` ----- -##[53. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) +## [53. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) Given a linked list, return the node where the cycle begins. If there is no cycle, return null. @@ -2513,7 +2513,7 @@ class Solution: ``` ----- -##[54. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) +## [54. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) Write a function to find the longest common prefix string amongst an array of strings. @@ -2534,7 +2534,7 @@ class Solution: ``` ----- -##[55. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) +## [55. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) Given an unsorted array of integers, find the length of the longest consecutive elements sequence. @@ -2576,7 +2576,7 @@ class Solution: ``` ----- -##[56. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) +## [56. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. @@ -2636,7 +2636,7 @@ class Solution: ``` ----- -##[57. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) +## [57. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1. @@ -2682,7 +2682,7 @@ class Solution: ``` ----- -##[58. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) +## [58. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. @@ -2718,7 +2718,7 @@ class Solution: ``` ----- -##[59. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) +## [59. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. @@ -2765,7 +2765,7 @@ class Solution: ``` ----- -##[60. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) +## [60. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. @@ -2809,7 +2809,7 @@ class Solution: ``` ----- -##[61. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) +## [61. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) Given a binary tree, find its maximum depth. @@ -2835,7 +2835,7 @@ class Solution: ``` ----- -##[62. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) +## [62. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) Find the contiguous subarray within an array (containing at least one number) which has the largest product. @@ -2871,7 +2871,7 @@ class Solution: ``` ----- -##[63. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) +## [63. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) Find the contiguous subarray within an array (containing at least one number) which has the largest sum. @@ -2917,7 +2917,7 @@ class Solution: ``` ----- -##[64. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) +## [64. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). @@ -2963,7 +2963,7 @@ class Solution: ``` ----- -##[65. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) +## [65. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) Given a collection of intervals, merge all overlapping intervals. @@ -3000,7 +3000,7 @@ class Solution: ``` ----- -##[66. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) +## [66. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) Given two sorted integer arrays A and B, merge B into A as one sorted array. @@ -3035,7 +3035,7 @@ class Solution: ``` ----- -##[67. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) +## [67. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. @@ -3070,7 +3070,7 @@ class Solution: ``` ----- -##[68. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) +## [68. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. @@ -3104,7 +3104,7 @@ class Solution: ``` ----- -##[69. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) +## [69. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) Given a binary tree, find its minimum depth. @@ -3136,7 +3136,7 @@ class Solution: ``` ----- -##[70. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) +## [70. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. @@ -3219,7 +3219,7 @@ All Previous work. No need to worry ``` ----- -##[71. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) +## [71. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). @@ -3280,7 +3280,7 @@ class Solution: ``` ----- -##[72. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) +## [72. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) Given two numbers represented as strings, return multiplication of the numbers as a string. @@ -3303,7 +3303,7 @@ class Solution: ``` ----- -##[73. N-Queens](https://oj.leetcode.com/problems/n-queens/) +## [73. N-Queens](https://oj.leetcode.com/problems/n-queens/) The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. @@ -3360,7 +3360,7 @@ class Solution: ``` ----- -##[74. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) +## [74. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) Follow up for N-Queens problem. @@ -3399,7 +3399,7 @@ class Solution: ``` ----- -##[75. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) +## [75. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. @@ -3445,7 +3445,7 @@ class Solution: ``` ----- -##[76. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) +## [76. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) Determine whether an integer is a palindrome. Do this without extra space. @@ -3480,7 +3480,7 @@ class Solution: ``` ----- -##[77. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) +## [77. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) Given a string s, partition s such that every substring of the partition is a palindrome. @@ -3529,7 +3529,7 @@ class Solution: ``` ----- -##[78. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) +## [78. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) Given a string s, partition s such that every substring of the partition is a palindrome. @@ -3593,7 +3593,7 @@ class Solution: ``` ----- -##[79. Partition List](https://oj.leetcode.com/problems/partition-list/) +## [79. Partition List](https://oj.leetcode.com/problems/partition-list/) Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. @@ -3640,7 +3640,7 @@ class Solution: ``` ----- -##[80. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) +## [80. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) Given numRows, generate the first numRows of Pascal's triangle. @@ -3693,7 +3693,7 @@ class Solution: ``` ----- -##[81. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) +## [81. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) Given an index k, return the kth row of the Pascal's triangle. @@ -3731,7 +3731,7 @@ class Solution: ``` ----- -##[82. Path Sum](https://oj.leetcode.com/problems/path-sum/) +## [82. Path Sum](https://oj.leetcode.com/problems/path-sum/) Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. @@ -3773,7 +3773,7 @@ class Solution: ``` ----- -##[83. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) +## [83. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. @@ -3852,7 +3852,7 @@ This way will have long run time ``` ----- -##[84. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) +## [84. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) The set [1,2,3,…,n] contains a total of n! unique permutations. @@ -3894,7 +3894,7 @@ class Solution: ``` ----- -##[85. Permutations](https://oj.leetcode.com/problems/permutations/) +## [85. Permutations](https://oj.leetcode.com/problems/permutations/) Given a collection of numbers, return all possible permutations. @@ -3938,7 +3938,7 @@ class Solution: ``` ----- -##[86. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) +## [86. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) Given a collection of numbers that might contain duplicates, return all possible unique permutations. @@ -3990,7 +3990,7 @@ class Solution: ``` ----- -##[87. Plus One](https://oj.leetcode.com/problems/plus-one/) +## [87. Plus One](https://oj.leetcode.com/problems/plus-one/) Given a non-negative number represented as an array of digits, plus one to the number. @@ -4015,7 +4015,7 @@ class Solution: ``` ----- -##[88. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) +## [88. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) Given a binary tree @@ -4075,7 +4075,7 @@ class Solution: ``` ----- -##[89. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) +## [89. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) Follow up for problem "Populating Next Right Pointers in Each Node". @@ -4144,7 +4144,7 @@ class Solution: ``` ----- -##[90. Powx-n](https://oj.leetcode.com/problems/powx-n/) +## [90. Powx-n](https://oj.leetcode.com/problems/powx-n/) Implement pow(x, n). @@ -4179,7 +4179,7 @@ class Solution: ``` ----- -##[91. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) +## [91. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) Two elements of a binary search tree (BST) are swapped by mistake. @@ -4231,7 +4231,7 @@ class Solution: ``` ----- -##[92. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) +## [92. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) Implement regular expression matching with support for '.' and '*'. @@ -4282,7 +4282,7 @@ class Solution: ``` ----- -##[93. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) +## [93. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. @@ -4322,7 +4322,7 @@ class Solution: ``` ----- -##[94. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) +## [94. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? @@ -4351,7 +4351,7 @@ class Solution: ``` ----- -##[95. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) +## [95. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) Given a sorted linked list, delete all duplicates such that each element appear only once. @@ -4383,7 +4383,7 @@ class Solution: ``` ----- -##[96. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) +## [96. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. @@ -4424,7 +4424,7 @@ class Solution: ``` ----- -##[97. Remove Element](https://oj.leetcode.com/problems/remove-element/) +## [97. Remove Element](https://oj.leetcode.com/problems/remove-element/) Given an array and a value, remove all instances of that value in place and return the new length. @@ -4448,7 +4448,7 @@ class Solution: ``` ----- -##[98. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) +## [98. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) Given a linked list, remove the nth node from the end of list and return its head. @@ -4487,7 +4487,7 @@ class Solution: ``` ----- -##[99. Reorder List](https://oj.leetcode.com/problems/reorder-list/) +## [99. Reorder List](https://oj.leetcode.com/problems/reorder-list/) Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… @@ -4557,7 +4557,7 @@ class Solution: ``` ----- -##[100. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) +## [100. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) Given a string containing only digits, restore it by returning all possible valid IP address combinations. @@ -4594,7 +4594,7 @@ class Solution: ``` ----- -##[101. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) +## [101. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) Reverse digits of an integer. @@ -4627,7 +4627,7 @@ class Solution: ``` ----- -##[102. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) +## [102. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) Reverse a linked list from position m to n. Do it in-place and in one-pass. @@ -4673,7 +4673,7 @@ class Solution: ``` ----- -##[103. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) +## [103. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. @@ -4731,7 +4731,7 @@ class Solution: ``` ----- -##[104. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) +## [104. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) Given an input string, reverse the string word by word. @@ -4778,7 +4778,7 @@ class Solution: ``` ----- -##[105. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) +## [105. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) Given a roman numeral, convert it to an integer. @@ -4809,7 +4809,7 @@ class Solution: ``` ----- -##[106. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) +## [106. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) You are given an n x n 2D matrix representing an image. @@ -4850,7 +4850,7 @@ class Solution: ``` ----- -##[107. Rotate List](https://oj.leetcode.com/problems/rotate-list/) +## [107. Rotate List](https://oj.leetcode.com/problems/rotate-list/) Given a list, rotate the list to the right by k places, where k is non-negative. @@ -4893,7 +4893,7 @@ class Solution: ``` ----- -##[108. Same Tree](https://oj.leetcode.com/problems/same-tree/) +## [108. Same Tree](https://oj.leetcode.com/problems/same-tree/) Given two binary trees, write a function to check if they are equal or not. @@ -4924,7 +4924,7 @@ class Solution: ``` ----- -##[109. Scramble String](https://oj.leetcode.com/problems/scramble-string/) +## [109. Scramble String](https://oj.leetcode.com/problems/scramble-string/) Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. @@ -4989,7 +4989,7 @@ class Solution: ``` ----- -##[110. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) +## [110. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. @@ -5029,7 +5029,7 @@ class Solution: ``` ----- -##[111. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) +## [111. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: @@ -5122,7 +5122,7 @@ Note: ``` ----- -##[112. Search for a Range](https://oj.leetcode.com/problems/search-for-a-range/) +## [112. Search for a Range](https://oj.leetcode.com/problems/search-for-a-range/) Given a sorted array of integers, find the starting and ending position of a given target value. @@ -5183,7 +5183,7 @@ class Solution: ``` ----- -##[113. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) +## [113. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) Suppose a sorted array is rotated at some pivot unknown to you beforehand. @@ -5249,7 +5249,7 @@ class Solution: ``` ----- -##[114. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) +## [114. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? @@ -5287,7 +5287,7 @@ class Solution: ``` ----- -##[115. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) +## [115. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. @@ -5335,7 +5335,7 @@ class Solution: ``` ----- -##[116. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) +## [116. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) Given an absolute path for a file (Unix-style), simplify it. @@ -5377,7 +5377,7 @@ class Solution: ``` ----- -##[117. Single Number](https://oj.leetcode.com/problems/single-number/) +## [117. Single Number](https://oj.leetcode.com/problems/single-number/) Given an array of integers, every element appears twice except for one. Find that single one. @@ -5396,7 +5396,7 @@ class Solution: ``` ----- -##[118. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) +## [118. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) Given an array of integers, every element appears three times except for one. Find that single one. @@ -5453,7 +5453,7 @@ class Solution: ``` ----- -##[119. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) +## [119. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. @@ -5492,7 +5492,7 @@ class Solution: ``` ----- -##[120. Sort List](https://oj.leetcode.com/problems/sort-list/) +## [120. Sort List](https://oj.leetcode.com/problems/sort-list/) Sort a linked list in O(n log n) time using constant space complexity. @@ -5551,7 +5551,7 @@ class Solution: ``` ----- -##[121. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) +## [121. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. @@ -5608,7 +5608,7 @@ class Solution: ``` ----- -##[122. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) +## [122. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. @@ -5666,7 +5666,7 @@ class Solution: ``` ----- -##[123. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) +## [123. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) Implement int sqrt(int x). @@ -5715,7 +5715,7 @@ class Solution: ``` ----- -##[124. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) +## [124. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) Implement atoi to convert a string to an integer. @@ -5764,7 +5764,7 @@ class Solution: ``` ----- -##[125. Subsets](https://oj.leetcode.com/problems/subsets/) +## [125. Subsets](https://oj.leetcode.com/problems/subsets/) Given a set of distinct integers, S, return all possible subsets. @@ -5822,7 +5822,7 @@ class Solution: ``` ----- -##[126. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) +## [126. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) Given a collection of integers that might contain duplicates, S, return all possible subsets. @@ -5880,7 +5880,7 @@ class Solution: ``` ----- -##[127. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) +## [127. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters. @@ -5926,7 +5926,7 @@ class Solution: ``` ----- -##[128. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) +## [128. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) Write a program to solve a Sudoku puzzle by filling the empty cells. @@ -5978,7 +5978,7 @@ class Solution: ``` ----- -##[129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) +## [129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. @@ -6051,7 +6051,7 @@ class Solution: ``` ----- -##[130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) +## [130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. @@ -6129,7 +6129,7 @@ class Solution: ``` ----- -##[131. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) +## [131. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) Given a linked list, swap every two adjacent nodes and return its head. @@ -6185,7 +6185,7 @@ class Solution: ``` ----- -##[132. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) +## [132. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). @@ -6257,7 +6257,7 @@ class Solution: ``` ----- -##[133. Text Justification](https://oj.leetcode.com/problems/text-justification/) +## [133. Text Justification](https://oj.leetcode.com/problems/text-justification/) Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. @@ -6325,7 +6325,7 @@ class Solution: ``` ----- -##[134. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) +## [134. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. @@ -6360,7 +6360,7 @@ class Solution: ``` ----- -##[135. Triangle](https://oj.leetcode.com/problems/triangle/) +## [135. Triangle](https://oj.leetcode.com/problems/triangle/) Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. @@ -6418,7 +6418,7 @@ class Solution: ``` ----- -##[136. Two Sum](https://oj.leetcode.com/problems/two-sum/) +## [136. Two Sum](https://oj.leetcode.com/problems/two-sum/) Given an array of integers, find two numbers such that they add up to a specific target number. @@ -6477,7 +6477,7 @@ class Solution: ``` ----- -##[137. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) +## [137. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) Given n, how many structurally unique BST's (binary search trees) that store values 1...n? @@ -6498,7 +6498,7 @@ class Solution: ``` ----- -##[138. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) +## [138. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. @@ -6547,7 +6547,7 @@ class Solution: ``` ----- -##[139. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) +## [139. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). @@ -6581,7 +6581,7 @@ class Solution: ``` ----- -##[140. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) +## [140. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) Follow up for "Unique Paths": @@ -6632,7 +6632,7 @@ class Solution: ``` ----- -##[141. Valid Number](https://oj.leetcode.com/problems/valid-number/) +## [141. Valid Number](https://oj.leetcode.com/problems/valid-number/) Validate if a given string is numeric. @@ -6688,7 +6688,7 @@ class Solution: ``` ----- -##[142. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) +## [142. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. @@ -6725,7 +6725,7 @@ class Solution: ``` ----- -##[143. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) +## [143. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. @@ -6752,7 +6752,7 @@ class Solution: ``` ----- -##[144. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) +## [144. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. @@ -6796,7 +6796,7 @@ class Solution: ``` ----- -##[145. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) +## [145. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) Given a binary tree, determine if it is a valid binary search tree (BST). @@ -6851,7 +6851,7 @@ This won't pass ``` ----- -##[146. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) +## [146. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) Implement wildcard pattern matching with support for '?' and '*'. @@ -6907,7 +6907,7 @@ class Solution: ``` ----- -##[147. Word Break](https://oj.leetcode.com/problems/word-break/) +## [147. Word Break](https://oj.leetcode.com/problems/word-break/) Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. @@ -6944,7 +6944,7 @@ class Solution: ``` ----- -##[148. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) +## [148. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. @@ -7022,7 +7022,7 @@ class Solution: ``` ----- -##[149. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) +## [149. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: @@ -7069,7 +7069,7 @@ class Solution: ``` ----- -##[150. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) +## [150. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: @@ -7134,7 +7134,7 @@ class Solution: ``` ----- -##[151. Word Search](https://oj.leetcode.com/problems/word-search/) +## [151. Word Search](https://oj.leetcode.com/problems/word-search/) Given a 2D board and a word, find if the word exists in the grid. @@ -7197,7 +7197,7 @@ class Solution: ``` ----- -##[152. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) +## [152. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ``` @@ -7237,7 +7237,7 @@ class Solution: ``` ----- -##153. Absolute Minimum +## 153. Absolute Minimum #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32782345.html) for Amazon Interview Given three arrays A,B,C containing unsorted numbers. Find three numbers a, @@ -7283,7 +7283,7 @@ def get_min_distance(A1, A2, A3): ``` ----- -##154. Alternating Positive N Negative +## 154. Alternating Positive N Negative or Rearrange Array Alternating Positive Negative Items Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance. @@ -7368,7 +7368,7 @@ print rearrange_array_rotate(B) ``` ----- -##155. BFS DFS +## 155. BFS DFS #####Summarize all kind of ways to do Tree Traversal * BFS @@ -7604,7 +7604,7 @@ print_tree_as_list(head) ``` ----- -##156. Binary Tree Level K Nodes +## 156. Binary Tree Level K Nodes #####From [blog](http://blog.csdn.net/luckyxiaoqiang/article/details/7518888#topic6) @@ -7635,7 +7635,7 @@ print get_kth_level_nodes(root, 5) ``` ----- -##157. Blocking Queue +## 157. Blocking Queue #####From Tango Interview Challenge This is pretty important design pattern, including the knowledge of thread @@ -7752,7 +7752,7 @@ random_result() ``` ----- -##158. Coin Change +## 158. Coin Change #####From [Geeksforgeeks](http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/) @@ -7787,7 +7787,7 @@ print coin_change(5) ``` ----- -##159. Consecutive Subarray +## 159. Consecutive Subarray #####Interview With Cyan 1. Shortest Path @@ -7839,7 +7839,7 @@ print find_consecutive(num, sum) ``` ----- -##161. Count zeros in Factorial +## 161. Count zeros in Factorial From mitbbs for Facebook @@ -7868,7 +7868,7 @@ print fact(N) ``` ----- -##162. Delete a Node in BST +## 162. Delete a Node in BST [Solution](http://answer.ninechapter.com/solutions/delete-a-node-in-binary-search-tree/) 实际上有好几种做法 @@ -7931,7 +7931,7 @@ def delete_node_in_BST(parent, node): ``` ----- -##165. Flatten a Multilevel Linked List +## 165. Flatten a Multilevel Linked List Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in below figure.You are given the head of the first level of the list. Flatten the list so that all the nodes appear in a single-level linked list. You need to flatten the list in way that all nodes at first level should come first, then nodes of second level, and so on. @@ -7964,7 +7964,7 @@ def flatten_list(head): ``` ----- -##166. Flattening a Linked List +## 166. Flattening a Linked List Given a linked list where every node represents a linked list and contains two pointers of its type: (i) Pointer to next node in the main list (we call it ‘right’ pointer in below code) @@ -8017,7 +8017,7 @@ def merge(node1, node2): ``` ----- -##167. Largest None Close Sum +## 167. Largest None Close Sum #####9/23/2014 Interview with Kevin from Fivestars @@ -8053,7 +8053,7 @@ def find_largest_none_close_sum(A): ``` ----- -##168. Longest Common Subsequence +## 168. Longest Common Subsequence Need to distinguish from Longest Common Substring @@ -8153,7 +8153,7 @@ print LCS('AGGTAB', 'GXTXAYB') ``` ----- -##169. Longest Common Substring +## 169. Longest Common Substring ##### 9/4/2014 Interview with Tubular 1. Subset(second le) @@ -8211,7 +8211,7 @@ print Longest_Common_Substring("GeeksforGeeks", "GeeksQuiz") ``` ----- -##170. Longest Increasing Subsequence +## 170. Longest Increasing Subsequence #####NC Class 5, slides 17 @@ -8273,7 +8273,7 @@ d_A = LIS(A) ``` ----- -##171. Lowest Common Ancestor +## 171. Lowest Common Ancestor #####[LCA, Lowest Common Ancestor](http://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/) Pocket Gem possible question 9/8/2014 @@ -8347,7 +8347,7 @@ def get_LCA(root, node1, node2): ``` ----- -##172. Majority Number +## 172. Majority Number #####From mibbs for Linkedin Interview Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). @@ -8406,7 +8406,7 @@ def majority_ii(A): ``` ----- -##173. Min Num to Composite Words +## 173. Min Num to Composite Words #####From [Career Cup](http://www.careercup.com/page?pid=pinterest-interview-questions) Pinterest @@ -8451,7 +8451,7 @@ print print_min_num_words(str, d) ``` ----- -##174. Min Stack +## 174. Min Stack #####From NC Class 7 Data Structures, slides 8 [Solution](http://www.geeksforgeeks.org/design-and-implement-special-stack-data-structure/) @@ -8490,7 +8490,7 @@ class MinStack(): ``` ----- -##175. Nested Integer +## 175. Nested Integer #####From NC QQ group and mitbbs, Linkedin Second round phone interview This is the interface that represents nested lists. @@ -8545,7 +8545,7 @@ def get_depth_recur(input, depth) ``` ----- -##176. Operations Calculation +## 176. Operations Calculation ##### 9/5/2014 Elasticbox 加减运算 @@ -8602,7 +8602,7 @@ find_next_num() ``` ----- -##177. Print Matrix +## 177. Print Matrix #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32570751.html) for Pinterest @@ -8647,7 +8647,7 @@ print_matrix(matrix) ``` ----- -##178. Print Numbers With Five +## 178. Print Numbers With Five ##### 9/7/2014 From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32651839.html) for Groupon 写一个function,对于参数n,输出从0到n之间所有含5的数字。 @@ -8675,7 +8675,7 @@ print find_five(60) ``` ----- -##179. Queue by Two Stacks +## 179. Queue by Two Stacks Implement a Queue by using two stacks. Support O(1) push, pop, top @@ -8703,7 +8703,7 @@ class Queue(): ``` ----- -##180. Recover Rotated Sorted Array +## 180. Recover Rotated Sorted Array Given a rotated sorted array, recover it to sorted array in-place. @@ -8734,7 +8734,7 @@ print recover_rotated_sorted_array(A) ``` ----- -##181. Rotated Mirror Number +## 181. Rotated Mirror Number #####From Alec's email, someone's onsite interview with Facebook for finding rotated mirrow number like 808 which is less than N @@ -8779,7 +8779,7 @@ print rotated_mirror_number(10000) ``` ----- -##184. Search a Range in BST +## 184. Search a Range in BST or Print BST Keys in the Give Range @@ -8810,7 +8810,7 @@ def search_a_range(root, k1, k2): ``` ----- -##185. Shortest Path +## 185. Shortest Path #####With Twitter & Cyan @@ -8893,7 +8893,7 @@ print find_path(map) ``` ----- -##186. Shuffle +## 186. Shuffle #####Shuffle a given array Saw it from FiveStar's interview. @@ -8922,7 +8922,7 @@ print shuffle_array(A) ``` ----- -##187. Sort by Stack +## 187. Sort by Stack #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32230525.html) for Quantcast @@ -8972,7 +8972,7 @@ print sort_by_two_stacks(s) ``` ----- -##188. isOneEditDistance +## 188. isOneEditDistance #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32760941.html) for facebook diff --git a/tool.py b/tool.py index b91ab10..01aa960 100755 --- a/tool.py +++ b/tool.py @@ -8,16 +8,16 @@ def combiner(file_list): for i, answer in enumerate(file_list): with open(answer) as file: title = ' '.join(answer.split('/')[-1].split('.py')[0].split('_')) - folder = answer.split('/')[1] + folder = answer.split('/')[2] content = file.read() sections = content.split("\"\"\"") if len(sections) < 3 or len(sections[2]) < 10: continue if folder == 'Leetcode': address = title.lower().replace(' ', '-') - f.write('##[%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (i+1,title,address)) + f.write('## [%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (i+1,title,address)) else: - f.write('##%d. %s\n' % (i+1,title)) + f.write('## %d. %s\n' % (i+1,title)) if '\\' in sections[1]: new_section = sections[1].split('\n') min_index = len(new_section) - 1 @@ -45,7 +45,7 @@ def title_convert(title): def frequency_creator(file_list): f = open('frequency.md', 'wb') - f.write('##Leetcode Order by Frequency\n') + f.write('## Leetcode Order by Frequency\n') book = open_workbook('Leetcode Order by Frequency.xlsx') sheet = book.sheet_by_index(0) @@ -89,14 +89,14 @@ def type_searchor(target, type): if __name__ == '__main__': - file_list = glob.glob('./Leetcode/*.py') - file_list.remove('./Leetcode/__init__.py') + file_list = glob.glob('./Ninja/Leetcode/*.py') + file_list.remove('./Ninja/Leetcode/__init__.py') file_list.sort() interview_list = glob.glob('./Interviews/*.py') interview_list.sort() file_list.extend(interview_list) combiner(file_list) - frequency_creator(file_list) + # frequency_creator(file_list) # type 1 == Data Structure, 2 == Algorithms - #type_searchor('dp', 2) + # type_searchor('dp', 2) From 6c220d3cbd5fab049e6b0b6ce61e8a5150f7ed69 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 7 Oct 2019 01:32:00 -0700 Subject: [PATCH 19/50] Change from ## to ### --- solutions.md | 366 +++++++++++++++++++++++++-------------------------- tool.py | 4 +- 2 files changed, 185 insertions(+), 185 deletions(-) diff --git a/solutions.md b/solutions.md index d17c0ec..98efb5d 100644 --- a/solutions.md +++ b/solutions.md @@ -1,4 +1,4 @@ -## [1. 3Sum](https://oj.leetcode.com/problems/3sum/) +### [1. 3Sum](https://oj.leetcode.com/problems/3sum/) Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. @@ -45,7 +45,7 @@ class Solution: ``` ----- -## [2. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) +### [2. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. @@ -82,7 +82,7 @@ class Solution: ``` ----- -## [3. 4Sum](https://oj.leetcode.com/problems/4sum/) +### [3. 4Sum](https://oj.leetcode.com/problems/4sum/) Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. @@ -158,7 +158,7 @@ class Solution: ``` ----- -## [4. Add Binary](https://oj.leetcode.com/problems/add-binary/) +### [4. Add Binary](https://oj.leetcode.com/problems/add-binary/) Given two binary strings, return their sum (also a binary string). @@ -196,7 +196,7 @@ class Solution: ``` ----- -## [5. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) +### [5. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. @@ -232,7 +232,7 @@ class Solution: ``` ----- -## [6. Anagrams](https://oj.leetcode.com/problems/anagrams/) +### [6. Anagrams](https://oj.leetcode.com/problems/anagrams/) Given an array of strings, return all groups of strings that are anagrams. @@ -264,7 +264,7 @@ class Solution: ``` ----- -## [7. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) +### [7. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) Given a binary tree, determine if it is height-balanced. @@ -321,7 +321,7 @@ class Solution: ``` ----- -## [8. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) +### [8. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -344,7 +344,7 @@ class Solution: ``` ----- -## [9. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) +### [9. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -366,7 +366,7 @@ class Solution: ``` ----- -## [10. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) +### [10. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) Say you have an array for which the ith element is the price of a given stock on day i. @@ -407,7 +407,7 @@ class Solution: ``` ----- -## [11. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) +### [11. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) Given a binary tree, return the inorder traversal of its nodes' values. @@ -467,7 +467,7 @@ class Solution: ``` ----- -## [12. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) +### [12. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). @@ -523,7 +523,7 @@ class Solution: ``` ----- -## [13. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) +### [13. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). @@ -580,7 +580,7 @@ class Solution: ``` ----- -## [14. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) +### [14. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) Given a binary tree, find the maximum path sum. @@ -629,7 +629,7 @@ class Solution: ``` ----- -## [15. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) +### [15. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) Given a binary tree, return the postorder traversal of its nodes' values. @@ -709,7 +709,7 @@ class Solution: ``` ----- -## [16. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) +### [16. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) Given a binary tree, return the preorder traversal of its nodes' values. @@ -769,7 +769,7 @@ class Solution: ``` ----- -## [17. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) +### [17. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). @@ -830,7 +830,7 @@ class Solution: ``` ----- -## [18. Candy](https://oj.leetcode.com/problems/candy/) +### [18. Candy](https://oj.leetcode.com/problems/candy/) There are N children standing in a line. Each child is assigned a rating value. @@ -861,7 +861,7 @@ class Solution: ``` ----- -## [19. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) +### [19. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) You are climbing a stair case. It takes n steps to reach to the top. @@ -912,7 +912,7 @@ class Solution: ``` ----- -## [20. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) +### [20. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. @@ -975,7 +975,7 @@ class Solution: ``` ----- -## [21. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) +### [21. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. @@ -1016,7 +1016,7 @@ class Solution: ``` ----- -## [22. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) +### [22. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. @@ -1061,7 +1061,7 @@ class Solution: ``` ----- -## [23. Combinations](https://oj.leetcode.com/problems/combinations/) +### [23. Combinations](https://oj.leetcode.com/problems/combinations/) Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. @@ -1098,7 +1098,7 @@ class Solution: ``` ----- -## [24. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) +### [24. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) Given inorder and postorder traversal of a tree, construct the binary tree. @@ -1131,7 +1131,7 @@ class Solution: ``` ----- -## [25. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) +### [25. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) Given preorder and inorder traversal of a tree, construct the binary tree. @@ -1164,7 +1164,7 @@ class Solution: ``` ----- -## [26. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) +### [26. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. @@ -1190,7 +1190,7 @@ class Solution: ``` ----- -## [27. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) +### [27. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) Given an array where elements are sorted in ascending order, convert it to a height balanced BST. @@ -1222,7 +1222,7 @@ class Solution: ``` ----- -## [28. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) +### [28. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. @@ -1272,7 +1272,7 @@ class Solution: ``` ----- -## [29. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) +### [29. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. @@ -1317,7 +1317,7 @@ class Solution: ``` ----- -## [30. Count and Say](https://oj.leetcode.com/problems/count-and-say/) +### [30. Count and Say](https://oj.leetcode.com/problems/count-and-say/) The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... @@ -1351,7 +1351,7 @@ class Solution: ``` ----- -## [31. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) +### [31. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) A message containing letters from A-Z is being encoded to numbers using the following mapping: @@ -1418,7 +1418,7 @@ class Solution: ``` ----- -## [32. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) +### [32. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) Given a string S and a string T, count the number of distinct subsequences of T in S. @@ -1474,7 +1474,7 @@ class Solution: ``` ----- -## [33. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) +### [33. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) Divide two integers without using multiplication, division and mod operator. @@ -1507,7 +1507,7 @@ class Solution: ``` ----- -## [34. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) +### [34. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) @@ -1560,7 +1560,7 @@ class Solution: ``` ----- -## [35. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) +### [35. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) Evaluate the value of an arithmetic expression in Reverse Polish Notation. @@ -1599,7 +1599,7 @@ class Solution: ``` ----- -## [36. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) +### [36. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) Given an unsorted integer array, find the first missing positive integer. @@ -1641,7 +1641,7 @@ class Solution: ``` ----- -## [37. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) +### [37. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) Given a binary tree, flatten it to a linked list in-place. @@ -1747,7 +1747,7 @@ class Solution: ``` ----- -## [38. Gas Station](https://oj.leetcode.com/problems/gas-station/) +### [38. Gas Station](https://oj.leetcode.com/problems/gas-station/) There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. @@ -1784,7 +1784,7 @@ class Solution: ``` ----- -## [39. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) +### [39. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. @@ -1813,7 +1813,7 @@ class Solution: ``` ----- -## [40. Gray Code](https://oj.leetcode.com/problems/gray-code/) +### [40. Gray Code](https://oj.leetcode.com/problems/gray-code/) The gray code is a binary numeral system where two successive values differ in only one bit. @@ -1894,7 +1894,7 @@ class Solution: ``` ----- -## [41. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) +### [41. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) Implement strStr(). @@ -1934,7 +1934,7 @@ class Solution: ``` ----- -## [42. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) +### [42. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). @@ -1986,7 +1986,7 @@ class Solution: ``` ----- -## [43. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) +### [43. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) Sort a linked list using insertion sort. @@ -2025,7 +2025,7 @@ class Solution: ``` ----- -## [44. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) +### [44. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) Given an integer, convert it to a roman numeral. @@ -2050,7 +2050,7 @@ class Solution: ``` ----- -## [45. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) +### [45. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. @@ -2114,7 +2114,7 @@ class Solution: ``` ----- -## [46. Jump Game](https://oj.leetcode.com/problems/jump-game/) +### [46. Jump Game](https://oj.leetcode.com/problems/jump-game/) Given an array of non-negative integers, you are initially positioned at the first index of the array. @@ -2181,7 +2181,7 @@ class Solution: ``` ----- -## [47. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) +### [47. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) Given an array of non-negative integers, you are initially positioned at the first index of the array. @@ -2231,7 +2231,7 @@ class Solution: ``` ----- -## [48. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) +### [48. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. @@ -2303,7 +2303,7 @@ class LRUCache: ``` ----- -## [49. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) +### [49. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. @@ -2343,7 +2343,7 @@ class Solution: ``` ----- -## [50. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) +### [50. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. @@ -2391,7 +2391,7 @@ class Solution: ``` ----- -## [51. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) +### [51. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) Given a digit string, return all possible letter combinations that the number could represent. @@ -2445,7 +2445,7 @@ class Solution: ``` ----- -## [52. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) +### [52. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) Given a linked list, determine if it has a cycle in it. @@ -2475,7 +2475,7 @@ class Solution: ``` ----- -## [53. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) +### [53. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) Given a linked list, return the node where the cycle begins. If there is no cycle, return null. @@ -2513,7 +2513,7 @@ class Solution: ``` ----- -## [54. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) +### [54. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) Write a function to find the longest common prefix string amongst an array of strings. @@ -2534,7 +2534,7 @@ class Solution: ``` ----- -## [55. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) +### [55. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) Given an unsorted array of integers, find the length of the longest consecutive elements sequence. @@ -2576,7 +2576,7 @@ class Solution: ``` ----- -## [56. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) +### [56. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. @@ -2636,7 +2636,7 @@ class Solution: ``` ----- -## [57. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) +### [57. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1. @@ -2682,7 +2682,7 @@ class Solution: ``` ----- -## [58. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) +### [58. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. @@ -2718,7 +2718,7 @@ class Solution: ``` ----- -## [59. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) +### [59. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. @@ -2765,7 +2765,7 @@ class Solution: ``` ----- -## [60. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) +### [60. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. @@ -2809,7 +2809,7 @@ class Solution: ``` ----- -## [61. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) +### [61. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) Given a binary tree, find its maximum depth. @@ -2835,7 +2835,7 @@ class Solution: ``` ----- -## [62. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) +### [62. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) Find the contiguous subarray within an array (containing at least one number) which has the largest product. @@ -2871,7 +2871,7 @@ class Solution: ``` ----- -## [63. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) +### [63. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) Find the contiguous subarray within an array (containing at least one number) which has the largest sum. @@ -2917,7 +2917,7 @@ class Solution: ``` ----- -## [64. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) +### [64. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). @@ -2963,7 +2963,7 @@ class Solution: ``` ----- -## [65. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) +### [65. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) Given a collection of intervals, merge all overlapping intervals. @@ -3000,7 +3000,7 @@ class Solution: ``` ----- -## [66. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) +### [66. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) Given two sorted integer arrays A and B, merge B into A as one sorted array. @@ -3035,7 +3035,7 @@ class Solution: ``` ----- -## [67. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) +### [67. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. @@ -3070,7 +3070,7 @@ class Solution: ``` ----- -## [68. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) +### [68. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. @@ -3104,7 +3104,7 @@ class Solution: ``` ----- -## [69. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) +### [69. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) Given a binary tree, find its minimum depth. @@ -3136,7 +3136,7 @@ class Solution: ``` ----- -## [70. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) +### [70. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. @@ -3219,7 +3219,7 @@ All Previous work. No need to worry ``` ----- -## [71. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) +### [71. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). @@ -3280,7 +3280,7 @@ class Solution: ``` ----- -## [72. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) +### [72. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) Given two numbers represented as strings, return multiplication of the numbers as a string. @@ -3303,7 +3303,7 @@ class Solution: ``` ----- -## [73. N-Queens](https://oj.leetcode.com/problems/n-queens/) +### [73. N-Queens](https://oj.leetcode.com/problems/n-queens/) The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. @@ -3360,7 +3360,7 @@ class Solution: ``` ----- -## [74. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) +### [74. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) Follow up for N-Queens problem. @@ -3399,7 +3399,7 @@ class Solution: ``` ----- -## [75. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) +### [75. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. @@ -3445,7 +3445,7 @@ class Solution: ``` ----- -## [76. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) +### [76. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) Determine whether an integer is a palindrome. Do this without extra space. @@ -3480,7 +3480,7 @@ class Solution: ``` ----- -## [77. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) +### [77. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) Given a string s, partition s such that every substring of the partition is a palindrome. @@ -3529,7 +3529,7 @@ class Solution: ``` ----- -## [78. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) +### [78. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) Given a string s, partition s such that every substring of the partition is a palindrome. @@ -3593,7 +3593,7 @@ class Solution: ``` ----- -## [79. Partition List](https://oj.leetcode.com/problems/partition-list/) +### [79. Partition List](https://oj.leetcode.com/problems/partition-list/) Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. @@ -3640,7 +3640,7 @@ class Solution: ``` ----- -## [80. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) +### [80. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) Given numRows, generate the first numRows of Pascal's triangle. @@ -3693,7 +3693,7 @@ class Solution: ``` ----- -## [81. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) +### [81. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) Given an index k, return the kth row of the Pascal's triangle. @@ -3731,7 +3731,7 @@ class Solution: ``` ----- -## [82. Path Sum](https://oj.leetcode.com/problems/path-sum/) +### [82. Path Sum](https://oj.leetcode.com/problems/path-sum/) Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. @@ -3773,7 +3773,7 @@ class Solution: ``` ----- -## [83. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) +### [83. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. @@ -3852,7 +3852,7 @@ This way will have long run time ``` ----- -## [84. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) +### [84. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) The set [1,2,3,…,n] contains a total of n! unique permutations. @@ -3894,7 +3894,7 @@ class Solution: ``` ----- -## [85. Permutations](https://oj.leetcode.com/problems/permutations/) +### [85. Permutations](https://oj.leetcode.com/problems/permutations/) Given a collection of numbers, return all possible permutations. @@ -3938,7 +3938,7 @@ class Solution: ``` ----- -## [86. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) +### [86. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) Given a collection of numbers that might contain duplicates, return all possible unique permutations. @@ -3990,7 +3990,7 @@ class Solution: ``` ----- -## [87. Plus One](https://oj.leetcode.com/problems/plus-one/) +### [87. Plus One](https://oj.leetcode.com/problems/plus-one/) Given a non-negative number represented as an array of digits, plus one to the number. @@ -4015,7 +4015,7 @@ class Solution: ``` ----- -## [88. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) +### [88. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) Given a binary tree @@ -4075,7 +4075,7 @@ class Solution: ``` ----- -## [89. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) +### [89. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) Follow up for problem "Populating Next Right Pointers in Each Node". @@ -4144,7 +4144,7 @@ class Solution: ``` ----- -## [90. Powx-n](https://oj.leetcode.com/problems/powx-n/) +### [90. Powx-n](https://oj.leetcode.com/problems/powx-n/) Implement pow(x, n). @@ -4179,7 +4179,7 @@ class Solution: ``` ----- -## [91. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) +### [91. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) Two elements of a binary search tree (BST) are swapped by mistake. @@ -4231,7 +4231,7 @@ class Solution: ``` ----- -## [92. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) +### [92. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) Implement regular expression matching with support for '.' and '*'. @@ -4282,7 +4282,7 @@ class Solution: ``` ----- -## [93. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) +### [93. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. @@ -4322,7 +4322,7 @@ class Solution: ``` ----- -## [94. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) +### [94. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? @@ -4351,7 +4351,7 @@ class Solution: ``` ----- -## [95. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) +### [95. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) Given a sorted linked list, delete all duplicates such that each element appear only once. @@ -4383,7 +4383,7 @@ class Solution: ``` ----- -## [96. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) +### [96. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. @@ -4424,7 +4424,7 @@ class Solution: ``` ----- -## [97. Remove Element](https://oj.leetcode.com/problems/remove-element/) +### [97. Remove Element](https://oj.leetcode.com/problems/remove-element/) Given an array and a value, remove all instances of that value in place and return the new length. @@ -4448,7 +4448,7 @@ class Solution: ``` ----- -## [98. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) +### [98. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) Given a linked list, remove the nth node from the end of list and return its head. @@ -4487,7 +4487,7 @@ class Solution: ``` ----- -## [99. Reorder List](https://oj.leetcode.com/problems/reorder-list/) +### [99. Reorder List](https://oj.leetcode.com/problems/reorder-list/) Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… @@ -4557,7 +4557,7 @@ class Solution: ``` ----- -## [100. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) +### [100. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) Given a string containing only digits, restore it by returning all possible valid IP address combinations. @@ -4594,7 +4594,7 @@ class Solution: ``` ----- -## [101. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) +### [101. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) Reverse digits of an integer. @@ -4627,7 +4627,7 @@ class Solution: ``` ----- -## [102. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) +### [102. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) Reverse a linked list from position m to n. Do it in-place and in one-pass. @@ -4673,7 +4673,7 @@ class Solution: ``` ----- -## [103. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) +### [103. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. @@ -4731,7 +4731,7 @@ class Solution: ``` ----- -## [104. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) +### [104. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) Given an input string, reverse the string word by word. @@ -4778,7 +4778,7 @@ class Solution: ``` ----- -## [105. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) +### [105. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) Given a roman numeral, convert it to an integer. @@ -4809,7 +4809,7 @@ class Solution: ``` ----- -## [106. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) +### [106. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) You are given an n x n 2D matrix representing an image. @@ -4850,7 +4850,7 @@ class Solution: ``` ----- -## [107. Rotate List](https://oj.leetcode.com/problems/rotate-list/) +### [107. Rotate List](https://oj.leetcode.com/problems/rotate-list/) Given a list, rotate the list to the right by k places, where k is non-negative. @@ -4893,7 +4893,7 @@ class Solution: ``` ----- -## [108. Same Tree](https://oj.leetcode.com/problems/same-tree/) +### [108. Same Tree](https://oj.leetcode.com/problems/same-tree/) Given two binary trees, write a function to check if they are equal or not. @@ -4924,7 +4924,7 @@ class Solution: ``` ----- -## [109. Scramble String](https://oj.leetcode.com/problems/scramble-string/) +### [109. Scramble String](https://oj.leetcode.com/problems/scramble-string/) Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. @@ -4989,7 +4989,7 @@ class Solution: ``` ----- -## [110. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) +### [110. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. @@ -5029,7 +5029,7 @@ class Solution: ``` ----- -## [111. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) +### [111. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: @@ -5122,7 +5122,7 @@ Note: ``` ----- -## [112. Search for a Range](https://oj.leetcode.com/problems/search-for-a-range/) +### [112. Search for a Range](https://oj.leetcode.com/problems/search-for-a-range/) Given a sorted array of integers, find the starting and ending position of a given target value. @@ -5183,7 +5183,7 @@ class Solution: ``` ----- -## [113. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) +### [113. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) Suppose a sorted array is rotated at some pivot unknown to you beforehand. @@ -5249,7 +5249,7 @@ class Solution: ``` ----- -## [114. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) +### [114. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? @@ -5287,7 +5287,7 @@ class Solution: ``` ----- -## [115. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) +### [115. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. @@ -5335,7 +5335,7 @@ class Solution: ``` ----- -## [116. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) +### [116. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) Given an absolute path for a file (Unix-style), simplify it. @@ -5377,7 +5377,7 @@ class Solution: ``` ----- -## [117. Single Number](https://oj.leetcode.com/problems/single-number/) +### [117. Single Number](https://oj.leetcode.com/problems/single-number/) Given an array of integers, every element appears twice except for one. Find that single one. @@ -5396,7 +5396,7 @@ class Solution: ``` ----- -## [118. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) +### [118. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) Given an array of integers, every element appears three times except for one. Find that single one. @@ -5453,7 +5453,7 @@ class Solution: ``` ----- -## [119. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) +### [119. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. @@ -5492,7 +5492,7 @@ class Solution: ``` ----- -## [120. Sort List](https://oj.leetcode.com/problems/sort-list/) +### [120. Sort List](https://oj.leetcode.com/problems/sort-list/) Sort a linked list in O(n log n) time using constant space complexity. @@ -5551,7 +5551,7 @@ class Solution: ``` ----- -## [121. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) +### [121. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. @@ -5608,7 +5608,7 @@ class Solution: ``` ----- -## [122. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) +### [122. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. @@ -5666,7 +5666,7 @@ class Solution: ``` ----- -## [123. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) +### [123. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) Implement int sqrt(int x). @@ -5715,7 +5715,7 @@ class Solution: ``` ----- -## [124. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) +### [124. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) Implement atoi to convert a string to an integer. @@ -5764,7 +5764,7 @@ class Solution: ``` ----- -## [125. Subsets](https://oj.leetcode.com/problems/subsets/) +### [125. Subsets](https://oj.leetcode.com/problems/subsets/) Given a set of distinct integers, S, return all possible subsets. @@ -5822,7 +5822,7 @@ class Solution: ``` ----- -## [126. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) +### [126. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) Given a collection of integers that might contain duplicates, S, return all possible subsets. @@ -5880,7 +5880,7 @@ class Solution: ``` ----- -## [127. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) +### [127. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters. @@ -5926,7 +5926,7 @@ class Solution: ``` ----- -## [128. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) +### [128. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) Write a program to solve a Sudoku puzzle by filling the empty cells. @@ -5978,7 +5978,7 @@ class Solution: ``` ----- -## [129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) +### [129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. @@ -6051,7 +6051,7 @@ class Solution: ``` ----- -## [130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) +### [130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. @@ -6129,7 +6129,7 @@ class Solution: ``` ----- -## [131. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) +### [131. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) Given a linked list, swap every two adjacent nodes and return its head. @@ -6185,7 +6185,7 @@ class Solution: ``` ----- -## [132. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) +### [132. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). @@ -6257,7 +6257,7 @@ class Solution: ``` ----- -## [133. Text Justification](https://oj.leetcode.com/problems/text-justification/) +### [133. Text Justification](https://oj.leetcode.com/problems/text-justification/) Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. @@ -6325,7 +6325,7 @@ class Solution: ``` ----- -## [134. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) +### [134. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. @@ -6360,7 +6360,7 @@ class Solution: ``` ----- -## [135. Triangle](https://oj.leetcode.com/problems/triangle/) +### [135. Triangle](https://oj.leetcode.com/problems/triangle/) Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. @@ -6418,7 +6418,7 @@ class Solution: ``` ----- -## [136. Two Sum](https://oj.leetcode.com/problems/two-sum/) +### [136. Two Sum](https://oj.leetcode.com/problems/two-sum/) Given an array of integers, find two numbers such that they add up to a specific target number. @@ -6477,7 +6477,7 @@ class Solution: ``` ----- -## [137. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) +### [137. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) Given n, how many structurally unique BST's (binary search trees) that store values 1...n? @@ -6498,7 +6498,7 @@ class Solution: ``` ----- -## [138. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) +### [138. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. @@ -6547,7 +6547,7 @@ class Solution: ``` ----- -## [139. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) +### [139. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). @@ -6581,7 +6581,7 @@ class Solution: ``` ----- -## [140. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) +### [140. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) Follow up for "Unique Paths": @@ -6632,7 +6632,7 @@ class Solution: ``` ----- -## [141. Valid Number](https://oj.leetcode.com/problems/valid-number/) +### [141. Valid Number](https://oj.leetcode.com/problems/valid-number/) Validate if a given string is numeric. @@ -6688,7 +6688,7 @@ class Solution: ``` ----- -## [142. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) +### [142. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. @@ -6725,7 +6725,7 @@ class Solution: ``` ----- -## [143. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) +### [143. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. @@ -6752,7 +6752,7 @@ class Solution: ``` ----- -## [144. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) +### [144. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. @@ -6796,7 +6796,7 @@ class Solution: ``` ----- -## [145. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) +### [145. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) Given a binary tree, determine if it is a valid binary search tree (BST). @@ -6851,7 +6851,7 @@ This won't pass ``` ----- -## [146. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) +### [146. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) Implement wildcard pattern matching with support for '?' and '*'. @@ -6907,7 +6907,7 @@ class Solution: ``` ----- -## [147. Word Break](https://oj.leetcode.com/problems/word-break/) +### [147. Word Break](https://oj.leetcode.com/problems/word-break/) Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. @@ -6944,7 +6944,7 @@ class Solution: ``` ----- -## [148. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) +### [148. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. @@ -7022,7 +7022,7 @@ class Solution: ``` ----- -## [149. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) +### [149. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: @@ -7069,7 +7069,7 @@ class Solution: ``` ----- -## [150. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) +### [150. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: @@ -7134,7 +7134,7 @@ class Solution: ``` ----- -## [151. Word Search](https://oj.leetcode.com/problems/word-search/) +### [151. Word Search](https://oj.leetcode.com/problems/word-search/) Given a 2D board and a word, find if the word exists in the grid. @@ -7197,7 +7197,7 @@ class Solution: ``` ----- -## [152. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) +### [152. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ``` @@ -7237,7 +7237,7 @@ class Solution: ``` ----- -## 153. Absolute Minimum +### 153. Absolute Minimum #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32782345.html) for Amazon Interview Given three arrays A,B,C containing unsorted numbers. Find three numbers a, @@ -7283,7 +7283,7 @@ def get_min_distance(A1, A2, A3): ``` ----- -## 154. Alternating Positive N Negative +### 154. Alternating Positive N Negative or Rearrange Array Alternating Positive Negative Items Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance. @@ -7368,7 +7368,7 @@ print rearrange_array_rotate(B) ``` ----- -## 155. BFS DFS +### 155. BFS DFS #####Summarize all kind of ways to do Tree Traversal * BFS @@ -7604,7 +7604,7 @@ print_tree_as_list(head) ``` ----- -## 156. Binary Tree Level K Nodes +### 156. Binary Tree Level K Nodes #####From [blog](http://blog.csdn.net/luckyxiaoqiang/article/details/7518888#topic6) @@ -7635,7 +7635,7 @@ print get_kth_level_nodes(root, 5) ``` ----- -## 157. Blocking Queue +### 157. Blocking Queue #####From Tango Interview Challenge This is pretty important design pattern, including the knowledge of thread @@ -7752,7 +7752,7 @@ random_result() ``` ----- -## 158. Coin Change +### 158. Coin Change #####From [Geeksforgeeks](http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/) @@ -7787,7 +7787,7 @@ print coin_change(5) ``` ----- -## 159. Consecutive Subarray +### 159. Consecutive Subarray #####Interview With Cyan 1. Shortest Path @@ -7839,7 +7839,7 @@ print find_consecutive(num, sum) ``` ----- -## 161. Count zeros in Factorial +### 161. Count zeros in Factorial From mitbbs for Facebook @@ -7868,7 +7868,7 @@ print fact(N) ``` ----- -## 162. Delete a Node in BST +### 162. Delete a Node in BST [Solution](http://answer.ninechapter.com/solutions/delete-a-node-in-binary-search-tree/) 实际上有好几种做法 @@ -7931,7 +7931,7 @@ def delete_node_in_BST(parent, node): ``` ----- -## 165. Flatten a Multilevel Linked List +### 165. Flatten a Multilevel Linked List Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in below figure.You are given the head of the first level of the list. Flatten the list so that all the nodes appear in a single-level linked list. You need to flatten the list in way that all nodes at first level should come first, then nodes of second level, and so on. @@ -7964,7 +7964,7 @@ def flatten_list(head): ``` ----- -## 166. Flattening a Linked List +### 166. Flattening a Linked List Given a linked list where every node represents a linked list and contains two pointers of its type: (i) Pointer to next node in the main list (we call it ‘right’ pointer in below code) @@ -8017,7 +8017,7 @@ def merge(node1, node2): ``` ----- -## 167. Largest None Close Sum +### 167. Largest None Close Sum #####9/23/2014 Interview with Kevin from Fivestars @@ -8053,7 +8053,7 @@ def find_largest_none_close_sum(A): ``` ----- -## 168. Longest Common Subsequence +### 168. Longest Common Subsequence Need to distinguish from Longest Common Substring @@ -8153,7 +8153,7 @@ print LCS('AGGTAB', 'GXTXAYB') ``` ----- -## 169. Longest Common Substring +### 169. Longest Common Substring ##### 9/4/2014 Interview with Tubular 1. Subset(second le) @@ -8211,7 +8211,7 @@ print Longest_Common_Substring("GeeksforGeeks", "GeeksQuiz") ``` ----- -## 170. Longest Increasing Subsequence +### 170. Longest Increasing Subsequence #####NC Class 5, slides 17 @@ -8273,7 +8273,7 @@ d_A = LIS(A) ``` ----- -## 171. Lowest Common Ancestor +### 171. Lowest Common Ancestor #####[LCA, Lowest Common Ancestor](http://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/) Pocket Gem possible question 9/8/2014 @@ -8347,7 +8347,7 @@ def get_LCA(root, node1, node2): ``` ----- -## 172. Majority Number +### 172. Majority Number #####From mibbs for Linkedin Interview Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). @@ -8406,7 +8406,7 @@ def majority_ii(A): ``` ----- -## 173. Min Num to Composite Words +### 173. Min Num to Composite Words #####From [Career Cup](http://www.careercup.com/page?pid=pinterest-interview-questions) Pinterest @@ -8451,7 +8451,7 @@ print print_min_num_words(str, d) ``` ----- -## 174. Min Stack +### 174. Min Stack #####From NC Class 7 Data Structures, slides 8 [Solution](http://www.geeksforgeeks.org/design-and-implement-special-stack-data-structure/) @@ -8490,7 +8490,7 @@ class MinStack(): ``` ----- -## 175. Nested Integer +### 175. Nested Integer #####From NC QQ group and mitbbs, Linkedin Second round phone interview This is the interface that represents nested lists. @@ -8545,7 +8545,7 @@ def get_depth_recur(input, depth) ``` ----- -## 176. Operations Calculation +### 176. Operations Calculation ##### 9/5/2014 Elasticbox 加减运算 @@ -8602,7 +8602,7 @@ find_next_num() ``` ----- -## 177. Print Matrix +### 177. Print Matrix #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32570751.html) for Pinterest @@ -8647,7 +8647,7 @@ print_matrix(matrix) ``` ----- -## 178. Print Numbers With Five +### 178. Print Numbers With Five ##### 9/7/2014 From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32651839.html) for Groupon 写一个function,对于参数n,输出从0到n之间所有含5的数字。 @@ -8675,7 +8675,7 @@ print find_five(60) ``` ----- -## 179. Queue by Two Stacks +### 179. Queue by Two Stacks Implement a Queue by using two stacks. Support O(1) push, pop, top @@ -8703,7 +8703,7 @@ class Queue(): ``` ----- -## 180. Recover Rotated Sorted Array +### 180. Recover Rotated Sorted Array Given a rotated sorted array, recover it to sorted array in-place. @@ -8734,7 +8734,7 @@ print recover_rotated_sorted_array(A) ``` ----- -## 181. Rotated Mirror Number +### 181. Rotated Mirror Number #####From Alec's email, someone's onsite interview with Facebook for finding rotated mirrow number like 808 which is less than N @@ -8779,7 +8779,7 @@ print rotated_mirror_number(10000) ``` ----- -## 184. Search a Range in BST +### 184. Search a Range in BST or Print BST Keys in the Give Range @@ -8810,7 +8810,7 @@ def search_a_range(root, k1, k2): ``` ----- -## 185. Shortest Path +### 185. Shortest Path #####With Twitter & Cyan @@ -8893,7 +8893,7 @@ print find_path(map) ``` ----- -## 186. Shuffle +### 186. Shuffle #####Shuffle a given array Saw it from FiveStar's interview. @@ -8922,7 +8922,7 @@ print shuffle_array(A) ``` ----- -## 187. Sort by Stack +### 187. Sort by Stack #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32230525.html) for Quantcast @@ -8972,7 +8972,7 @@ print sort_by_two_stacks(s) ``` ----- -## 188. isOneEditDistance +### 188. isOneEditDistance #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32760941.html) for facebook diff --git a/tool.py b/tool.py index 01aa960..5f96012 100755 --- a/tool.py +++ b/tool.py @@ -15,9 +15,9 @@ def combiner(file_list): continue if folder == 'Leetcode': address = title.lower().replace(' ', '-') - f.write('## [%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (i+1,title,address)) + f.write('### [%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (i+1,title,address)) else: - f.write('## %d. %s\n' % (i+1,title)) + f.write('### %d. %s\n' % (i+1,title)) if '\\' in sections[1]: new_section = sections[1].split('\n') min_index = len(new_section) - 1 From 1b7b56e3f4344dc50c98b6d593dda0edaf8fb8de Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Tue, 8 Oct 2019 23:40:11 -0700 Subject: [PATCH 20/50] Update BS --- Ninja/Concept_Implement/Binary_Search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ninja/Concept_Implement/Binary_Search.py b/Ninja/Concept_Implement/Binary_Search.py index 2507aa9..93fcc25 100755 --- a/Ninja/Concept_Implement/Binary_Search.py +++ b/Ninja/Concept_Implement/Binary_Search.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -a = [1,3 ,4 ,5 ,7 ,8 , 10 , 12] +a = [1, 3, 4, 5, 7, 8, 10, 12] def binary_search_1(a, target): N = len(a) From 30ec2403599b5125a74e57e334fa452ab9ae1e02 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 15:56:10 -0800 Subject: [PATCH 21/50] Update playground --- Ninja/playground.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ninja/playground.py b/Ninja/playground.py index 104a58b..f4fe3c4 100644 --- a/Ninja/playground.py +++ b/Ninja/playground.py @@ -1,11 +1,11 @@ class TreeNode: - def __init__(self, data=None): + def __init__(self, data): self.left = None self.right = None self.data = data class LinkedListNode: - def __init__(self, data=None): + def __init__(self, data): self.data = data self.next = None From 84ab37a68d037281d92faa1964f285be0358efe6 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 16:34:00 -0800 Subject: [PATCH 22/50] Update tools.py to make it work --- tool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tool.py b/tool.py index 5f96012..c9431e0 100755 --- a/tool.py +++ b/tool.py @@ -4,7 +4,7 @@ from xlrd import open_workbook def combiner(file_list): - f = open('solutions.md', 'wb') + f = open('solutions.md', 'w') for i, answer in enumerate(file_list): with open(answer) as file: title = ' '.join(answer.split('/')[-1].split('.py')[0].split('_')) @@ -44,7 +44,7 @@ def title_convert(title): return title.lower() def frequency_creator(file_list): - f = open('frequency.md', 'wb') + f = open('frequency.md', 'w') f.write('## Leetcode Order by Frequency\n') book = open_workbook('Leetcode Order by Frequency.xlsx') sheet = book.sheet_by_index(0) @@ -85,7 +85,7 @@ def type_searchor(target, type): col_index = 5 for row_index in range(sheet.nrows): if target in str(sheet.cell(row_index, col_index).value): - print str(sheet.cell(row_index, 1).value) + print(str(sheet.cell(row_index, 1).value)) if __name__ == '__main__': From a01b1249fd574e2d77175ff1181a46a530eb85cd Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 16:49:15 -0800 Subject: [PATCH 23/50] Add sequence number to the file name for easier search --- Ninja/Leetcode/{3Sum.py => 15_3Sum.py} | 0 solutions.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Ninja/Leetcode/{3Sum.py => 15_3Sum.py} (100%) diff --git a/Ninja/Leetcode/3Sum.py b/Ninja/Leetcode/15_3Sum.py similarity index 100% rename from Ninja/Leetcode/3Sum.py rename to Ninja/Leetcode/15_3Sum.py diff --git a/solutions.md b/solutions.md index 98efb5d..5563a30 100644 --- a/solutions.md +++ b/solutions.md @@ -1,4 +1,4 @@ -### [1. 3Sum](https://oj.leetcode.com/problems/3sum/) +### [1. 15 3Sum](https://oj.leetcode.com/problems/15-3sum/) Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. From 1196d109647567f03779a4e1aaec13f1a66c629d Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 22:16:44 -0800 Subject: [PATCH 24/50] Rename all leetcode questions --- Ninja/Leetcode/{Same_Tree.py => 100_Same_Tree.py} | 0 Ninja/Leetcode/{Symmetric_Tree.py => 101_Symmetric_Tree.py} | 0 ...rder_Traversal.py => 102_Binary_Tree_Level_Order_Traversal.py} | 0 ...aversal.py => 103_Binary_Tree_Zigzag_Level_Order_Traversal.py} | 0 ...epth_of_Binary_Tree.py => 104_Maximum_Depth_of_Binary_Tree.py} | 0 ..._Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py} | 0 ...Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py} | 0 ...raversal_II.py => 107_Binary_Tree_Level_Order_Traversal_II.py} | 0 ..._Tree.py => 108_Convert_Sorted_Array_to_Binary_Search_Tree.py} | 0 ...h_Tree.py => 109_Convert_Sorted_List_to_Binary_Search_Tree.py} | 0 ...r_Expression_Matching.py => 10_Regular_Expression_Matching.py} | 0 .../{Balanced_Binary_Tree.py => 110_Balanced_Binary_Tree.py} | 0 ...epth_of_Binary_Tree.py => 111_Minimum_Depth_of_Binary_Tree.py} | 0 Ninja/Leetcode/{Path_Sum.py => 112_Path_Sum.py} | 0 Ninja/Leetcode/{Path_Sum_II.py => 113_Path_Sum_II.py} | 0 ...o_Linked_List.py => 114_Flatten_Binary_Tree_to_Linked_List.py} | 0 .../{Distinct_Subsequences.py => 115_Distinct_Subsequences.py} | 0 ...Node.py => 116_Populating_Next_Right_Pointers_in_Each_Node.py} | 0 ...I.py => 117_Populating_Next_Right_Pointers_in_Each_Node_II.py} | 0 ...ntainer_With_Most_Water.py => 11_Container_With_Most_Water.py} | 0 Ninja/Leetcode/{Triangle.py => 120_Triangle.py} | 0 ...y_and_Sell_Stock.py => 121_Best_Time_to_Buy_and_Sell_Stock.py} | 0 ...Sell_Stock_II.py => 122_Best_Time_to_Buy_and_Sell_Stock_II.py} | 0 ...ll_Stock_III.py => 123_Best_Time_to_Buy_and_Sell_Stock_III.py} | 0 ...ee_Maximum_Path_Sum.py => 124_Binary_Tree_Maximum_Path_Sum.py} | 0 Ninja/Leetcode/{Valid_Palindrome.py => 125_Valid_Palindrome.py} | 0 Ninja/Leetcode/{Word_Ladder_II.py => 126_Word_Ladder_II.py} | 0 Ninja/Leetcode/{Word_Ladder.py => 127_Word_Ladder.py} | 0 ...onsecutive_Sequence.py => 128_Longest_Consecutive_Sequence.py} | 0 ...um_Root_to_Leaf_Numbers.py => 129_Sum_Root_to_Leaf_Numbers.py} | 0 Ninja/Leetcode/{Integer_to_Roman.py => 12_Integer_to_Roman.py} | 0 .../Leetcode/{Surrounded_Regions.py => 130_Surrounded_Regions.py} | 0 ...{Palindrome_Partitioning.py => 131_Palindrome_Partitioning.py} | 0 ...drome_Partitioning_II.py => 132_Palindrome_Partitioning_II.py} | 0 Ninja/Leetcode/{Clone_Graph.py => 133_Clone_Graph.py} | 0 Ninja/Leetcode/{Gas_Station.py => 134_Gas_Station.py} | 0 Ninja/Leetcode/{Candy.py => 135_Candy.py} | 0 Ninja/Leetcode/{Single_Number.py => 136_Single_Number.py} | 0 Ninja/Leetcode/{Single_Number_II.py => 137_Single_Number_II.py} | 0 ...ith_Random_Pointer.py => 138_Copy_List_with_Random_Pointer.py} | 0 Ninja/Leetcode/{Word_Break.py => 139_Word_Break.py} | 0 Ninja/Leetcode/{Roman_to_Integer.py => 13_Roman_to_Integer.py} | 0 Ninja/Leetcode/{Word_Break_II.py => 140_Word_Break_II.py} | 0 Ninja/Leetcode/{Linked_List_Cycle.py => 141_Linked_List_Cycle.py} | 0 .../{Linked_List_Cycle_II.py => 142_Linked_List_Cycle_II.py} | 0 Ninja/Leetcode/{Reorder_List.py => 143_Reorder_List.py} | 0 ...reorder_Traversal.py => 144_Binary_Tree_Preorder_Traversal.py} | 0 ...torder_Traversal.py => 145_Binary_Tree_Postorder_Traversal.py} | 0 Ninja/Leetcode/{LRU_Cache.py => 146_LRU_Cache.py} | 0 .../{Insertion_Sort_List.py => 147_Insertion_Sort_List.py} | 0 Ninja/Leetcode/{Sort_List.py => 148_Sort_List.py} | 0 .../{Max_Points_on_a_Line.py => 149_Max_Points_on_a_Line.py} | 0 .../{Longest_Common_Prefix.py => 14_Longest_Common_Prefix.py} | 0 ...Polish_Notation.py => 150_Evaluate_Reverse_Polish_Notation.py} | 0 ...erse_Words_in_a_String.py => 151_Reverse_Words_in_a_String.py} | 0 ...aximum_Product_Subarray.py => 152_Maximum_Product_Subarray.py} | 0 Ninja/Leetcode/{3Sum_Closest.py => 16_3Sum_Closest.py} | 0 ...hone_Number.py => 17_Letter_Combinations_of_a_Phone_Number.py} | 0 Ninja/Leetcode/{4Sum.py => 18_4Sum.py} | 0 ...From_End_of_List.py => 19_Remove_Nth_Node_From_End_of_List.py} | 0 Ninja/Leetcode/{Two_Sum.py => 1_Two_Sum.py} | 0 Ninja/Leetcode/{Valid_Parentheses.py => 20_Valid_Parentheses.py} | 0 .../{Merge_Two_Sorted_Lists.py => 21_Merge_Two_Sorted_Lists.py} | 0 .../{Generate_Parentheses.py => 22_Generate_Parentheses.py} | 0 .../{Merge_k_Sorted_Lists.py => 23_Merge_k_Sorted_Lists.py} | 0 .../{Swap_Nodes_in_Pairs.py => 24_Swap_Nodes_in_Pairs.py} | 0 ...Reverse_Nodes_in_k-Group.py => 25_Reverse_Nodes_in_k-Group.py} | 0 ..._Sorted_Array.py => 26_Remove_Duplicates_from_Sorted_Array.py} | 0 Ninja/Leetcode/{Remove_Element.py => 27_Remove_Element.py} | 0 .../{Divide_Two_Integers.py => 29_Divide_Two_Integers.py} | 0 Ninja/Leetcode/{Add_Two_Numbers.py => 2_Add_Two_Numbers.py} | 0 ...l_Words.py => 30_Substring_with_Concatenation_of_All_Words.py} | 0 Ninja/Leetcode/{Next_Permutation.py => 31_Next_Permutation.py} | 0 ...ngest_Valid_Parentheses.py => 32_Longest_Valid_Parentheses.py} | 0 ...tated_Sorted_Array.py => 33_Search_in_Rotated_Sorted_Array.py} | 0 .../{Search_Insert_Position.py => 35_Search_Insert_Position.py} | 0 Ninja/Leetcode/{Valid_Sudoku.py => 36_Valid_Sudoku.py} | 0 Ninja/Leetcode/{Sudoku_Solver.py => 37_Sudoku_Solver.py} | 0 Ninja/Leetcode/{Count_and_Say.py => 38_Count_and_Say.py} | 0 Ninja/Leetcode/{Combination_Sum.py => 39_Combination_Sum.py} | 0 ...ers.py => 3_Longest_Substring_Without_Repeating_Characters.py} | 0 .../Leetcode/{Combination_Sum_II.py => 40_Combination_Sum_II.py} | 0 .../{First_Missing_Positive.py => 41_First_Missing_Positive.py} | 0 .../{Trapping_Rain_Water.py => 42_Trapping_Rain_Water.py} | 0 Ninja/Leetcode/{Multiply_Strings.py => 43_Multiply_Strings.py} | 0 Ninja/Leetcode/{Wildcard_Matching.py => 44_Wildcard_Matching.py} | 0 Ninja/Leetcode/{Jump_Game_II.py => 45_Jump_Game_II.py} | 0 Ninja/Leetcode/{Permutations.py => 46_Permutations.py} | 0 Ninja/Leetcode/{Permutations_II.py => 47_Permutations_II.py} | 0 Ninja/Leetcode/{Rotate_Image.py => 48_Rotate_Image.py} | 0 ...n_of_Two_Sorted_Arrays.py => 4_Median_of_Two_Sorted_Arrays.py} | 0 Ninja/Leetcode/{N-Queens.py => 51_N-Queens.py} | 0 Ninja/Leetcode/{N-Queens_II.py => 52_N-Queens_II.py} | 0 Ninja/Leetcode/{Maximum_Subarray.py => 53_Maximum_Subarray.py} | 0 Ninja/Leetcode/{Spiral_Matrix.py => 54_Spiral_Matrix.py} | 0 Ninja/Leetcode/{Jump_Game.py => 55_Jump_Game.py} | 0 Ninja/Leetcode/{Merge_Intervals.py => 56_Merge_Intervals.py} | 0 Ninja/Leetcode/{Insert_Interval.py => 57_Insert_Interval.py} | 0 .../{Length_of_Last_Word.py => 58_Length_of_Last_Word.py} | 0 Ninja/Leetcode/{Spiral_Matrix_II.py => 59_Spiral_Matrix_II.py} | 0 ...alindromic_Substring.py => 5_Longest_Palindromic_Substring.py} | 0 .../{Permutation_Sequence.py => 60_Permutation_Sequence.py} | 0 Ninja/Leetcode/{Rotate_List.py => 61_Rotate_List.py} | 0 Ninja/Leetcode/{Unique_Paths.py => 62_Unique_Paths.py} | 0 Ninja/Leetcode/{Unique_Paths_II.py => 63_Unique_Paths_II.py} | 0 Ninja/Leetcode/{Minimum_Path_Sum.py => 64_Minimum_Path_Sum.py} | 0 Ninja/Leetcode/{Valid_Number.py => 65_Valid_Number.py} | 0 Ninja/Leetcode/{Plus_One.py => 66_Plus_One.py} | 0 Ninja/Leetcode/{Add_Binary.py => 67_Add_Binary.py} | 0 .../Leetcode/{Text_Justification.py => 68_Text_Justification.py} | 0 Ninja/Leetcode/{ZigZag_Conversion.py => 6_ZigZag_Conversion.py} | 0 Ninja/Leetcode/{Climbing_Stairs.py => 70_Climbing_Stairs.py} | 0 Ninja/Leetcode/{Simplify_Path.py => 71_Simplify_Path.py} | 0 Ninja/Leetcode/{Edit_Distance.py => 72_Edit_Distance.py} | 0 Ninja/Leetcode/{Set_Matrix_Zeroes.py => 73_Set_Matrix_Zeroes.py} | 0 .../Leetcode/{Search_a_2D_Matrix.py => 74_Search_a_2D_Matrix.py} | 0 Ninja/Leetcode/{Sort_Colors.py => 75_Sort_Colors.py} | 0 ...Minimum_Window_Substring.py => 76_Minimum_Window_Substring.py} | 0 Ninja/Leetcode/{Combinations.py => 77_Combinations.py} | 0 Ninja/Leetcode/{Subsets.py => 78_Subsets.py} | 0 Ninja/Leetcode/{Word_Search.py => 79_Word_Search.py} | 0 Ninja/Leetcode/{Reverse_Integer.py => 7_Reverse_Integer.py} | 0 ...d_Array_II.py => 80_Remove_Duplicates_from_Sorted_Array_II.py} | 0 ...Sorted_Array_II.py => 81_Search_in_Rotated_Sorted_Array_II.py} | 0 ...ted_List_II.py => 82_Remove_Duplicates_from_Sorted_List_II.py} | 0 ...om_Sorted_List.py => 83_Remove_Duplicates_from_Sorted_List.py} | 0 ...angle_in_Histogram.py => 84_Largest_Rectangle_in_Histogram.py} | 0 Ninja/Leetcode/{Maximal_Rectangle.py => 85_Maximal_Rectangle.py} | 0 Ninja/Leetcode/{Partition_List.py => 86_Partition_List.py} | 0 Ninja/Leetcode/{Scramble_String.py => 87_Scramble_String.py} | 0 .../Leetcode/{Merge_Sorted_Array.py => 88_Merge_Sorted_Array.py} | 0 Ninja/Leetcode/{Gray_Code.py => 89_Gray_Code.py} | 0 Ninja/Leetcode/{Subsets_II.py => 90_Subsets_II.py} | 0 Ninja/Leetcode/{Decode_Ways.py => 91_Decode_Ways.py} | 0 .../{Reverse_Linked_List_II.py => 92_Reverse_Linked_List_II.py} | 0 .../{Restore_IP_Addresses.py => 93_Restore_IP_Addresses.py} | 0 ...e_Inorder_Traversal.py => 94_Binary_Tree_Inorder_Traversal.py} | 0 ...ary_Search_Trees_II.py => 95_Unique_Binary_Search_Trees_II.py} | 0 ...ue_Binary_Search_Trees.py => 96_Unique_Binary_Search_Trees.py} | 0 .../{Interleaving_String.py => 97_Interleaving_String.py} | 0 ...te_Binary_Search_Tree.py => 98_Validate_Binary_Search_Tree.py} | 0 ...ver_Binary_Search_Tree.py => 99_Recover_Binary_Search_Tree.py} | 0 Ninja/Leetcode/{Palindrome_Number.py => 9_Palindrome_Number.py} | 0 143 files changed, 0 insertions(+), 0 deletions(-) rename Ninja/Leetcode/{Same_Tree.py => 100_Same_Tree.py} (100%) rename Ninja/Leetcode/{Symmetric_Tree.py => 101_Symmetric_Tree.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Level_Order_Traversal.py => 102_Binary_Tree_Level_Order_Traversal.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Zigzag_Level_Order_Traversal.py => 103_Binary_Tree_Zigzag_Level_Order_Traversal.py} (100%) rename Ninja/Leetcode/{Maximum_Depth_of_Binary_Tree.py => 104_Maximum_Depth_of_Binary_Tree.py} (100%) rename Ninja/Leetcode/{Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py => 105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py} (100%) rename Ninja/Leetcode/{Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py => 106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Level_Order_Traversal_II.py => 107_Binary_Tree_Level_Order_Traversal_II.py} (100%) rename Ninja/Leetcode/{Convert_Sorted_Array_to_Binary_Search_Tree.py => 108_Convert_Sorted_Array_to_Binary_Search_Tree.py} (100%) rename Ninja/Leetcode/{Convert_Sorted_List_to_Binary_Search_Tree.py => 109_Convert_Sorted_List_to_Binary_Search_Tree.py} (100%) rename Ninja/Leetcode/{Regular_Expression_Matching.py => 10_Regular_Expression_Matching.py} (100%) rename Ninja/Leetcode/{Balanced_Binary_Tree.py => 110_Balanced_Binary_Tree.py} (100%) rename Ninja/Leetcode/{Minimum_Depth_of_Binary_Tree.py => 111_Minimum_Depth_of_Binary_Tree.py} (100%) rename Ninja/Leetcode/{Path_Sum.py => 112_Path_Sum.py} (100%) rename Ninja/Leetcode/{Path_Sum_II.py => 113_Path_Sum_II.py} (100%) rename Ninja/Leetcode/{Flatten_Binary_Tree_to_Linked_List.py => 114_Flatten_Binary_Tree_to_Linked_List.py} (100%) rename Ninja/Leetcode/{Distinct_Subsequences.py => 115_Distinct_Subsequences.py} (100%) rename Ninja/Leetcode/{Populating_Next_Right_Pointers_in_Each_Node.py => 116_Populating_Next_Right_Pointers_in_Each_Node.py} (100%) rename Ninja/Leetcode/{Populating_Next_Right_Pointers_in_Each_Node_II.py => 117_Populating_Next_Right_Pointers_in_Each_Node_II.py} (100%) rename Ninja/Leetcode/{Container_With_Most_Water.py => 11_Container_With_Most_Water.py} (100%) rename Ninja/Leetcode/{Triangle.py => 120_Triangle.py} (100%) rename Ninja/Leetcode/{Best_Time_to_Buy_and_Sell_Stock.py => 121_Best_Time_to_Buy_and_Sell_Stock.py} (100%) rename Ninja/Leetcode/{Best_Time_to_Buy_and_Sell_Stock_II.py => 122_Best_Time_to_Buy_and_Sell_Stock_II.py} (100%) rename Ninja/Leetcode/{Best_Time_to_Buy_and_Sell_Stock_III.py => 123_Best_Time_to_Buy_and_Sell_Stock_III.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Maximum_Path_Sum.py => 124_Binary_Tree_Maximum_Path_Sum.py} (100%) rename Ninja/Leetcode/{Valid_Palindrome.py => 125_Valid_Palindrome.py} (100%) rename Ninja/Leetcode/{Word_Ladder_II.py => 126_Word_Ladder_II.py} (100%) rename Ninja/Leetcode/{Word_Ladder.py => 127_Word_Ladder.py} (100%) rename Ninja/Leetcode/{Longest_Consecutive_Sequence.py => 128_Longest_Consecutive_Sequence.py} (100%) rename Ninja/Leetcode/{Sum_Root_to_Leaf_Numbers.py => 129_Sum_Root_to_Leaf_Numbers.py} (100%) rename Ninja/Leetcode/{Integer_to_Roman.py => 12_Integer_to_Roman.py} (100%) rename Ninja/Leetcode/{Surrounded_Regions.py => 130_Surrounded_Regions.py} (100%) rename Ninja/Leetcode/{Palindrome_Partitioning.py => 131_Palindrome_Partitioning.py} (100%) rename Ninja/Leetcode/{Palindrome_Partitioning_II.py => 132_Palindrome_Partitioning_II.py} (100%) rename Ninja/Leetcode/{Clone_Graph.py => 133_Clone_Graph.py} (100%) rename Ninja/Leetcode/{Gas_Station.py => 134_Gas_Station.py} (100%) rename Ninja/Leetcode/{Candy.py => 135_Candy.py} (100%) rename Ninja/Leetcode/{Single_Number.py => 136_Single_Number.py} (100%) rename Ninja/Leetcode/{Single_Number_II.py => 137_Single_Number_II.py} (100%) rename Ninja/Leetcode/{Copy_List_with_Random_Pointer.py => 138_Copy_List_with_Random_Pointer.py} (100%) rename Ninja/Leetcode/{Word_Break.py => 139_Word_Break.py} (100%) rename Ninja/Leetcode/{Roman_to_Integer.py => 13_Roman_to_Integer.py} (100%) rename Ninja/Leetcode/{Word_Break_II.py => 140_Word_Break_II.py} (100%) rename Ninja/Leetcode/{Linked_List_Cycle.py => 141_Linked_List_Cycle.py} (100%) rename Ninja/Leetcode/{Linked_List_Cycle_II.py => 142_Linked_List_Cycle_II.py} (100%) rename Ninja/Leetcode/{Reorder_List.py => 143_Reorder_List.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Preorder_Traversal.py => 144_Binary_Tree_Preorder_Traversal.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Postorder_Traversal.py => 145_Binary_Tree_Postorder_Traversal.py} (100%) rename Ninja/Leetcode/{LRU_Cache.py => 146_LRU_Cache.py} (100%) rename Ninja/Leetcode/{Insertion_Sort_List.py => 147_Insertion_Sort_List.py} (100%) rename Ninja/Leetcode/{Sort_List.py => 148_Sort_List.py} (100%) rename Ninja/Leetcode/{Max_Points_on_a_Line.py => 149_Max_Points_on_a_Line.py} (100%) rename Ninja/Leetcode/{Longest_Common_Prefix.py => 14_Longest_Common_Prefix.py} (100%) rename Ninja/Leetcode/{Evaluate_Reverse_Polish_Notation.py => 150_Evaluate_Reverse_Polish_Notation.py} (100%) rename Ninja/Leetcode/{Reverse_Words_in_a_String.py => 151_Reverse_Words_in_a_String.py} (100%) rename Ninja/Leetcode/{Maximum_Product_Subarray.py => 152_Maximum_Product_Subarray.py} (100%) rename Ninja/Leetcode/{3Sum_Closest.py => 16_3Sum_Closest.py} (100%) rename Ninja/Leetcode/{Letter_Combinations_of_a_Phone_Number.py => 17_Letter_Combinations_of_a_Phone_Number.py} (100%) rename Ninja/Leetcode/{4Sum.py => 18_4Sum.py} (100%) rename Ninja/Leetcode/{Remove_Nth_Node_From_End_of_List.py => 19_Remove_Nth_Node_From_End_of_List.py} (100%) rename Ninja/Leetcode/{Two_Sum.py => 1_Two_Sum.py} (100%) rename Ninja/Leetcode/{Valid_Parentheses.py => 20_Valid_Parentheses.py} (100%) rename Ninja/Leetcode/{Merge_Two_Sorted_Lists.py => 21_Merge_Two_Sorted_Lists.py} (100%) rename Ninja/Leetcode/{Generate_Parentheses.py => 22_Generate_Parentheses.py} (100%) rename Ninja/Leetcode/{Merge_k_Sorted_Lists.py => 23_Merge_k_Sorted_Lists.py} (100%) rename Ninja/Leetcode/{Swap_Nodes_in_Pairs.py => 24_Swap_Nodes_in_Pairs.py} (100%) rename Ninja/Leetcode/{Reverse_Nodes_in_k-Group.py => 25_Reverse_Nodes_in_k-Group.py} (100%) rename Ninja/Leetcode/{Remove_Duplicates_from_Sorted_Array.py => 26_Remove_Duplicates_from_Sorted_Array.py} (100%) rename Ninja/Leetcode/{Remove_Element.py => 27_Remove_Element.py} (100%) rename Ninja/Leetcode/{Divide_Two_Integers.py => 29_Divide_Two_Integers.py} (100%) rename Ninja/Leetcode/{Add_Two_Numbers.py => 2_Add_Two_Numbers.py} (100%) rename Ninja/Leetcode/{Substring_with_Concatenation_of_All_Words.py => 30_Substring_with_Concatenation_of_All_Words.py} (100%) rename Ninja/Leetcode/{Next_Permutation.py => 31_Next_Permutation.py} (100%) rename Ninja/Leetcode/{Longest_Valid_Parentheses.py => 32_Longest_Valid_Parentheses.py} (100%) rename Ninja/Leetcode/{Search_in_Rotated_Sorted_Array.py => 33_Search_in_Rotated_Sorted_Array.py} (100%) rename Ninja/Leetcode/{Search_Insert_Position.py => 35_Search_Insert_Position.py} (100%) rename Ninja/Leetcode/{Valid_Sudoku.py => 36_Valid_Sudoku.py} (100%) rename Ninja/Leetcode/{Sudoku_Solver.py => 37_Sudoku_Solver.py} (100%) rename Ninja/Leetcode/{Count_and_Say.py => 38_Count_and_Say.py} (100%) rename Ninja/Leetcode/{Combination_Sum.py => 39_Combination_Sum.py} (100%) rename Ninja/Leetcode/{Longest_Substring_Without_Repeating_Characters.py => 3_Longest_Substring_Without_Repeating_Characters.py} (100%) rename Ninja/Leetcode/{Combination_Sum_II.py => 40_Combination_Sum_II.py} (100%) rename Ninja/Leetcode/{First_Missing_Positive.py => 41_First_Missing_Positive.py} (100%) rename Ninja/Leetcode/{Trapping_Rain_Water.py => 42_Trapping_Rain_Water.py} (100%) rename Ninja/Leetcode/{Multiply_Strings.py => 43_Multiply_Strings.py} (100%) rename Ninja/Leetcode/{Wildcard_Matching.py => 44_Wildcard_Matching.py} (100%) rename Ninja/Leetcode/{Jump_Game_II.py => 45_Jump_Game_II.py} (100%) rename Ninja/Leetcode/{Permutations.py => 46_Permutations.py} (100%) rename Ninja/Leetcode/{Permutations_II.py => 47_Permutations_II.py} (100%) rename Ninja/Leetcode/{Rotate_Image.py => 48_Rotate_Image.py} (100%) rename Ninja/Leetcode/{Median_of_Two_Sorted_Arrays.py => 4_Median_of_Two_Sorted_Arrays.py} (100%) rename Ninja/Leetcode/{N-Queens.py => 51_N-Queens.py} (100%) rename Ninja/Leetcode/{N-Queens_II.py => 52_N-Queens_II.py} (100%) rename Ninja/Leetcode/{Maximum_Subarray.py => 53_Maximum_Subarray.py} (100%) rename Ninja/Leetcode/{Spiral_Matrix.py => 54_Spiral_Matrix.py} (100%) rename Ninja/Leetcode/{Jump_Game.py => 55_Jump_Game.py} (100%) rename Ninja/Leetcode/{Merge_Intervals.py => 56_Merge_Intervals.py} (100%) rename Ninja/Leetcode/{Insert_Interval.py => 57_Insert_Interval.py} (100%) rename Ninja/Leetcode/{Length_of_Last_Word.py => 58_Length_of_Last_Word.py} (100%) rename Ninja/Leetcode/{Spiral_Matrix_II.py => 59_Spiral_Matrix_II.py} (100%) rename Ninja/Leetcode/{Longest_Palindromic_Substring.py => 5_Longest_Palindromic_Substring.py} (100%) rename Ninja/Leetcode/{Permutation_Sequence.py => 60_Permutation_Sequence.py} (100%) rename Ninja/Leetcode/{Rotate_List.py => 61_Rotate_List.py} (100%) rename Ninja/Leetcode/{Unique_Paths.py => 62_Unique_Paths.py} (100%) rename Ninja/Leetcode/{Unique_Paths_II.py => 63_Unique_Paths_II.py} (100%) rename Ninja/Leetcode/{Minimum_Path_Sum.py => 64_Minimum_Path_Sum.py} (100%) rename Ninja/Leetcode/{Valid_Number.py => 65_Valid_Number.py} (100%) rename Ninja/Leetcode/{Plus_One.py => 66_Plus_One.py} (100%) rename Ninja/Leetcode/{Add_Binary.py => 67_Add_Binary.py} (100%) rename Ninja/Leetcode/{Text_Justification.py => 68_Text_Justification.py} (100%) rename Ninja/Leetcode/{ZigZag_Conversion.py => 6_ZigZag_Conversion.py} (100%) rename Ninja/Leetcode/{Climbing_Stairs.py => 70_Climbing_Stairs.py} (100%) rename Ninja/Leetcode/{Simplify_Path.py => 71_Simplify_Path.py} (100%) rename Ninja/Leetcode/{Edit_Distance.py => 72_Edit_Distance.py} (100%) rename Ninja/Leetcode/{Set_Matrix_Zeroes.py => 73_Set_Matrix_Zeroes.py} (100%) rename Ninja/Leetcode/{Search_a_2D_Matrix.py => 74_Search_a_2D_Matrix.py} (100%) rename Ninja/Leetcode/{Sort_Colors.py => 75_Sort_Colors.py} (100%) rename Ninja/Leetcode/{Minimum_Window_Substring.py => 76_Minimum_Window_Substring.py} (100%) rename Ninja/Leetcode/{Combinations.py => 77_Combinations.py} (100%) rename Ninja/Leetcode/{Subsets.py => 78_Subsets.py} (100%) rename Ninja/Leetcode/{Word_Search.py => 79_Word_Search.py} (100%) rename Ninja/Leetcode/{Reverse_Integer.py => 7_Reverse_Integer.py} (100%) rename Ninja/Leetcode/{Remove_Duplicates_from_Sorted_Array_II.py => 80_Remove_Duplicates_from_Sorted_Array_II.py} (100%) rename Ninja/Leetcode/{Search_in_Rotated_Sorted_Array_II.py => 81_Search_in_Rotated_Sorted_Array_II.py} (100%) rename Ninja/Leetcode/{Remove_Duplicates_from_Sorted_List_II.py => 82_Remove_Duplicates_from_Sorted_List_II.py} (100%) rename Ninja/Leetcode/{Remove_Duplicates_from_Sorted_List.py => 83_Remove_Duplicates_from_Sorted_List.py} (100%) rename Ninja/Leetcode/{Largest_Rectangle_in_Histogram.py => 84_Largest_Rectangle_in_Histogram.py} (100%) rename Ninja/Leetcode/{Maximal_Rectangle.py => 85_Maximal_Rectangle.py} (100%) rename Ninja/Leetcode/{Partition_List.py => 86_Partition_List.py} (100%) rename Ninja/Leetcode/{Scramble_String.py => 87_Scramble_String.py} (100%) rename Ninja/Leetcode/{Merge_Sorted_Array.py => 88_Merge_Sorted_Array.py} (100%) rename Ninja/Leetcode/{Gray_Code.py => 89_Gray_Code.py} (100%) rename Ninja/Leetcode/{Subsets_II.py => 90_Subsets_II.py} (100%) rename Ninja/Leetcode/{Decode_Ways.py => 91_Decode_Ways.py} (100%) rename Ninja/Leetcode/{Reverse_Linked_List_II.py => 92_Reverse_Linked_List_II.py} (100%) rename Ninja/Leetcode/{Restore_IP_Addresses.py => 93_Restore_IP_Addresses.py} (100%) rename Ninja/Leetcode/{Binary_Tree_Inorder_Traversal.py => 94_Binary_Tree_Inorder_Traversal.py} (100%) rename Ninja/Leetcode/{Unique_Binary_Search_Trees_II.py => 95_Unique_Binary_Search_Trees_II.py} (100%) rename Ninja/Leetcode/{Unique_Binary_Search_Trees.py => 96_Unique_Binary_Search_Trees.py} (100%) rename Ninja/Leetcode/{Interleaving_String.py => 97_Interleaving_String.py} (100%) rename Ninja/Leetcode/{Validate_Binary_Search_Tree.py => 98_Validate_Binary_Search_Tree.py} (100%) rename Ninja/Leetcode/{Recover_Binary_Search_Tree.py => 99_Recover_Binary_Search_Tree.py} (100%) rename Ninja/Leetcode/{Palindrome_Number.py => 9_Palindrome_Number.py} (100%) diff --git a/Ninja/Leetcode/Same_Tree.py b/Ninja/Leetcode/100_Same_Tree.py similarity index 100% rename from Ninja/Leetcode/Same_Tree.py rename to Ninja/Leetcode/100_Same_Tree.py diff --git a/Ninja/Leetcode/Symmetric_Tree.py b/Ninja/Leetcode/101_Symmetric_Tree.py similarity index 100% rename from Ninja/Leetcode/Symmetric_Tree.py rename to Ninja/Leetcode/101_Symmetric_Tree.py diff --git a/Ninja/Leetcode/Binary_Tree_Level_Order_Traversal.py b/Ninja/Leetcode/102_Binary_Tree_Level_Order_Traversal.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Level_Order_Traversal.py rename to Ninja/Leetcode/102_Binary_Tree_Level_Order_Traversal.py diff --git a/Ninja/Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py b/Ninja/Leetcode/103_Binary_Tree_Zigzag_Level_Order_Traversal.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Zigzag_Level_Order_Traversal.py rename to Ninja/Leetcode/103_Binary_Tree_Zigzag_Level_Order_Traversal.py diff --git a/Ninja/Leetcode/Maximum_Depth_of_Binary_Tree.py b/Ninja/Leetcode/104_Maximum_Depth_of_Binary_Tree.py similarity index 100% rename from Ninja/Leetcode/Maximum_Depth_of_Binary_Tree.py rename to Ninja/Leetcode/104_Maximum_Depth_of_Binary_Tree.py diff --git a/Ninja/Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py b/Ninja/Leetcode/105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py similarity index 100% rename from Ninja/Leetcode/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py rename to Ninja/Leetcode/105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py diff --git a/Ninja/Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py b/Ninja/Leetcode/106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py similarity index 100% rename from Ninja/Leetcode/Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py rename to Ninja/Leetcode/106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.py diff --git a/Ninja/Leetcode/Binary_Tree_Level_Order_Traversal_II.py b/Ninja/Leetcode/107_Binary_Tree_Level_Order_Traversal_II.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Level_Order_Traversal_II.py rename to Ninja/Leetcode/107_Binary_Tree_Level_Order_Traversal_II.py diff --git a/Ninja/Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py b/Ninja/Leetcode/108_Convert_Sorted_Array_to_Binary_Search_Tree.py similarity index 100% rename from Ninja/Leetcode/Convert_Sorted_Array_to_Binary_Search_Tree.py rename to Ninja/Leetcode/108_Convert_Sorted_Array_to_Binary_Search_Tree.py diff --git a/Ninja/Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py b/Ninja/Leetcode/109_Convert_Sorted_List_to_Binary_Search_Tree.py similarity index 100% rename from Ninja/Leetcode/Convert_Sorted_List_to_Binary_Search_Tree.py rename to Ninja/Leetcode/109_Convert_Sorted_List_to_Binary_Search_Tree.py diff --git a/Ninja/Leetcode/Regular_Expression_Matching.py b/Ninja/Leetcode/10_Regular_Expression_Matching.py similarity index 100% rename from Ninja/Leetcode/Regular_Expression_Matching.py rename to Ninja/Leetcode/10_Regular_Expression_Matching.py diff --git a/Ninja/Leetcode/Balanced_Binary_Tree.py b/Ninja/Leetcode/110_Balanced_Binary_Tree.py similarity index 100% rename from Ninja/Leetcode/Balanced_Binary_Tree.py rename to Ninja/Leetcode/110_Balanced_Binary_Tree.py diff --git a/Ninja/Leetcode/Minimum_Depth_of_Binary_Tree.py b/Ninja/Leetcode/111_Minimum_Depth_of_Binary_Tree.py similarity index 100% rename from Ninja/Leetcode/Minimum_Depth_of_Binary_Tree.py rename to Ninja/Leetcode/111_Minimum_Depth_of_Binary_Tree.py diff --git a/Ninja/Leetcode/Path_Sum.py b/Ninja/Leetcode/112_Path_Sum.py similarity index 100% rename from Ninja/Leetcode/Path_Sum.py rename to Ninja/Leetcode/112_Path_Sum.py diff --git a/Ninja/Leetcode/Path_Sum_II.py b/Ninja/Leetcode/113_Path_Sum_II.py similarity index 100% rename from Ninja/Leetcode/Path_Sum_II.py rename to Ninja/Leetcode/113_Path_Sum_II.py diff --git a/Ninja/Leetcode/Flatten_Binary_Tree_to_Linked_List.py b/Ninja/Leetcode/114_Flatten_Binary_Tree_to_Linked_List.py similarity index 100% rename from Ninja/Leetcode/Flatten_Binary_Tree_to_Linked_List.py rename to Ninja/Leetcode/114_Flatten_Binary_Tree_to_Linked_List.py diff --git a/Ninja/Leetcode/Distinct_Subsequences.py b/Ninja/Leetcode/115_Distinct_Subsequences.py similarity index 100% rename from Ninja/Leetcode/Distinct_Subsequences.py rename to Ninja/Leetcode/115_Distinct_Subsequences.py diff --git a/Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py b/Ninja/Leetcode/116_Populating_Next_Right_Pointers_in_Each_Node.py similarity index 100% rename from Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node.py rename to Ninja/Leetcode/116_Populating_Next_Right_Pointers_in_Each_Node.py diff --git a/Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py b/Ninja/Leetcode/117_Populating_Next_Right_Pointers_in_Each_Node_II.py similarity index 100% rename from Ninja/Leetcode/Populating_Next_Right_Pointers_in_Each_Node_II.py rename to Ninja/Leetcode/117_Populating_Next_Right_Pointers_in_Each_Node_II.py diff --git a/Ninja/Leetcode/Container_With_Most_Water.py b/Ninja/Leetcode/11_Container_With_Most_Water.py similarity index 100% rename from Ninja/Leetcode/Container_With_Most_Water.py rename to Ninja/Leetcode/11_Container_With_Most_Water.py diff --git a/Ninja/Leetcode/Triangle.py b/Ninja/Leetcode/120_Triangle.py similarity index 100% rename from Ninja/Leetcode/Triangle.py rename to Ninja/Leetcode/120_Triangle.py diff --git a/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock.py b/Ninja/Leetcode/121_Best_Time_to_Buy_and_Sell_Stock.py similarity index 100% rename from Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock.py rename to Ninja/Leetcode/121_Best_Time_to_Buy_and_Sell_Stock.py diff --git a/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py b/Ninja/Leetcode/122_Best_Time_to_Buy_and_Sell_Stock_II.py similarity index 100% rename from Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_II.py rename to Ninja/Leetcode/122_Best_Time_to_Buy_and_Sell_Stock_II.py diff --git a/Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py b/Ninja/Leetcode/123_Best_Time_to_Buy_and_Sell_Stock_III.py similarity index 100% rename from Ninja/Leetcode/Best_Time_to_Buy_and_Sell_Stock_III.py rename to Ninja/Leetcode/123_Best_Time_to_Buy_and_Sell_Stock_III.py diff --git a/Ninja/Leetcode/Binary_Tree_Maximum_Path_Sum.py b/Ninja/Leetcode/124_Binary_Tree_Maximum_Path_Sum.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Maximum_Path_Sum.py rename to Ninja/Leetcode/124_Binary_Tree_Maximum_Path_Sum.py diff --git a/Ninja/Leetcode/Valid_Palindrome.py b/Ninja/Leetcode/125_Valid_Palindrome.py similarity index 100% rename from Ninja/Leetcode/Valid_Palindrome.py rename to Ninja/Leetcode/125_Valid_Palindrome.py diff --git a/Ninja/Leetcode/Word_Ladder_II.py b/Ninja/Leetcode/126_Word_Ladder_II.py similarity index 100% rename from Ninja/Leetcode/Word_Ladder_II.py rename to Ninja/Leetcode/126_Word_Ladder_II.py diff --git a/Ninja/Leetcode/Word_Ladder.py b/Ninja/Leetcode/127_Word_Ladder.py similarity index 100% rename from Ninja/Leetcode/Word_Ladder.py rename to Ninja/Leetcode/127_Word_Ladder.py diff --git a/Ninja/Leetcode/Longest_Consecutive_Sequence.py b/Ninja/Leetcode/128_Longest_Consecutive_Sequence.py similarity index 100% rename from Ninja/Leetcode/Longest_Consecutive_Sequence.py rename to Ninja/Leetcode/128_Longest_Consecutive_Sequence.py diff --git a/Ninja/Leetcode/Sum_Root_to_Leaf_Numbers.py b/Ninja/Leetcode/129_Sum_Root_to_Leaf_Numbers.py similarity index 100% rename from Ninja/Leetcode/Sum_Root_to_Leaf_Numbers.py rename to Ninja/Leetcode/129_Sum_Root_to_Leaf_Numbers.py diff --git a/Ninja/Leetcode/Integer_to_Roman.py b/Ninja/Leetcode/12_Integer_to_Roman.py similarity index 100% rename from Ninja/Leetcode/Integer_to_Roman.py rename to Ninja/Leetcode/12_Integer_to_Roman.py diff --git a/Ninja/Leetcode/Surrounded_Regions.py b/Ninja/Leetcode/130_Surrounded_Regions.py similarity index 100% rename from Ninja/Leetcode/Surrounded_Regions.py rename to Ninja/Leetcode/130_Surrounded_Regions.py diff --git a/Ninja/Leetcode/Palindrome_Partitioning.py b/Ninja/Leetcode/131_Palindrome_Partitioning.py similarity index 100% rename from Ninja/Leetcode/Palindrome_Partitioning.py rename to Ninja/Leetcode/131_Palindrome_Partitioning.py diff --git a/Ninja/Leetcode/Palindrome_Partitioning_II.py b/Ninja/Leetcode/132_Palindrome_Partitioning_II.py similarity index 100% rename from Ninja/Leetcode/Palindrome_Partitioning_II.py rename to Ninja/Leetcode/132_Palindrome_Partitioning_II.py diff --git a/Ninja/Leetcode/Clone_Graph.py b/Ninja/Leetcode/133_Clone_Graph.py similarity index 100% rename from Ninja/Leetcode/Clone_Graph.py rename to Ninja/Leetcode/133_Clone_Graph.py diff --git a/Ninja/Leetcode/Gas_Station.py b/Ninja/Leetcode/134_Gas_Station.py similarity index 100% rename from Ninja/Leetcode/Gas_Station.py rename to Ninja/Leetcode/134_Gas_Station.py diff --git a/Ninja/Leetcode/Candy.py b/Ninja/Leetcode/135_Candy.py similarity index 100% rename from Ninja/Leetcode/Candy.py rename to Ninja/Leetcode/135_Candy.py diff --git a/Ninja/Leetcode/Single_Number.py b/Ninja/Leetcode/136_Single_Number.py similarity index 100% rename from Ninja/Leetcode/Single_Number.py rename to Ninja/Leetcode/136_Single_Number.py diff --git a/Ninja/Leetcode/Single_Number_II.py b/Ninja/Leetcode/137_Single_Number_II.py similarity index 100% rename from Ninja/Leetcode/Single_Number_II.py rename to Ninja/Leetcode/137_Single_Number_II.py diff --git a/Ninja/Leetcode/Copy_List_with_Random_Pointer.py b/Ninja/Leetcode/138_Copy_List_with_Random_Pointer.py similarity index 100% rename from Ninja/Leetcode/Copy_List_with_Random_Pointer.py rename to Ninja/Leetcode/138_Copy_List_with_Random_Pointer.py diff --git a/Ninja/Leetcode/Word_Break.py b/Ninja/Leetcode/139_Word_Break.py similarity index 100% rename from Ninja/Leetcode/Word_Break.py rename to Ninja/Leetcode/139_Word_Break.py diff --git a/Ninja/Leetcode/Roman_to_Integer.py b/Ninja/Leetcode/13_Roman_to_Integer.py similarity index 100% rename from Ninja/Leetcode/Roman_to_Integer.py rename to Ninja/Leetcode/13_Roman_to_Integer.py diff --git a/Ninja/Leetcode/Word_Break_II.py b/Ninja/Leetcode/140_Word_Break_II.py similarity index 100% rename from Ninja/Leetcode/Word_Break_II.py rename to Ninja/Leetcode/140_Word_Break_II.py diff --git a/Ninja/Leetcode/Linked_List_Cycle.py b/Ninja/Leetcode/141_Linked_List_Cycle.py similarity index 100% rename from Ninja/Leetcode/Linked_List_Cycle.py rename to Ninja/Leetcode/141_Linked_List_Cycle.py diff --git a/Ninja/Leetcode/Linked_List_Cycle_II.py b/Ninja/Leetcode/142_Linked_List_Cycle_II.py similarity index 100% rename from Ninja/Leetcode/Linked_List_Cycle_II.py rename to Ninja/Leetcode/142_Linked_List_Cycle_II.py diff --git a/Ninja/Leetcode/Reorder_List.py b/Ninja/Leetcode/143_Reorder_List.py similarity index 100% rename from Ninja/Leetcode/Reorder_List.py rename to Ninja/Leetcode/143_Reorder_List.py diff --git a/Ninja/Leetcode/Binary_Tree_Preorder_Traversal.py b/Ninja/Leetcode/144_Binary_Tree_Preorder_Traversal.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Preorder_Traversal.py rename to Ninja/Leetcode/144_Binary_Tree_Preorder_Traversal.py diff --git a/Ninja/Leetcode/Binary_Tree_Postorder_Traversal.py b/Ninja/Leetcode/145_Binary_Tree_Postorder_Traversal.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Postorder_Traversal.py rename to Ninja/Leetcode/145_Binary_Tree_Postorder_Traversal.py diff --git a/Ninja/Leetcode/LRU_Cache.py b/Ninja/Leetcode/146_LRU_Cache.py similarity index 100% rename from Ninja/Leetcode/LRU_Cache.py rename to Ninja/Leetcode/146_LRU_Cache.py diff --git a/Ninja/Leetcode/Insertion_Sort_List.py b/Ninja/Leetcode/147_Insertion_Sort_List.py similarity index 100% rename from Ninja/Leetcode/Insertion_Sort_List.py rename to Ninja/Leetcode/147_Insertion_Sort_List.py diff --git a/Ninja/Leetcode/Sort_List.py b/Ninja/Leetcode/148_Sort_List.py similarity index 100% rename from Ninja/Leetcode/Sort_List.py rename to Ninja/Leetcode/148_Sort_List.py diff --git a/Ninja/Leetcode/Max_Points_on_a_Line.py b/Ninja/Leetcode/149_Max_Points_on_a_Line.py similarity index 100% rename from Ninja/Leetcode/Max_Points_on_a_Line.py rename to Ninja/Leetcode/149_Max_Points_on_a_Line.py diff --git a/Ninja/Leetcode/Longest_Common_Prefix.py b/Ninja/Leetcode/14_Longest_Common_Prefix.py similarity index 100% rename from Ninja/Leetcode/Longest_Common_Prefix.py rename to Ninja/Leetcode/14_Longest_Common_Prefix.py diff --git a/Ninja/Leetcode/Evaluate_Reverse_Polish_Notation.py b/Ninja/Leetcode/150_Evaluate_Reverse_Polish_Notation.py similarity index 100% rename from Ninja/Leetcode/Evaluate_Reverse_Polish_Notation.py rename to Ninja/Leetcode/150_Evaluate_Reverse_Polish_Notation.py diff --git a/Ninja/Leetcode/Reverse_Words_in_a_String.py b/Ninja/Leetcode/151_Reverse_Words_in_a_String.py similarity index 100% rename from Ninja/Leetcode/Reverse_Words_in_a_String.py rename to Ninja/Leetcode/151_Reverse_Words_in_a_String.py diff --git a/Ninja/Leetcode/Maximum_Product_Subarray.py b/Ninja/Leetcode/152_Maximum_Product_Subarray.py similarity index 100% rename from Ninja/Leetcode/Maximum_Product_Subarray.py rename to Ninja/Leetcode/152_Maximum_Product_Subarray.py diff --git a/Ninja/Leetcode/3Sum_Closest.py b/Ninja/Leetcode/16_3Sum_Closest.py similarity index 100% rename from Ninja/Leetcode/3Sum_Closest.py rename to Ninja/Leetcode/16_3Sum_Closest.py diff --git a/Ninja/Leetcode/Letter_Combinations_of_a_Phone_Number.py b/Ninja/Leetcode/17_Letter_Combinations_of_a_Phone_Number.py similarity index 100% rename from Ninja/Leetcode/Letter_Combinations_of_a_Phone_Number.py rename to Ninja/Leetcode/17_Letter_Combinations_of_a_Phone_Number.py diff --git a/Ninja/Leetcode/4Sum.py b/Ninja/Leetcode/18_4Sum.py similarity index 100% rename from Ninja/Leetcode/4Sum.py rename to Ninja/Leetcode/18_4Sum.py diff --git a/Ninja/Leetcode/Remove_Nth_Node_From_End_of_List.py b/Ninja/Leetcode/19_Remove_Nth_Node_From_End_of_List.py similarity index 100% rename from Ninja/Leetcode/Remove_Nth_Node_From_End_of_List.py rename to Ninja/Leetcode/19_Remove_Nth_Node_From_End_of_List.py diff --git a/Ninja/Leetcode/Two_Sum.py b/Ninja/Leetcode/1_Two_Sum.py similarity index 100% rename from Ninja/Leetcode/Two_Sum.py rename to Ninja/Leetcode/1_Two_Sum.py diff --git a/Ninja/Leetcode/Valid_Parentheses.py b/Ninja/Leetcode/20_Valid_Parentheses.py similarity index 100% rename from Ninja/Leetcode/Valid_Parentheses.py rename to Ninja/Leetcode/20_Valid_Parentheses.py diff --git a/Ninja/Leetcode/Merge_Two_Sorted_Lists.py b/Ninja/Leetcode/21_Merge_Two_Sorted_Lists.py similarity index 100% rename from Ninja/Leetcode/Merge_Two_Sorted_Lists.py rename to Ninja/Leetcode/21_Merge_Two_Sorted_Lists.py diff --git a/Ninja/Leetcode/Generate_Parentheses.py b/Ninja/Leetcode/22_Generate_Parentheses.py similarity index 100% rename from Ninja/Leetcode/Generate_Parentheses.py rename to Ninja/Leetcode/22_Generate_Parentheses.py diff --git a/Ninja/Leetcode/Merge_k_Sorted_Lists.py b/Ninja/Leetcode/23_Merge_k_Sorted_Lists.py similarity index 100% rename from Ninja/Leetcode/Merge_k_Sorted_Lists.py rename to Ninja/Leetcode/23_Merge_k_Sorted_Lists.py diff --git a/Ninja/Leetcode/Swap_Nodes_in_Pairs.py b/Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py similarity index 100% rename from Ninja/Leetcode/Swap_Nodes_in_Pairs.py rename to Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py diff --git a/Ninja/Leetcode/Reverse_Nodes_in_k-Group.py b/Ninja/Leetcode/25_Reverse_Nodes_in_k-Group.py similarity index 100% rename from Ninja/Leetcode/Reverse_Nodes_in_k-Group.py rename to Ninja/Leetcode/25_Reverse_Nodes_in_k-Group.py diff --git a/Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array.py b/Ninja/Leetcode/26_Remove_Duplicates_from_Sorted_Array.py similarity index 100% rename from Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array.py rename to Ninja/Leetcode/26_Remove_Duplicates_from_Sorted_Array.py diff --git a/Ninja/Leetcode/Remove_Element.py b/Ninja/Leetcode/27_Remove_Element.py similarity index 100% rename from Ninja/Leetcode/Remove_Element.py rename to Ninja/Leetcode/27_Remove_Element.py diff --git a/Ninja/Leetcode/Divide_Two_Integers.py b/Ninja/Leetcode/29_Divide_Two_Integers.py similarity index 100% rename from Ninja/Leetcode/Divide_Two_Integers.py rename to Ninja/Leetcode/29_Divide_Two_Integers.py diff --git a/Ninja/Leetcode/Add_Two_Numbers.py b/Ninja/Leetcode/2_Add_Two_Numbers.py similarity index 100% rename from Ninja/Leetcode/Add_Two_Numbers.py rename to Ninja/Leetcode/2_Add_Two_Numbers.py diff --git a/Ninja/Leetcode/Substring_with_Concatenation_of_All_Words.py b/Ninja/Leetcode/30_Substring_with_Concatenation_of_All_Words.py similarity index 100% rename from Ninja/Leetcode/Substring_with_Concatenation_of_All_Words.py rename to Ninja/Leetcode/30_Substring_with_Concatenation_of_All_Words.py diff --git a/Ninja/Leetcode/Next_Permutation.py b/Ninja/Leetcode/31_Next_Permutation.py similarity index 100% rename from Ninja/Leetcode/Next_Permutation.py rename to Ninja/Leetcode/31_Next_Permutation.py diff --git a/Ninja/Leetcode/Longest_Valid_Parentheses.py b/Ninja/Leetcode/32_Longest_Valid_Parentheses.py similarity index 100% rename from Ninja/Leetcode/Longest_Valid_Parentheses.py rename to Ninja/Leetcode/32_Longest_Valid_Parentheses.py diff --git a/Ninja/Leetcode/Search_in_Rotated_Sorted_Array.py b/Ninja/Leetcode/33_Search_in_Rotated_Sorted_Array.py similarity index 100% rename from Ninja/Leetcode/Search_in_Rotated_Sorted_Array.py rename to Ninja/Leetcode/33_Search_in_Rotated_Sorted_Array.py diff --git a/Ninja/Leetcode/Search_Insert_Position.py b/Ninja/Leetcode/35_Search_Insert_Position.py similarity index 100% rename from Ninja/Leetcode/Search_Insert_Position.py rename to Ninja/Leetcode/35_Search_Insert_Position.py diff --git a/Ninja/Leetcode/Valid_Sudoku.py b/Ninja/Leetcode/36_Valid_Sudoku.py similarity index 100% rename from Ninja/Leetcode/Valid_Sudoku.py rename to Ninja/Leetcode/36_Valid_Sudoku.py diff --git a/Ninja/Leetcode/Sudoku_Solver.py b/Ninja/Leetcode/37_Sudoku_Solver.py similarity index 100% rename from Ninja/Leetcode/Sudoku_Solver.py rename to Ninja/Leetcode/37_Sudoku_Solver.py diff --git a/Ninja/Leetcode/Count_and_Say.py b/Ninja/Leetcode/38_Count_and_Say.py similarity index 100% rename from Ninja/Leetcode/Count_and_Say.py rename to Ninja/Leetcode/38_Count_and_Say.py diff --git a/Ninja/Leetcode/Combination_Sum.py b/Ninja/Leetcode/39_Combination_Sum.py similarity index 100% rename from Ninja/Leetcode/Combination_Sum.py rename to Ninja/Leetcode/39_Combination_Sum.py diff --git a/Ninja/Leetcode/Longest_Substring_Without_Repeating_Characters.py b/Ninja/Leetcode/3_Longest_Substring_Without_Repeating_Characters.py similarity index 100% rename from Ninja/Leetcode/Longest_Substring_Without_Repeating_Characters.py rename to Ninja/Leetcode/3_Longest_Substring_Without_Repeating_Characters.py diff --git a/Ninja/Leetcode/Combination_Sum_II.py b/Ninja/Leetcode/40_Combination_Sum_II.py similarity index 100% rename from Ninja/Leetcode/Combination_Sum_II.py rename to Ninja/Leetcode/40_Combination_Sum_II.py diff --git a/Ninja/Leetcode/First_Missing_Positive.py b/Ninja/Leetcode/41_First_Missing_Positive.py similarity index 100% rename from Ninja/Leetcode/First_Missing_Positive.py rename to Ninja/Leetcode/41_First_Missing_Positive.py diff --git a/Ninja/Leetcode/Trapping_Rain_Water.py b/Ninja/Leetcode/42_Trapping_Rain_Water.py similarity index 100% rename from Ninja/Leetcode/Trapping_Rain_Water.py rename to Ninja/Leetcode/42_Trapping_Rain_Water.py diff --git a/Ninja/Leetcode/Multiply_Strings.py b/Ninja/Leetcode/43_Multiply_Strings.py similarity index 100% rename from Ninja/Leetcode/Multiply_Strings.py rename to Ninja/Leetcode/43_Multiply_Strings.py diff --git a/Ninja/Leetcode/Wildcard_Matching.py b/Ninja/Leetcode/44_Wildcard_Matching.py similarity index 100% rename from Ninja/Leetcode/Wildcard_Matching.py rename to Ninja/Leetcode/44_Wildcard_Matching.py diff --git a/Ninja/Leetcode/Jump_Game_II.py b/Ninja/Leetcode/45_Jump_Game_II.py similarity index 100% rename from Ninja/Leetcode/Jump_Game_II.py rename to Ninja/Leetcode/45_Jump_Game_II.py diff --git a/Ninja/Leetcode/Permutations.py b/Ninja/Leetcode/46_Permutations.py similarity index 100% rename from Ninja/Leetcode/Permutations.py rename to Ninja/Leetcode/46_Permutations.py diff --git a/Ninja/Leetcode/Permutations_II.py b/Ninja/Leetcode/47_Permutations_II.py similarity index 100% rename from Ninja/Leetcode/Permutations_II.py rename to Ninja/Leetcode/47_Permutations_II.py diff --git a/Ninja/Leetcode/Rotate_Image.py b/Ninja/Leetcode/48_Rotate_Image.py similarity index 100% rename from Ninja/Leetcode/Rotate_Image.py rename to Ninja/Leetcode/48_Rotate_Image.py diff --git a/Ninja/Leetcode/Median_of_Two_Sorted_Arrays.py b/Ninja/Leetcode/4_Median_of_Two_Sorted_Arrays.py similarity index 100% rename from Ninja/Leetcode/Median_of_Two_Sorted_Arrays.py rename to Ninja/Leetcode/4_Median_of_Two_Sorted_Arrays.py diff --git a/Ninja/Leetcode/N-Queens.py b/Ninja/Leetcode/51_N-Queens.py similarity index 100% rename from Ninja/Leetcode/N-Queens.py rename to Ninja/Leetcode/51_N-Queens.py diff --git a/Ninja/Leetcode/N-Queens_II.py b/Ninja/Leetcode/52_N-Queens_II.py similarity index 100% rename from Ninja/Leetcode/N-Queens_II.py rename to Ninja/Leetcode/52_N-Queens_II.py diff --git a/Ninja/Leetcode/Maximum_Subarray.py b/Ninja/Leetcode/53_Maximum_Subarray.py similarity index 100% rename from Ninja/Leetcode/Maximum_Subarray.py rename to Ninja/Leetcode/53_Maximum_Subarray.py diff --git a/Ninja/Leetcode/Spiral_Matrix.py b/Ninja/Leetcode/54_Spiral_Matrix.py similarity index 100% rename from Ninja/Leetcode/Spiral_Matrix.py rename to Ninja/Leetcode/54_Spiral_Matrix.py diff --git a/Ninja/Leetcode/Jump_Game.py b/Ninja/Leetcode/55_Jump_Game.py similarity index 100% rename from Ninja/Leetcode/Jump_Game.py rename to Ninja/Leetcode/55_Jump_Game.py diff --git a/Ninja/Leetcode/Merge_Intervals.py b/Ninja/Leetcode/56_Merge_Intervals.py similarity index 100% rename from Ninja/Leetcode/Merge_Intervals.py rename to Ninja/Leetcode/56_Merge_Intervals.py diff --git a/Ninja/Leetcode/Insert_Interval.py b/Ninja/Leetcode/57_Insert_Interval.py similarity index 100% rename from Ninja/Leetcode/Insert_Interval.py rename to Ninja/Leetcode/57_Insert_Interval.py diff --git a/Ninja/Leetcode/Length_of_Last_Word.py b/Ninja/Leetcode/58_Length_of_Last_Word.py similarity index 100% rename from Ninja/Leetcode/Length_of_Last_Word.py rename to Ninja/Leetcode/58_Length_of_Last_Word.py diff --git a/Ninja/Leetcode/Spiral_Matrix_II.py b/Ninja/Leetcode/59_Spiral_Matrix_II.py similarity index 100% rename from Ninja/Leetcode/Spiral_Matrix_II.py rename to Ninja/Leetcode/59_Spiral_Matrix_II.py diff --git a/Ninja/Leetcode/Longest_Palindromic_Substring.py b/Ninja/Leetcode/5_Longest_Palindromic_Substring.py similarity index 100% rename from Ninja/Leetcode/Longest_Palindromic_Substring.py rename to Ninja/Leetcode/5_Longest_Palindromic_Substring.py diff --git a/Ninja/Leetcode/Permutation_Sequence.py b/Ninja/Leetcode/60_Permutation_Sequence.py similarity index 100% rename from Ninja/Leetcode/Permutation_Sequence.py rename to Ninja/Leetcode/60_Permutation_Sequence.py diff --git a/Ninja/Leetcode/Rotate_List.py b/Ninja/Leetcode/61_Rotate_List.py similarity index 100% rename from Ninja/Leetcode/Rotate_List.py rename to Ninja/Leetcode/61_Rotate_List.py diff --git a/Ninja/Leetcode/Unique_Paths.py b/Ninja/Leetcode/62_Unique_Paths.py similarity index 100% rename from Ninja/Leetcode/Unique_Paths.py rename to Ninja/Leetcode/62_Unique_Paths.py diff --git a/Ninja/Leetcode/Unique_Paths_II.py b/Ninja/Leetcode/63_Unique_Paths_II.py similarity index 100% rename from Ninja/Leetcode/Unique_Paths_II.py rename to Ninja/Leetcode/63_Unique_Paths_II.py diff --git a/Ninja/Leetcode/Minimum_Path_Sum.py b/Ninja/Leetcode/64_Minimum_Path_Sum.py similarity index 100% rename from Ninja/Leetcode/Minimum_Path_Sum.py rename to Ninja/Leetcode/64_Minimum_Path_Sum.py diff --git a/Ninja/Leetcode/Valid_Number.py b/Ninja/Leetcode/65_Valid_Number.py similarity index 100% rename from Ninja/Leetcode/Valid_Number.py rename to Ninja/Leetcode/65_Valid_Number.py diff --git a/Ninja/Leetcode/Plus_One.py b/Ninja/Leetcode/66_Plus_One.py similarity index 100% rename from Ninja/Leetcode/Plus_One.py rename to Ninja/Leetcode/66_Plus_One.py diff --git a/Ninja/Leetcode/Add_Binary.py b/Ninja/Leetcode/67_Add_Binary.py similarity index 100% rename from Ninja/Leetcode/Add_Binary.py rename to Ninja/Leetcode/67_Add_Binary.py diff --git a/Ninja/Leetcode/Text_Justification.py b/Ninja/Leetcode/68_Text_Justification.py similarity index 100% rename from Ninja/Leetcode/Text_Justification.py rename to Ninja/Leetcode/68_Text_Justification.py diff --git a/Ninja/Leetcode/ZigZag_Conversion.py b/Ninja/Leetcode/6_ZigZag_Conversion.py similarity index 100% rename from Ninja/Leetcode/ZigZag_Conversion.py rename to Ninja/Leetcode/6_ZigZag_Conversion.py diff --git a/Ninja/Leetcode/Climbing_Stairs.py b/Ninja/Leetcode/70_Climbing_Stairs.py similarity index 100% rename from Ninja/Leetcode/Climbing_Stairs.py rename to Ninja/Leetcode/70_Climbing_Stairs.py diff --git a/Ninja/Leetcode/Simplify_Path.py b/Ninja/Leetcode/71_Simplify_Path.py similarity index 100% rename from Ninja/Leetcode/Simplify_Path.py rename to Ninja/Leetcode/71_Simplify_Path.py diff --git a/Ninja/Leetcode/Edit_Distance.py b/Ninja/Leetcode/72_Edit_Distance.py similarity index 100% rename from Ninja/Leetcode/Edit_Distance.py rename to Ninja/Leetcode/72_Edit_Distance.py diff --git a/Ninja/Leetcode/Set_Matrix_Zeroes.py b/Ninja/Leetcode/73_Set_Matrix_Zeroes.py similarity index 100% rename from Ninja/Leetcode/Set_Matrix_Zeroes.py rename to Ninja/Leetcode/73_Set_Matrix_Zeroes.py diff --git a/Ninja/Leetcode/Search_a_2D_Matrix.py b/Ninja/Leetcode/74_Search_a_2D_Matrix.py similarity index 100% rename from Ninja/Leetcode/Search_a_2D_Matrix.py rename to Ninja/Leetcode/74_Search_a_2D_Matrix.py diff --git a/Ninja/Leetcode/Sort_Colors.py b/Ninja/Leetcode/75_Sort_Colors.py similarity index 100% rename from Ninja/Leetcode/Sort_Colors.py rename to Ninja/Leetcode/75_Sort_Colors.py diff --git a/Ninja/Leetcode/Minimum_Window_Substring.py b/Ninja/Leetcode/76_Minimum_Window_Substring.py similarity index 100% rename from Ninja/Leetcode/Minimum_Window_Substring.py rename to Ninja/Leetcode/76_Minimum_Window_Substring.py diff --git a/Ninja/Leetcode/Combinations.py b/Ninja/Leetcode/77_Combinations.py similarity index 100% rename from Ninja/Leetcode/Combinations.py rename to Ninja/Leetcode/77_Combinations.py diff --git a/Ninja/Leetcode/Subsets.py b/Ninja/Leetcode/78_Subsets.py similarity index 100% rename from Ninja/Leetcode/Subsets.py rename to Ninja/Leetcode/78_Subsets.py diff --git a/Ninja/Leetcode/Word_Search.py b/Ninja/Leetcode/79_Word_Search.py similarity index 100% rename from Ninja/Leetcode/Word_Search.py rename to Ninja/Leetcode/79_Word_Search.py diff --git a/Ninja/Leetcode/Reverse_Integer.py b/Ninja/Leetcode/7_Reverse_Integer.py similarity index 100% rename from Ninja/Leetcode/Reverse_Integer.py rename to Ninja/Leetcode/7_Reverse_Integer.py diff --git a/Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py b/Ninja/Leetcode/80_Remove_Duplicates_from_Sorted_Array_II.py similarity index 100% rename from Ninja/Leetcode/Remove_Duplicates_from_Sorted_Array_II.py rename to Ninja/Leetcode/80_Remove_Duplicates_from_Sorted_Array_II.py diff --git a/Ninja/Leetcode/Search_in_Rotated_Sorted_Array_II.py b/Ninja/Leetcode/81_Search_in_Rotated_Sorted_Array_II.py similarity index 100% rename from Ninja/Leetcode/Search_in_Rotated_Sorted_Array_II.py rename to Ninja/Leetcode/81_Search_in_Rotated_Sorted_Array_II.py diff --git a/Ninja/Leetcode/Remove_Duplicates_from_Sorted_List_II.py b/Ninja/Leetcode/82_Remove_Duplicates_from_Sorted_List_II.py similarity index 100% rename from Ninja/Leetcode/Remove_Duplicates_from_Sorted_List_II.py rename to Ninja/Leetcode/82_Remove_Duplicates_from_Sorted_List_II.py diff --git a/Ninja/Leetcode/Remove_Duplicates_from_Sorted_List.py b/Ninja/Leetcode/83_Remove_Duplicates_from_Sorted_List.py similarity index 100% rename from Ninja/Leetcode/Remove_Duplicates_from_Sorted_List.py rename to Ninja/Leetcode/83_Remove_Duplicates_from_Sorted_List.py diff --git a/Ninja/Leetcode/Largest_Rectangle_in_Histogram.py b/Ninja/Leetcode/84_Largest_Rectangle_in_Histogram.py similarity index 100% rename from Ninja/Leetcode/Largest_Rectangle_in_Histogram.py rename to Ninja/Leetcode/84_Largest_Rectangle_in_Histogram.py diff --git a/Ninja/Leetcode/Maximal_Rectangle.py b/Ninja/Leetcode/85_Maximal_Rectangle.py similarity index 100% rename from Ninja/Leetcode/Maximal_Rectangle.py rename to Ninja/Leetcode/85_Maximal_Rectangle.py diff --git a/Ninja/Leetcode/Partition_List.py b/Ninja/Leetcode/86_Partition_List.py similarity index 100% rename from Ninja/Leetcode/Partition_List.py rename to Ninja/Leetcode/86_Partition_List.py diff --git a/Ninja/Leetcode/Scramble_String.py b/Ninja/Leetcode/87_Scramble_String.py similarity index 100% rename from Ninja/Leetcode/Scramble_String.py rename to Ninja/Leetcode/87_Scramble_String.py diff --git a/Ninja/Leetcode/Merge_Sorted_Array.py b/Ninja/Leetcode/88_Merge_Sorted_Array.py similarity index 100% rename from Ninja/Leetcode/Merge_Sorted_Array.py rename to Ninja/Leetcode/88_Merge_Sorted_Array.py diff --git a/Ninja/Leetcode/Gray_Code.py b/Ninja/Leetcode/89_Gray_Code.py similarity index 100% rename from Ninja/Leetcode/Gray_Code.py rename to Ninja/Leetcode/89_Gray_Code.py diff --git a/Ninja/Leetcode/Subsets_II.py b/Ninja/Leetcode/90_Subsets_II.py similarity index 100% rename from Ninja/Leetcode/Subsets_II.py rename to Ninja/Leetcode/90_Subsets_II.py diff --git a/Ninja/Leetcode/Decode_Ways.py b/Ninja/Leetcode/91_Decode_Ways.py similarity index 100% rename from Ninja/Leetcode/Decode_Ways.py rename to Ninja/Leetcode/91_Decode_Ways.py diff --git a/Ninja/Leetcode/Reverse_Linked_List_II.py b/Ninja/Leetcode/92_Reverse_Linked_List_II.py similarity index 100% rename from Ninja/Leetcode/Reverse_Linked_List_II.py rename to Ninja/Leetcode/92_Reverse_Linked_List_II.py diff --git a/Ninja/Leetcode/Restore_IP_Addresses.py b/Ninja/Leetcode/93_Restore_IP_Addresses.py similarity index 100% rename from Ninja/Leetcode/Restore_IP_Addresses.py rename to Ninja/Leetcode/93_Restore_IP_Addresses.py diff --git a/Ninja/Leetcode/Binary_Tree_Inorder_Traversal.py b/Ninja/Leetcode/94_Binary_Tree_Inorder_Traversal.py similarity index 100% rename from Ninja/Leetcode/Binary_Tree_Inorder_Traversal.py rename to Ninja/Leetcode/94_Binary_Tree_Inorder_Traversal.py diff --git a/Ninja/Leetcode/Unique_Binary_Search_Trees_II.py b/Ninja/Leetcode/95_Unique_Binary_Search_Trees_II.py similarity index 100% rename from Ninja/Leetcode/Unique_Binary_Search_Trees_II.py rename to Ninja/Leetcode/95_Unique_Binary_Search_Trees_II.py diff --git a/Ninja/Leetcode/Unique_Binary_Search_Trees.py b/Ninja/Leetcode/96_Unique_Binary_Search_Trees.py similarity index 100% rename from Ninja/Leetcode/Unique_Binary_Search_Trees.py rename to Ninja/Leetcode/96_Unique_Binary_Search_Trees.py diff --git a/Ninja/Leetcode/Interleaving_String.py b/Ninja/Leetcode/97_Interleaving_String.py similarity index 100% rename from Ninja/Leetcode/Interleaving_String.py rename to Ninja/Leetcode/97_Interleaving_String.py diff --git a/Ninja/Leetcode/Validate_Binary_Search_Tree.py b/Ninja/Leetcode/98_Validate_Binary_Search_Tree.py similarity index 100% rename from Ninja/Leetcode/Validate_Binary_Search_Tree.py rename to Ninja/Leetcode/98_Validate_Binary_Search_Tree.py diff --git a/Ninja/Leetcode/Recover_Binary_Search_Tree.py b/Ninja/Leetcode/99_Recover_Binary_Search_Tree.py similarity index 100% rename from Ninja/Leetcode/Recover_Binary_Search_Tree.py rename to Ninja/Leetcode/99_Recover_Binary_Search_Tree.py diff --git a/Ninja/Leetcode/Palindrome_Number.py b/Ninja/Leetcode/9_Palindrome_Number.py similarity index 100% rename from Ninja/Leetcode/Palindrome_Number.py rename to Ninja/Leetcode/9_Palindrome_Number.py From f478549bf49e98a82ec2df7acc0c23721871a9a4 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 22:28:20 -0800 Subject: [PATCH 25/50] Manual fix the rest of the names --- ...ls_Triangle.py => 118_Pascals_Triangle.py} | 0 ...angle_II.py => 119_Pascals_Triangle_II.py} | 0 ...ement_strStr.py => 28_Implement_strStr.py} | 0 ...st_Position_of_Element_in_Sorted_Array.py} | 13 ++++++++---- .../{Anagrams.py => 49_Group_Anagrams.py} | 21 ++++++++++++------- Ninja/Leetcode/{Powx-n.py => 50_Powx-n.py} | 0 Ninja/Leetcode/{Sqrtx.py => 69_Sqrtx.py} | 0 ...er_atoi.py => 8_String_to_Integer_atoi.py} | 0 8 files changed, 23 insertions(+), 11 deletions(-) rename Ninja/Leetcode/{Pascals_Triangle.py => 118_Pascals_Triangle.py} (100%) rename Ninja/Leetcode/{Pascals_Triangle_II.py => 119_Pascals_Triangle_II.py} (100%) rename Ninja/Leetcode/{Implement_strStr.py => 28_Implement_strStr.py} (100%) rename Ninja/Leetcode/{Search_for_a_Range.py => 34_Find_First_and_Last_Position_of_Element_in_Sorted_Array.py} (83%) rename Ninja/Leetcode/{Anagrams.py => 49_Group_Anagrams.py} (65%) rename Ninja/Leetcode/{Powx-n.py => 50_Powx-n.py} (100%) rename Ninja/Leetcode/{Sqrtx.py => 69_Sqrtx.py} (100%) rename Ninja/Leetcode/{String_to_Integer_atoi.py => 8_String_to_Integer_atoi.py} (100%) diff --git a/Ninja/Leetcode/Pascals_Triangle.py b/Ninja/Leetcode/118_Pascals_Triangle.py similarity index 100% rename from Ninja/Leetcode/Pascals_Triangle.py rename to Ninja/Leetcode/118_Pascals_Triangle.py diff --git a/Ninja/Leetcode/Pascals_Triangle_II.py b/Ninja/Leetcode/119_Pascals_Triangle_II.py similarity index 100% rename from Ninja/Leetcode/Pascals_Triangle_II.py rename to Ninja/Leetcode/119_Pascals_Triangle_II.py diff --git a/Ninja/Leetcode/Implement_strStr.py b/Ninja/Leetcode/28_Implement_strStr.py similarity index 100% rename from Ninja/Leetcode/Implement_strStr.py rename to Ninja/Leetcode/28_Implement_strStr.py diff --git a/Ninja/Leetcode/Search_for_a_Range.py b/Ninja/Leetcode/34_Find_First_and_Last_Position_of_Element_in_Sorted_Array.py similarity index 83% rename from Ninja/Leetcode/Search_for_a_Range.py rename to Ninja/Leetcode/34_Find_First_and_Last_Position_of_Element_in_Sorted_Array.py index d768a75..ad0eee8 100644 --- a/Ninja/Leetcode/Search_for_a_Range.py +++ b/Ninja/Leetcode/34_Find_First_and_Last_Position_of_Element_in_Sorted_Array.py @@ -1,13 +1,18 @@ """ -Given a sorted array of integers, find the starting and ending position of a given target value. +Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. -For example, -Given [5, 7, 7, 8, 8, 10] and target value 8, -return [3, 4]. +Example 1: + +Input: nums = [5,7,7,8,8,10], target = 8 +Output: [3,4] +Example 2: + +Input: nums = [5,7,7,8,8,10], target = 6 +Output: [-1,-1] """ class Solution: diff --git a/Ninja/Leetcode/Anagrams.py b/Ninja/Leetcode/49_Group_Anagrams.py similarity index 65% rename from Ninja/Leetcode/Anagrams.py rename to Ninja/Leetcode/49_Group_Anagrams.py index 84fc587..2326f0a 100644 --- a/Ninja/Leetcode/Anagrams.py +++ b/Ninja/Leetcode/49_Group_Anagrams.py @@ -1,7 +1,19 @@ """ -Given an array of strings, return all groups of strings that are anagrams. +Given an array of strings, group anagrams together. -Note: All inputs will be in lower-case. +Example: + +Input: ["eat", "tea", "tan", "ate", "nat", "bat"], +Output: +[ + ["ate","eat","tea"], + ["nat","tan"], + ["bat"] +] +Note: + +All inputs will be in lowercase. +The order of your output does not matter. """ class Solution: @@ -20,8 +32,3 @@ def anagrams(self, strs): # Note: # 1. Need to use extend here, return those len(d[key]) > 1 # 2. Need to remember the definition of Anagrams - """ - Input: ["tea","and","ate","eat","dan"] - Output: ["and","dan"] - Expected: ["and","dan","tea","ate","eat"] - """ diff --git a/Ninja/Leetcode/Powx-n.py b/Ninja/Leetcode/50_Powx-n.py similarity index 100% rename from Ninja/Leetcode/Powx-n.py rename to Ninja/Leetcode/50_Powx-n.py diff --git a/Ninja/Leetcode/Sqrtx.py b/Ninja/Leetcode/69_Sqrtx.py similarity index 100% rename from Ninja/Leetcode/Sqrtx.py rename to Ninja/Leetcode/69_Sqrtx.py diff --git a/Ninja/Leetcode/String_to_Integer_atoi.py b/Ninja/Leetcode/8_String_to_Integer_atoi.py similarity index 100% rename from Ninja/Leetcode/String_to_Integer_atoi.py rename to Ninja/Leetcode/8_String_to_Integer_atoi.py From 24428a06ec69d37b7f535e88b387f12532992f86 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 22:29:32 -0800 Subject: [PATCH 26/50] Add rename script --- Ninja/question_names.py | 24878 ++++++++++++++++++++++++++++++++++++++ Ninja/rename_script.py | 34 + 2 files changed, 24912 insertions(+) create mode 100644 Ninja/question_names.py create mode 100644 Ninja/rename_script.py diff --git a/Ninja/question_names.py b/Ninja/question_names.py new file mode 100644 index 0000000..7fae0f4 --- /dev/null +++ b/Ninja/question_names.py @@ -0,0 +1,24878 @@ +LARGE_JSON_STRING = """ +{ + "user_name": "cyandterry", + "num_solved": 161, + "num_total": 1184, + "ac_easy": 43, + "ac_medium": 85, + "ac_hard": 33, + "stat_status_pairs": [{ + "stat": { + "question_id": 1409, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix", + "question__title_slug": "minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix", + "question__hide": false, + "total_acs": 1288, + "total_submitted": 1876, + "frontend_question_id": 1284, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1408, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find the Smallest Divisor Given a Threshold", + "question__title_slug": "find-the-smallest-divisor-given-a-threshold", + "question__hide": false, + "total_acs": 2215, + "total_submitted": 7352, + "frontend_question_id": 1283, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1407, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Group the People Given the Group Size They Belong To", + "question__title_slug": "group-the-people-given-the-group-size-they-belong-to", + "question__hide": false, + "total_acs": 2871, + "total_submitted": 3396, + "frontend_question_id": 1282, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1406, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Subtract the Product and Sum of Digits of an Integer", + "question__title_slug": "subtract-the-product-and-sum-of-digits-of-an-integer", + "question__hide": false, + "total_acs": 3239, + "total_submitted": 3780, + "frontend_question_id": 1281, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1404, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Print Immutable Linked List in Reverse", + "question__title_slug": "print-immutable-linked-list-in-reverse", + "question__hide": false, + "total_acs": 1289, + "total_submitted": 1352, + "frontend_question_id": 1265, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1403, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Palindrome Partitioning III", + "question__title_slug": "palindrome-partitioning-iii", + "question__hide": false, + "total_acs": 2803, + "total_submitted": 4926, + "frontend_question_id": 1278, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1402, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Square Submatrices with All Ones", + "question__title_slug": "count-square-submatrices-with-all-ones", + "question__hide": false, + "total_acs": 4769, + "total_submitted": 7175, + "frontend_question_id": 1277, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1401, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Burgers with No Waste of Ingredients", + "question__title_slug": "number-of-burgers-with-no-waste-of-ingredients", + "question__hide": false, + "total_acs": 4645, + "total_submitted": 9372, + "frontend_question_id": 1276, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1400, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Winner on a Tic Tac Toe Game", + "question__title_slug": "find-winner-on-a-tic-tac-toe-game", + "question__hide": false, + "total_acs": 4991, + "total_submitted": 8971, + "frontend_question_id": 1275, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1398, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Ways to Stay in the Same Place After Some Steps", + "question__title_slug": "number-of-ways-to-stay-in-the-same-place-after-some-steps", + "question__hide": false, + "total_acs": 4117, + "total_submitted": 10352, + "frontend_question_id": 1269, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1397, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Search Suggestions System", + "question__title_slug": "search-suggestions-system", + "question__hide": false, + "total_acs": 5915, + "total_submitted": 11564, + "frontend_question_id": 1268, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1396, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Servers that Communicate", + "question__title_slug": "count-servers-that-communicate", + "question__hide": false, + "total_acs": 6360, + "total_submitted": 10925, + "frontend_question_id": 1267, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1395, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Time Visiting All Points", + "question__title_slug": "minimum-time-visiting-all-points", + "question__hide": false, + "total_acs": 10620, + "total_submitted": 13369, + "frontend_question_id": 1266, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1389, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Moves to Move a Box to Their Target Location", + "question__title_slug": "minimum-moves-to-move-a-box-to-their-target-location", + "question__hide": false, + "total_acs": 2006, + "total_submitted": 5430, + "frontend_question_id": 1263, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1388, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Greatest Sum Divisible by Three", + "question__title_slug": "greatest-sum-divisible-by-three", + "question__hide": false, + "total_acs": 5655, + "total_submitted": 13783, + "frontend_question_id": 1262, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1387, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Elements in a Contaminated Binary Tree", + "question__title_slug": "find-elements-in-a-contaminated-binary-tree", + "question__hide": false, + "total_acs": 6793, + "total_submitted": 9338, + "frontend_question_id": 1261, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1386, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shift 2D Grid", + "question__title_slug": "shift-2d-grid", + "question__hide": false, + "total_acs": 6974, + "total_submitted": 11697, + "frontend_question_id": 1260, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1381, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Score Words Formed by Letters", + "question__title_slug": "maximum-score-words-formed-by-letters", + "question__hide": false, + "total_acs": 4015, + "total_submitted": 5729, + "frontend_question_id": 1255, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1380, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Closed Islands", + "question__title_slug": "number-of-closed-islands", + "question__hide": false, + "total_acs": 6793, + "total_submitted": 11316, + "frontend_question_id": 1254, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1379, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reconstruct a 2-Row Binary Matrix", + "question__title_slug": "reconstruct-a-2-row-binary-matrix", + "question__hide": false, + "total_acs": 6366, + "total_submitted": 16623, + "frontend_question_id": 1253, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1378, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Cells with Odd Values in a Matrix", + "question__title_slug": "cells-with-odd-values-in-a-matrix", + "question__hide": false, + "total_acs": 12955, + "total_submitted": 16549, + "frontend_question_id": 1252, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1372, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Check If It Is a Good Array", + "question__title_slug": "check-if-it-is-a-good-array", + "question__hide": false, + "total_acs": 3561, + "total_submitted": 6913, + "frontend_question_id": 1250, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1371, + "question__article__live": true, + "question__article__slug": "minimum-remove-to-make-valid-parentheses", + "question__title": "Minimum Remove to Make Valid Parentheses", + "question__title_slug": "minimum-remove-to-make-valid-parentheses", + "question__hide": false, + "total_acs": 9988, + "total_submitted": 16792, + "frontend_question_id": 1249, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1370, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Number of Nice Subarrays", + "question__title_slug": "count-number-of-nice-subarrays", + "question__hide": false, + "total_acs": 6135, + "total_submitted": 11596, + "frontend_question_id": 1248, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1369, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Swaps to Make Strings Equal", + "question__title_slug": "minimum-swaps-to-make-strings-equal", + "question__hide": false, + "total_acs": 6194, + "total_submitted": 10780, + "frontend_question_id": 1247, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1362, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Airplane Seat Assignment Probability", + "question__title_slug": "airplane-seat-assignment-probability", + "question__hide": false, + "total_acs": 3535, + "total_submitted": 5858, + "frontend_question_id": 1227, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1361, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Tiling a Rectangle with the Fewest Squares", + "question__title_slug": "tiling-a-rectangle-with-the-fewest-squares", + "question__hide": false, + "total_acs": 2176, + "total_submitted": 4464, + "frontend_question_id": 1240, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1360, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Length of a Concatenated String with Unique Characters", + "question__title_slug": "maximum-length-of-a-concatenated-string-with-unique-characters", + "question__hide": false, + "total_acs": 6579, + "total_submitted": 15618, + "frontend_question_id": 1239, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1359, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Circular Permutation in Binary Representation", + "question__title_slug": "circular-permutation-in-binary-representation", + "question__hide": false, + "total_acs": 4382, + "total_submitted": 7413, + "frontend_question_id": 1238, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1358, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Positive Integer Solution for a Given Equation", + "question__title_slug": "find-positive-integer-solution-for-a-given-equation", + "question__hide": false, + "total_acs": 8392, + "total_submitted": 12532, + "frontend_question_id": 1237, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1352, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Profit in Job Scheduling", + "question__title_slug": "maximum-profit-in-job-scheduling", + "question__hide": false, + "total_acs": 4954, + "total_submitted": 11224, + "frontend_question_id": 1235, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1351, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Replace the Substring for Balanced String", + "question__title_slug": "replace-the-substring-for-balanced-string", + "question__hide": false, + "total_acs": 5438, + "total_submitted": 17797, + "frontend_question_id": 1234, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1350, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Sub-Folders from the Filesystem", + "question__title_slug": "remove-sub-folders-from-the-filesystem", + "question__hide": false, + "total_acs": 7853, + "total_submitted": 14459, + "frontend_question_id": 1233, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1349, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Check If It Is a Straight Line", + "question__title_slug": "check-if-it-is-a-straight-line", + "question__hide": false, + "total_acs": 11644, + "total_submitted": 24751, + "frontend_question_id": 1232, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1344, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Equal Frequency", + "question__title_slug": "maximum-equal-frequency", + "question__hide": false, + "total_acs": 3868, + "total_submitted": 12092, + "frontend_question_id": 1224, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1343, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Dice Roll Simulation", + "question__title_slug": "dice-roll-simulation", + "question__hide": false, + "total_acs": 4772, + "total_submitted": 11213, + "frontend_question_id": 1223, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1342, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Queens That Can Attack the King", + "question__title_slug": "queens-that-can-attack-the-king", + "question__hide": false, + "total_acs": 8791, + "total_submitted": 12871, + "frontend_question_id": 1222, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1341, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Split a String in Balanced Strings", + "question__title_slug": "split-a-string-in-balanced-strings", + "question__hide": false, + "total_acs": 26275, + "total_submitted": 33082, + "frontend_question_id": 1221, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1337, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Skiplist", + "question__title_slug": "design-skiplist", + "question__hide": false, + "total_acs": 1656, + "total_submitted": 2775, + "frontend_question_id": 1206, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1332, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Vowels Permutation", + "question__title_slug": "count-vowels-permutation", + "question__hide": false, + "total_acs": 5606, + "total_submitted": 10946, + "frontend_question_id": 1220, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1331, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Path with Maximum Gold", + "question__title_slug": "path-with-maximum-gold", + "question__hide": false, + "total_acs": 10798, + "total_submitted": 17428, + "frontend_question_id": 1219, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1330, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Arithmetic Subsequence of Given Difference", + "question__title_slug": "longest-arithmetic-subsequence-of-given-difference", + "question__hide": false, + "total_acs": 8769, + "total_submitted": 21824, + "frontend_question_id": 1218, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1329, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Play with Chips", + "question__title_slug": "play-with-chips", + "question__hide": false, + "total_acs": 9854, + "total_submitted": 15457, + "frontend_question_id": 1217, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1322, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Moves to Reach Target with Rotations", + "question__title_slug": "minimum-moves-to-reach-target-with-rotations", + "question__hide": false, + "total_acs": 3298, + "total_submitted": 7627, + "frontend_question_id": 1210, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1321, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Get Equal Substrings Within Budget", + "question__title_slug": "get-equal-substrings-within-budget", + "question__hide": false, + "total_acs": 8655, + "total_submitted": 23233, + "frontend_question_id": 1208, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1320, + "question__article__live": true, + "question__article__slug": "remove-all-adjacent-duplicates-in-string-ii", + "question__title": "Remove All Adjacent Duplicates in String II", + "question__title_slug": "remove-all-adjacent-duplicates-in-string-ii", + "question__hide": false, + "total_acs": 11747, + "total_submitted": 20775, + "frontend_question_id": 1209, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1319, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Unique Number of Occurrences", + "question__title_slug": "unique-number-of-occurrences", + "question__hide": false, + "total_acs": 25066, + "total_submitted": 34804, + "frontend_question_id": 1207, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1309, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sort Items by Groups Respecting Dependencies", + "question__title_slug": "sort-items-by-groups-respecting-dependencies", + "question__hide": false, + "total_acs": 2208, + "total_submitted": 4945, + "frontend_question_id": 1203, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1308, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest String With Swaps", + "question__title_slug": "smallest-string-with-swaps", + "question__hide": false, + "total_acs": 6836, + "total_submitted": 16323, + "frontend_question_id": 1202, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1307, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Ugly Number III", + "question__title_slug": "ugly-number-iii", + "question__hide": false, + "total_acs": 5211, + "total_submitted": 20832, + "frontend_question_id": 1201, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1306, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Absolute Difference", + "question__title_slug": "minimum-absolute-difference", + "question__hide": false, + "total_acs": 18416, + "total_submitted": 27828, + "frontend_question_id": 1200, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1300, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Critical Connections in a Network", + "question__title_slug": "critical-connections-in-a-network", + "question__hide": false, + "total_acs": 18043, + "total_submitted": 37036, + "frontend_question_id": 1192, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1299, + "question__article__live": null, + "question__article__slug": null, + "question__title": "K-Concatenation Maximum Sum", + "question__title_slug": "k-concatenation-maximum-sum", + "question__hide": false, + "total_acs": 6992, + "total_submitted": 27580, + "frontend_question_id": 1191, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1298, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reverse Substrings Between Each Pair of Parentheses", + "question__title_slug": "reverse-substrings-between-each-pair-of-parentheses", + "question__hide": false, + "total_acs": 9381, + "total_submitted": 16119, + "frontend_question_id": 1190, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1297, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Number of Balloons", + "question__title_slug": "maximum-number-of-balloons", + "question__hide": false, + "total_acs": 17661, + "total_submitted": 28791, + "frontend_question_id": 1189, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1290, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Make Array Strictly Increasing", + "question__title_slug": "make-array-strictly-increasing", + "question__hide": false, + "total_acs": 3363, + "total_submitted": 8383, + "frontend_question_id": 1187, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1289, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Day of the Week", + "question__title_slug": "day-of-the-week", + "question__hide": false, + "total_acs": 11208, + "total_submitted": 17432, + "frontend_question_id": 1185, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1288, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Subarray Sum with One Deletion", + "question__title_slug": "maximum-subarray-sum-with-one-deletion", + "question__hide": false, + "total_acs": 8624, + "total_submitted": 24857, + "frontend_question_id": 1186, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1287, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Distance Between Bus Stops", + "question__title_slug": "distance-between-bus-stops", + "question__hide": false, + "total_acs": 12740, + "total_submitted": 22907, + "frontend_question_id": 1184, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1282, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Valid Words for Each Puzzle", + "question__title_slug": "number-of-valid-words-for-each-puzzle", + "question__hide": false, + "total_acs": 4106, + "total_submitted": 11298, + "frontend_question_id": 1178, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1281, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Can Make Palindrome from Substring", + "question__title_slug": "can-make-palindrome-from-substring", + "question__hide": false, + "total_acs": 6696, + "total_submitted": 20619, + "frontend_question_id": 1177, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1280, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Diet Plan Performance", + "question__title_slug": "diet-plan-performance", + "question__hide": false, + "total_acs": 6706, + "total_submitted": 13293, + "frontend_question_id": 1176, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1279, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Prime Arrangements", + "question__title_slug": "prime-arrangements", + "question__hide": false, + "total_acs": 7570, + "total_submitted": 15098, + "frontend_question_id": 1175, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1273, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Compare Strings by Frequency of the Smallest Character", + "question__title_slug": "compare-strings-by-frequency-of-the-smallest-character", + "question__hide": false, + "total_acs": 20650, + "total_submitted": 35550, + "frontend_question_id": 1170, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1272, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Invalid Transactions", + "question__title_slug": "invalid-transactions", + "question__hide": false, + "total_acs": 7463, + "total_submitted": 25746, + "frontend_question_id": 1169, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1271, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Web Crawler", + "question__title_slug": "web-crawler", + "question__hide": false, + "total_acs": 1499, + "total_submitted": 2292, + "frontend_question_id": 1236, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1270, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Dinner Plate Stacks", + "question__title_slug": "dinner-plate-stacks", + "question__hide": false, + "total_acs": 3901, + "total_submitted": 9723, + "frontend_question_id": 1172, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1267, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Zero Sum Consecutive Nodes from Linked List", + "question__title_slug": "remove-zero-sum-consecutive-nodes-from-linked-list", + "question__hide": false, + "total_acs": 7943, + "total_submitted": 19196, + "frontend_question_id": 1171, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1263, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Dice Rolls With Target Sum", + "question__title_slug": "number-of-dice-rolls-with-target-sum", + "question__hide": false, + "total_acs": 14947, + "total_submitted": 30666, + "frontend_question_id": 1155, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1262, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Online Majority Element In Subarray", + "question__title_slug": "online-majority-element-in-subarray", + "question__hide": false, + "total_acs": 3940, + "total_submitted": 11534, + "frontend_question_id": 1157, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1261, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Swap For Longest Repeated Character Substring", + "question__title_slug": "swap-for-longest-repeated-character-substring", + "question__hide": false, + "total_acs": 5625, + "total_submitted": 11937, + "frontend_question_id": 1156, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1260, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Day of the Year", + "question__title_slug": "day-of-the-year", + "question__hide": false, + "total_acs": 11113, + "total_submitted": 22736, + "frontend_question_id": 1154, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1251, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Chunked Palindrome Decomposition", + "question__title_slug": "longest-chunked-palindrome-decomposition", + "question__hide": false, + "total_acs": 6149, + "total_submitted": 10640, + "frontend_question_id": 1147, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1250, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Common Subsequence", + "question__title_slug": "longest-common-subsequence", + "question__hide": false, + "total_acs": 23858, + "total_submitted": 41569, + "frontend_question_id": 1143, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1249, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Snapshot Array", + "question__title_slug": "snapshot-array", + "question__hide": false, + "total_acs": 12038, + "total_submitted": 34843, + "frontend_question_id": 1146, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1248, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Tree Coloring Game", + "question__title_slug": "binary-tree-coloring-game", + "question__hide": false, + "total_acs": 9330, + "total_submitted": 18859, + "frontend_question_id": 1145, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1247, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Decrease Elements To Make Array Zigzag", + "question__title_slug": "decrease-elements-to-make-array-zigzag", + "question__hide": false, + "total_acs": 6188, + "total_submitted": 14238, + "frontend_question_id": 1144, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1240, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Stone Game II", + "question__title_slug": "stone-game-ii", + "question__hide": false, + "total_acs": 6133, + "total_submitted": 10213, + "frontend_question_id": 1140, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1239, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Largest 1-Bordered Square", + "question__title_slug": "largest-1-bordered-square", + "question__hide": false, + "total_acs": 5935, + "total_submitted": 13160, + "frontend_question_id": 1139, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1238, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Alphabet Board Path", + "question__title_slug": "alphabet-board-path", + "question__hide": false, + "total_acs": 8240, + "total_submitted": 18352, + "frontend_question_id": 1138, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1236, + "question__article__live": true, + "question__article__slug": "n-th-tribonacci-number", + "question__title": "N-th Tribonacci Number", + "question__title_slug": "n-th-tribonacci-number", + "question__hide": false, + "total_acs": 19856, + "total_submitted": 34439, + "frontend_question_id": 1137, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1233, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Ships in a Rectangle", + "question__title_slug": "number-of-ships-in-a-rectangle", + "question__hide": false, + "total_acs": 1461, + "total_submitted": 2252, + "frontend_question_id": 1274, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1230, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum of Absolute Value Expression", + "question__title_slug": "maximum-of-absolute-value-expression", + "question__hide": false, + "total_acs": 4559, + "total_submitted": 8639, + "frontend_question_id": 1131, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1229, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Path with Alternating Colors", + "question__title_slug": "shortest-path-with-alternating-colors", + "question__hide": false, + "total_acs": 7258, + "total_submitted": 19568, + "frontend_question_id": 1129, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1228, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Cost Tree From Leaf Values", + "question__title_slug": "minimum-cost-tree-from-leaf-values", + "question__hide": false, + "total_acs": 11744, + "total_submitted": 18688, + "frontend_question_id": 1130, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1227, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Equivalent Domino Pairs", + "question__title_slug": "number-of-equivalent-domino-pairs", + "question__hide": false, + "total_acs": 13811, + "total_submitted": 29857, + "frontend_question_id": 1128, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1220, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest Sufficient Team", + "question__title_slug": "smallest-sufficient-team", + "question__hide": false, + "total_acs": 4864, + "total_submitted": 10778, + "frontend_question_id": 1125, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1219, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Well-Performing Interval", + "question__title_slug": "longest-well-performing-interval", + "question__hide": false, + "total_acs": 7405, + "total_submitted": 23172, + "frontend_question_id": 1124, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1218, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Lowest Common Ancestor of Deepest Leaves", + "question__title_slug": "lowest-common-ancestor-of-deepest-leaves", + "question__hide": false, + "total_acs": 12374, + "total_submitted": 18894, + "frontend_question_id": 1123, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1217, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Relative Sort Array", + "question__title_slug": "relative-sort-array", + "question__hide": false, + "total_acs": 31366, + "total_submitted": 47132, + "frontend_question_id": 1122, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1213, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Handshakes That Don't Cross", + "question__title_slug": "handshakes-that-dont-cross", + "question__hide": false, + "total_acs": 1520, + "total_submitted": 2928, + "frontend_question_id": 1259, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1208, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Nesting Depth of Two Valid Parentheses Strings", + "question__title_slug": "maximum-nesting-depth-of-two-valid-parentheses-strings", + "question__hide": false, + "total_acs": 5359, + "total_submitted": 7929, + "frontend_question_id": 1111, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1207, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Delete Nodes And Return Forest", + "question__title_slug": "delete-nodes-and-return-forest", + "question__hide": false, + "total_acs": 26037, + "total_submitted": 40200, + "frontend_question_id": 1110, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1206, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Corporate Flight Bookings", + "question__title_slug": "corporate-flight-bookings", + "question__hide": false, + "total_acs": 11320, + "total_submitted": 22655, + "frontend_question_id": 1109, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1205, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Defanging an IP Address", + "question__title_slug": "defanging-an-ip-address", + "question__hide": false, + "total_acs": 97200, + "total_submitted": 114279, + "frontend_question_id": 1108, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1202, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Palindrome Removal", + "question__title_slug": "palindrome-removal", + "question__hide": false, + "total_acs": 1614, + "total_submitted": 3754, + "frontend_question_id": 1246, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1201, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Delete Tree Nodes", + "question__title_slug": "delete-tree-nodes", + "question__hide": false, + "total_acs": 2134, + "total_submitted": 3508, + "frontend_question_id": 1273, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1200, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Interval", + "question__title_slug": "remove-interval", + "question__hide": false, + "total_acs": 2445, + "total_submitted": 4490, + "frontend_question_id": 1272, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1199, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Hexspeak", + "question__title_slug": "hexspeak", + "question__hide": false, + "total_acs": 2717, + "total_submitted": 5250, + "frontend_question_id": 1271, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1197, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Parsing A Boolean Expression", + "question__title_slug": "parsing-a-boolean-expression", + "question__hide": false, + "total_acs": 6823, + "total_submitted": 11837, + "frontend_question_id": 1106, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1196, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Filling Bookcase Shelves", + "question__title_slug": "filling-bookcase-shelves", + "question__hide": false, + "total_acs": 8435, + "total_submitted": 14828, + "frontend_question_id": 1105, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1195, + "question__article__live": true, + "question__article__slug": "distribute-candies-to-people", + "question__title": "Distribute Candies to People", + "question__title_slug": "distribute-candies-to-people", + "question__hide": false, + "total_acs": 15821, + "total_submitted": 26344, + "frontend_question_id": 1103, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1194, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Path In Zigzag Labelled Binary Tree", + "question__title_slug": "path-in-zigzag-labelled-binary-tree", + "question__hide": false, + "total_acs": 10756, + "total_submitted": 15231, + "frontend_question_id": 1104, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1192, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Divide Chocolate", + "question__title_slug": "divide-chocolate", + "question__hide": false, + "total_acs": 3495, + "total_submitted": 6918, + "frontend_question_id": 1231, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1191, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Synonymous Sentences", + "question__title_slug": "synonymous-sentences", + "question__hide": false, + "total_acs": 1835, + "total_submitted": 3091, + "frontend_question_id": 1258, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1190, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest Common Region", + "question__title_slug": "smallest-common-region", + "question__hide": false, + "total_acs": 2431, + "total_submitted": 4505, + "frontend_question_id": 1257, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1189, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Encode Number", + "question__title_slug": "encode-number", + "question__hide": false, + "total_acs": 2391, + "total_submitted": 3787, + "frontend_question_id": 1256, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1188, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Brace Expansion II", + "question__title_slug": "brace-expansion-ii", + "question__hide": false, + "total_acs": 7348, + "total_submitted": 12110, + "frontend_question_id": 1096, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1185, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find in Mountain Array", + "question__title_slug": "find-in-mountain-array", + "question__hide": false, + "total_acs": 6020, + "total_submitted": 17240, + "frontend_question_id": 1095, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1184, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Car Pooling", + "question__title_slug": "car-pooling", + "question__hide": false, + "total_acs": 17008, + "total_submitted": 29907, + "frontend_question_id": 1094, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1183, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Statistics from a Large Sample", + "question__title_slug": "statistics-from-a-large-sample", + "question__hide": false, + "total_acs": 5813, + "total_submitted": 12856, + "frontend_question_id": 1093, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1178, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Palindrome III", + "question__title_slug": "valid-palindrome-iii", + "question__hide": false, + "total_acs": 3565, + "total_submitted": 8280, + "frontend_question_id": 1216, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1177, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Tree Diameter", + "question__title_slug": "tree-diameter", + "question__hide": false, + "total_acs": 3067, + "total_submitted": 5607, + "frontend_question_id": 1245, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1176, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design A Leaderboard", + "question__title_slug": "design-a-leaderboard", + "question__hide": false, + "total_acs": 2828, + "total_submitted": 5249, + "frontend_question_id": 1244, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1175, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Array Transformation", + "question__title_slug": "array-transformation", + "question__hide": false, + "total_acs": 3547, + "total_submitted": 6784, + "frontend_question_id": 1243, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1171, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Path in Binary Matrix", + "question__title_slug": "shortest-path-in-binary-matrix", + "question__hide": false, + "total_acs": 14642, + "total_submitted": 39954, + "frontend_question_id": 1091, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1170, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Common Supersequence ", + "question__title_slug": "shortest-common-supersequence", + "question__hide": false, + "total_acs": 6026, + "total_submitted": 12094, + "frontend_question_id": 1092, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1169, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Largest Values From Labels", + "question__title_slug": "largest-values-from-labels", + "question__hide": false, + "total_acs": 7964, + "total_submitted": 13750, + "frontend_question_id": 1090, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1168, + "question__article__live": true, + "question__article__slug": "duplicate-zeros", + "question__title": "Duplicate Zeros", + "question__title_slug": "duplicate-zeros", + "question__hide": false, + "total_acs": 24186, + "total_submitted": 41503, + "frontend_question_id": 1089, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1167, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Time to Build Blocks", + "question__title_slug": "minimum-time-to-build-blocks", + "question__hide": false, + "total_acs": 1358, + "total_submitted": 4074, + "frontend_question_id": 1199, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1166, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Toss Strange Coins", + "question__title_slug": "toss-strange-coins", + "question__hide": false, + "total_acs": 2546, + "total_submitted": 5739, + "frontend_question_id": 1230, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1165, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Meeting Scheduler", + "question__title_slug": "meeting-scheduler", + "question__hide": false, + "total_acs": 3406, + "total_submitted": 7976, + "frontend_question_id": 1229, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1164, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Missing Number In Arithmetic Progression", + "question__title_slug": "missing-number-in-arithmetic-progression", + "question__hide": false, + "total_acs": 4335, + "total_submitted": 8237, + "frontend_question_id": 1228, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1160, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Letter Tile Possibilities", + "question__title_slug": "letter-tile-possibilities", + "question__hide": false, + "total_acs": 17669, + "total_submitted": 23721, + "frontend_question_id": 1079, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1159, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest Subsequence of Distinct Characters", + "question__title_slug": "smallest-subsequence-of-distinct-characters", + "question__hide": false, + "total_acs": 6058, + "total_submitted": 13403, + "frontend_question_id": 1081, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1157, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Insufficient Nodes in Root to Leaf Paths", + "question__title_slug": "insufficient-nodes-in-root-to-leaf-paths", + "question__hide": false, + "total_acs": 8352, + "total_submitted": 18352, + "frontend_question_id": 1080, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1156, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Occurrences After Bigram", + "question__title_slug": "occurrences-after-bigram", + "question__hide": false, + "total_acs": 18388, + "total_submitted": 28493, + "frontend_question_id": 1078, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1152, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Number of Ones", + "question__title_slug": "maximum-number-of-ones", + "question__hide": false, + "total_acs": 875, + "total_submitted": 1788, + "frontend_question_id": 1183, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1151, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Stepping Numbers", + "question__title_slug": "stepping-numbers", + "question__hide": false, + "total_acs": 3025, + "total_submitted": 8206, + "frontend_question_id": 1215, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1150, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Two Sum BSTs", + "question__title_slug": "two-sum-bsts", + "question__hide": false, + "total_acs": 5098, + "total_submitted": 7754, + "frontend_question_id": 1214, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1149, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Intersection of Three Sorted Arrays", + "question__title_slug": "intersection-of-three-sorted-arrays", + "question__hide": false, + "total_acs": 8024, + "total_submitted": 10412, + "frontend_question_id": 1213, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1148, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Adding Two Negabinary Numbers", + "question__title_slug": "adding-two-negabinary-numbers", + "question__hide": false, + "total_acs": 4747, + "total_submitted": 14446, + "frontend_question_id": 1073, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1147, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flip Columns For Maximum Number of Equal Rows", + "question__title_slug": "flip-columns-for-maximum-number-of-equal-rows", + "question__hide": false, + "total_acs": 7241, + "total_submitted": 12155, + "frontend_question_id": 1072, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1146, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Greatest Common Divisor of Strings", + "question__title_slug": "greatest-common-divisor-of-strings", + "question__hide": false, + "total_acs": 15368, + "total_submitted": 28578, + "frontend_question_id": 1071, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1145, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Submatrices That Sum to Target", + "question__title_slug": "number-of-submatrices-that-sum-to-target", + "question__hide": false, + "total_acs": 6738, + "total_submitted": 11319, + "frontend_question_id": 1074, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1144, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Optimize Water Distribution in a Village", + "question__title_slug": "optimize-water-distribution-in-a-village", + "question__hide": false, + "total_acs": 3917, + "total_submitted": 6763, + "frontend_question_id": 1168, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1143, + "question__article__live": true, + "question__article__slug": "find-smallest-common-element-in-all-rows", + "question__title": "Find Smallest Common Element in All Rows", + "question__title_slug": "find-smallest-common-element-in-all-rows", + "question__hide": false, + "total_acs": 4905, + "total_submitted": 6634, + "frontend_question_id": 1198, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1142, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Knight Moves", + "question__title_slug": "minimum-knight-moves", + "question__hide": false, + "total_acs": 5888, + "total_submitted": 18832, + "frontend_question_id": 1197, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1141, + "question__article__live": null, + "question__article__slug": null, + "question__title": "How Many Apples Can You Put into the Basket", + "question__title_slug": "how-many-apples-can-you-put-into-the-basket", + "question__hide": false, + "total_acs": 4584, + "total_submitted": 6740, + "frontend_question_id": 1196, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1140, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Distant Barcodes", + "question__title_slug": "distant-barcodes", + "question__hide": false, + "total_acs": 9407, + "total_submitted": 23367, + "frontend_question_id": 1054, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1139, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Previous Permutation With One Swap", + "question__title_slug": "previous-permutation-with-one-swap", + "question__hide": false, + "total_acs": 7569, + "total_submitted": 16065, + "frontend_question_id": 1053, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1138, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Grumpy Bookstore Owner", + "question__title_slug": "grumpy-bookstore-owner", + "question__hide": false, + "total_acs": 12897, + "total_submitted": 24120, + "frontend_question_id": 1052, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1137, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Height Checker", + "question__title_slug": "height-checker", + "question__hide": false, + "total_acs": 31928, + "total_submitted": 46798, + "frontend_question_id": 1051, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1134, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Distance to Target Color", + "question__title_slug": "shortest-distance-to-target-color", + "question__hide": false, + "total_acs": 3111, + "total_submitted": 6017, + "frontend_question_id": 1182, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1133, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Last Substring in Lexicographical Order", + "question__title_slug": "last-substring-in-lexicographical-order", + "question__hide": false, + "total_acs": 6531, + "total_submitted": 20997, + "frontend_question_id": 1163, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1132, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Before and After Puzzle", + "question__title_slug": "before-and-after-puzzle", + "question__hide": false, + "total_acs": 4237, + "total_submitted": 9690, + "frontend_question_id": 1181, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1131, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Substrings with Only One Distinct Letter", + "question__title_slug": "count-substrings-with-only-one-distinct-letter", + "question__hide": false, + "total_acs": 4970, + "total_submitted": 6474, + "frontend_question_id": 1180, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1130, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Last Stone Weight II", + "question__title_slug": "last-stone-weight-ii", + "question__hide": false, + "total_acs": 8071, + "total_submitted": 19246, + "frontend_question_id": 1049, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1129, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest String Chain", + "question__title_slug": "longest-string-chain", + "question__hide": false, + "total_acs": 22828, + "total_submitted": 44187, + "frontend_question_id": 1048, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1128, + "question__article__live": true, + "question__article__slug": "remove-all-adjacent-duplicates-in-string", + "question__title": "Remove All Adjacent Duplicates In String", + "question__title_slug": "remove-all-adjacent-duplicates-in-string", + "question__hide": false, + "total_acs": 40310, + "total_submitted": 61474, + "frontend_question_id": 1047, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1127, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Last Stone Weight", + "question__title_slug": "last-stone-weight", + "question__hide": false, + "total_acs": 31553, + "total_submitted": 50490, + "frontend_question_id": 1046, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1126, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Cost to Connect Sticks", + "question__title_slug": "minimum-cost-to-connect-sticks", + "question__hide": false, + "total_acs": 9144, + "total_submitted": 14899, + "frontend_question_id": 1167, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1125, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design File System", + "question__title_slug": "design-file-system", + "question__hide": false, + "total_acs": 3719, + "total_submitted": 6478, + "frontend_question_id": 1166, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1124, + "question__article__live": null, + "question__article__slug": null, + "question__title": "String Transforms Into Another String", + "question__title_slug": "string-transforms-into-another-string", + "question__hide": false, + "total_acs": 5779, + "total_submitted": 17055, + "frontend_question_id": 1153, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1123, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Single-Row Keyboard", + "question__title_slug": "single-row-keyboard", + "question__hide": false, + "total_acs": 13151, + "total_submitted": 15599, + "frontend_question_id": 1165, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1122, + "question__article__live": true, + "question__article__slug": "longest-duplicate-substring", + "question__title": "Longest Duplicate Substring", + "question__title_slug": "longest-duplicate-substring", + "question__hide": false, + "total_acs": 4652, + "total_submitted": 19514, + "frontend_question_id": 1044, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1121, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Partition Array for Maximum Sum", + "question__title_slug": "partition-array-for-maximum-sum", + "question__hide": false, + "total_acs": 10887, + "total_submitted": 17254, + "frontend_question_id": 1043, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1120, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flower Planting With No Adjacent", + "question__title_slug": "flower-planting-with-no-adjacent", + "question__hide": false, + "total_acs": 14054, + "total_submitted": 29392, + "frontend_question_id": 1042, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1119, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Robot Bounded In Circle", + "question__title_slug": "robot-bounded-in-circle", + "question__hide": false, + "total_acs": 10404, + "total_submitted": 22174, + "frontend_question_id": 1041, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1118, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Divide Array Into Increasing Sequences", + "question__title_slug": "divide-array-into-increasing-sequences", + "question__hide": false, + "total_acs": 1933, + "total_submitted": 3484, + "frontend_question_id": 1121, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1117, + "question__article__live": null, + "question__article__slug": null, + "question__title": "As Far from Land as Possible", + "question__title_slug": "as-far-from-land-as-possible", + "question__hide": false, + "total_acs": 8851, + "total_submitted": 21851, + "frontend_question_id": 1162, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1116, + "question__article__live": true, + "question__article__slug": "maximum-level-sum-of-a-binary-tree", + "question__title": "Maximum Level Sum of a Binary Tree", + "question__title_slug": "maximum-level-sum-of-a-binary-tree", + "question__hide": false, + "total_acs": 19890, + "total_submitted": 28063, + "frontend_question_id": 1161, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1115, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Boomerang", + "question__title_slug": "valid-boomerang", + "question__hide": false, + "total_acs": 11999, + "total_submitted": 32003, + "frontend_question_id": 1037, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1114, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Search Tree to Greater Sum Tree", + "question__title_slug": "binary-search-tree-to-greater-sum-tree", + "question__hide": false, + "total_acs": 27931, + "total_submitted": 35596, + "frontend_question_id": 1038, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1113, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Moving Stones Until Consecutive II", + "question__title_slug": "moving-stones-until-consecutive-ii", + "question__hide": false, + "total_acs": 3091, + "total_submitted": 6149, + "frontend_question_id": 1040, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1112, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Words That Can Be Formed by Characters", + "question__title_slug": "find-words-that-can-be-formed-by-characters", + "question__hide": false, + "total_acs": 24259, + "total_submitted": 36455, + "frontend_question_id": 1160, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1111, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Score Triangulation of Polygon", + "question__title_slug": "minimum-score-triangulation-of-polygon", + "question__hide": false, + "total_acs": 5218, + "total_submitted": 11698, + "frontend_question_id": 1039, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1108, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Analyze User Website Visit Pattern", + "question__title_slug": "analyze-user-website-visit-pattern", + "question__hide": false, + "total_acs": 1810, + "total_submitted": 4565, + "frontend_question_id": 1152, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1107, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Swaps to Group All 1's Together", + "question__title_slug": "minimum-swaps-to-group-all-1s-together", + "question__hide": false, + "total_acs": 3047, + "total_submitted": 5287, + "frontend_question_id": 1151, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1106, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Escape a Large Maze", + "question__title_slug": "escape-a-large-maze", + "question__hide": false, + "total_acs": 6906, + "total_submitted": 19597, + "frontend_question_id": 1036, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1105, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Uncrossed Lines", + "question__title_slug": "uncrossed-lines", + "question__hide": false, + "total_acs": 9274, + "total_submitted": 17552, + "frontend_question_id": 1035, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1104, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Coloring A Border", + "question__title_slug": "coloring-a-border", + "question__hide": false, + "total_acs": 6941, + "total_submitted": 15953, + "frontend_question_id": 1034, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1103, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Moving Stones Until Consecutive", + "question__title_slug": "moving-stones-until-consecutive", + "question__hide": false, + "total_acs": 8992, + "total_submitted": 23140, + "frontend_question_id": 1033, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1102, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Check If a Number Is Majority Element in a Sorted Array", + "question__title_slug": "check-if-a-number-is-majority-element-in-a-sorted-array", + "question__hide": false, + "total_acs": 6334, + "total_submitted": 10407, + "frontend_question_id": 1150, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1101, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Parallel Courses", + "question__title_slug": "parallel-courses", + "question__hide": false, + "total_acs": 2932, + "total_submitted": 4979, + "frontend_question_id": 1136, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1100, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Connecting Cities With Minimum Cost", + "question__title_slug": "connecting-cities-with-minimum-cost", + "question__hide": false, + "total_acs": 6483, + "total_submitted": 11751, + "frontend_question_id": 1135, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1099, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Path With Maximum Minimum Value", + "question__title_slug": "path-with-maximum-minimum-value", + "question__hide": false, + "total_acs": 5954, + "total_submitted": 12480, + "frontend_question_id": 1102, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1098, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Largest Unique Number", + "question__title_slug": "largest-unique-number", + "question__hide": false, + "total_acs": 5967, + "total_submitted": 8971, + "frontend_question_id": 1133, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1097, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Stream of Characters", + "question__title_slug": "stream-of-characters", + "question__hide": false, + "total_acs": 11472, + "total_submitted": 25156, + "frontend_question_id": 1032, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1096, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Sum of Two Non-Overlapping Subarrays", + "question__title_slug": "maximum-sum-of-two-non-overlapping-subarrays", + "question__hide": false, + "total_acs": 10995, + "total_submitted": 19922, + "frontend_question_id": 1031, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1095, + "question__article__live": true, + "question__article__slug": "two-city-scheduling", + "question__title": "Two City Scheduling", + "question__title_slug": "two-city-scheduling", + "question__hide": false, + "total_acs": 20738, + "total_submitted": 37533, + "frontend_question_id": 1029, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1094, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Matrix Cells in Distance Order", + "question__title_slug": "matrix-cells-in-distance-order", + "question__hide": false, + "total_acs": 16117, + "total_submitted": 25043, + "frontend_question_id": 1030, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1093, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Recover a Tree From Preorder Traversal", + "question__title_slug": "recover-a-tree-from-preorder-traversal", + "question__hide": false, + "total_acs": 12185, + "total_submitted": 17535, + "frontend_question_id": 1028, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1092, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Difference Between Node and Ancestor", + "question__title_slug": "maximum-difference-between-node-and-ancestor", + "question__hide": false, + "total_acs": 18029, + "total_submitted": 29039, + "frontend_question_id": 1026, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1091, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Average Subtree", + "question__title_slug": "maximum-average-subtree", + "question__hide": false, + "total_acs": 6010, + "total_submitted": 9742, + "frontend_question_id": 1120, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1090, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Armstrong Number", + "question__title_slug": "armstrong-number", + "question__hide": false, + "total_acs": 6925, + "total_submitted": 8909, + "frontend_question_id": 1134, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1089, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Vowels from a String", + "question__title_slug": "remove-vowels-from-a-string", + "question__hide": false, + "total_acs": 17532, + "total_submitted": 19857, + "frontend_question_id": 1119, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1088, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Days in a Month", + "question__title_slug": "number-of-days-in-a-month", + "question__hide": false, + "total_acs": 2836, + "total_submitted": 4983, + "frontend_question_id": 1118, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1087, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Arithmetic Sequence", + "question__title_slug": "longest-arithmetic-sequence", + "question__hide": false, + "total_acs": 23020, + "total_submitted": 43793, + "frontend_question_id": 1027, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1086, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Divisor Game", + "question__title_slug": "divisor-game", + "question__hide": false, + "total_acs": 31525, + "total_submitted": 48181, + "frontend_question_id": 1025, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1085, + "question__article__live": null, + "question__article__slug": null, + "question__title": "The Earliest Moment When Everyone Become Friends", + "question__title_slug": "the-earliest-moment-when-everyone-become-friends", + "question__hide": false, + "total_acs": 3024, + "total_submitted": 4657, + "frontend_question_id": 1101, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1084, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find K-Length Substrings With No Repeated Characters", + "question__title_slug": "find-k-length-substrings-with-no-repeated-characters", + "question__hide": false, + "total_acs": 5077, + "total_submitted": 7142, + "frontend_question_id": 1100, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1083, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Two Sum Less Than K", + "question__title_slug": "two-sum-less-than-k", + "question__hide": false, + "total_acs": 17408, + "total_submitted": 28896, + "frontend_question_id": 1099, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1082, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sum of Digits in the Minimum Number", + "question__title_slug": "sum-of-digits-in-the-minimum-number", + "question__hide": false, + "total_acs": 7454, + "total_submitted": 10058, + "frontend_question_id": 1085, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1081, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Video Stitching", + "question__title_slug": "video-stitching", + "question__hide": false, + "total_acs": 14221, + "total_submitted": 29845, + "frontend_question_id": 1024, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1080, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Camelcase Matching", + "question__title_slug": "camelcase-matching", + "question__hide": false, + "total_acs": 11883, + "total_submitted": 21570, + "frontend_question_id": 1023, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1079, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sum of Root To Leaf Binary Numbers", + "question__title_slug": "sum-of-root-to-leaf-binary-numbers", + "question__hide": false, + "total_acs": 24406, + "total_submitted": 38854, + "frontend_question_id": 1022, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1078, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Outermost Parentheses", + "question__title_slug": "remove-outermost-parentheses", + "question__hide": false, + "total_acs": 59223, + "total_submitted": 78030, + "frontend_question_id": 1021, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1077, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Confusing Number II", + "question__title_slug": "confusing-number-ii", + "question__hide": false, + "total_acs": 3633, + "total_submitted": 9191, + "frontend_question_id": 1088, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1076, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Brace Expansion", + "question__title_slug": "brace-expansion", + "question__hide": false, + "total_acs": 11948, + "total_submitted": 19606, + "frontend_question_id": 1087, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1075, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Index Pairs of a String", + "question__title_slug": "index-pairs-of-a-string", + "question__hide": false, + "total_acs": 3963, + "total_submitted": 6812, + "frontend_question_id": 1065, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1074, + "question__article__live": null, + "question__article__slug": null, + "question__title": "High Five", + "question__title_slug": "high-five", + "question__hide": false, + "total_acs": 12983, + "total_submitted": 17109, + "frontend_question_id": 1086, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1073, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Enclaves", + "question__title_slug": "number-of-enclaves", + "question__hide": false, + "total_acs": 11269, + "total_submitted": 20427, + "frontend_question_id": 1020, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1072, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Next Greater Node In Linked List", + "question__title_slug": "next-greater-node-in-linked-list", + "question__hide": false, + "total_acs": 24881, + "total_submitted": 43919, + "frontend_question_id": 1019, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1071, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Prefix Divisible By 5", + "question__title_slug": "binary-prefix-divisible-by-5", + "question__hide": false, + "total_acs": 15825, + "total_submitted": 33742, + "frontend_question_id": 1018, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1070, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Convert to Base -2", + "question__title_slug": "convert-to-base-2", + "question__hide": false, + "total_acs": 8213, + "total_submitted": 14378, + "frontend_question_id": 1017, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1069, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Confusing Number", + "question__title_slug": "confusing-number", + "question__hide": false, + "total_acs": 4992, + "total_submitted": 9804, + "frontend_question_id": 1056, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1068, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Digit Count in Range", + "question__title_slug": "digit-count-in-range", + "question__hide": false, + "total_acs": 886, + "total_submitted": 2293, + "frontend_question_id": 1067, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1067, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Campus Bikes II", + "question__title_slug": "campus-bikes-ii", + "question__hide": false, + "total_acs": 13559, + "total_submitted": 25529, + "frontend_question_id": 1066, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1066, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Fixed Point", + "question__title_slug": "fixed-point", + "question__hide": false, + "total_acs": 12166, + "total_submitted": 17277, + "frontend_question_id": 1064, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1065, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary String With Substrings Representing 1 To N", + "question__title_slug": "binary-string-with-substrings-representing-1-to-n", + "question__hide": false, + "total_acs": 10535, + "total_submitted": 17855, + "frontend_question_id": 1016, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1064, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest Integer Divisible by K", + "question__title_slug": "smallest-integer-divisible-by-k", + "question__hide": false, + "total_acs": 7772, + "total_submitted": 25634, + "frontend_question_id": 1015, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1063, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Best Sightseeing Pair", + "question__title_slug": "best-sightseeing-pair", + "question__hide": false, + "total_acs": 12059, + "total_submitted": 23526, + "frontend_question_id": 1014, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1062, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Partition Array Into Three Parts With Equal Sum", + "question__title_slug": "partition-array-into-three-parts-with-equal-sum", + "question__hide": false, + "total_acs": 22417, + "total_submitted": 39527, + "frontend_question_id": 1013, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1061, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Valid Subarrays", + "question__title_slug": "number-of-valid-subarrays", + "question__hide": false, + "total_acs": 2010, + "total_submitted": 2819, + "frontend_question_id": 1063, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1060, + "question__article__live": true, + "question__article__slug": "longest-repeating-substring", + "question__title": "Longest Repeating Substring", + "question__title_slug": "longest-repeating-substring", + "question__hide": false, + "total_acs": 3931, + "total_submitted": 7405, + "frontend_question_id": 1062, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1059, + "question__article__live": true, + "question__article__slug": "missing-element-in-sorted-array", + "question__title": "Missing Element in Sorted Array", + "question__title_slug": "missing-element-in-sorted-array", + "question__hide": false, + "total_acs": 5556, + "total_submitted": 10455, + "frontend_question_id": 1060, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1058, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Lexicographically Smallest Equivalent String", + "question__title_slug": "lexicographically-smallest-equivalent-string", + "question__hide": false, + "total_acs": 1838, + "total_submitted": 2892, + "frontend_question_id": 1061, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1057, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Numbers With Repeated Digits", + "question__title_slug": "numbers-with-repeated-digits", + "question__hide": false, + "total_acs": 3780, + "total_submitted": 10441, + "frontend_question_id": 1012, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1056, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Capacity To Ship Packages Within D Days", + "question__title_slug": "capacity-to-ship-packages-within-d-days", + "question__hide": false, + "total_acs": 22936, + "total_submitted": 41123, + "frontend_question_id": 1011, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1055, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Pairs of Songs With Total Durations Divisible by 60", + "question__title_slug": "pairs-of-songs-with-total-durations-divisible-by-60", + "question__hide": false, + "total_acs": 21803, + "total_submitted": 46767, + "frontend_question_id": 1010, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1054, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Complement of Base 10 Integer", + "question__title_slug": "complement-of-base-10-integer", + "question__hide": false, + "total_acs": 17836, + "total_submitted": 30086, + "frontend_question_id": 1009, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1053, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimize Rounding Error to Meet Target", + "question__title_slug": "minimize-rounding-error-to-meet-target", + "question__hide": false, + "total_acs": 1817, + "total_submitted": 4493, + "frontend_question_id": 1058, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1052, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Campus Bikes", + "question__title_slug": "campus-bikes", + "question__hide": false, + "total_acs": 19991, + "total_submitted": 34319, + "frontend_question_id": 1057, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1051, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Way to Form String", + "question__title_slug": "shortest-way-to-form-string", + "question__hide": false, + "total_acs": 15691, + "total_submitted": 27344, + "frontend_question_id": 1055, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1050, + "question__article__live": true, + "question__article__slug": "construct-bst-from-preorder-traversal", + "question__title": "Construct Binary Search Tree from Preorder Traversal", + "question__title_slug": "construct-binary-search-tree-from-preorder-traversal", + "question__hide": false, + "total_acs": 30788, + "total_submitted": 41462, + "frontend_question_id": 1008, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1049, + "question__article__live": true, + "question__article__slug": "minimum-domino-rotations-for-equal-row", + "question__title": "Minimum Domino Rotations For Equal Row", + "question__title_slug": "minimum-domino-rotations-for-equal-row", + "question__hide": false, + "total_acs": 42638, + "total_submitted": 83902, + "frontend_question_id": 1007, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1048, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Clumsy Factorial", + "question__title_slug": "clumsy-factorial", + "question__hide": false, + "total_acs": 9841, + "total_submitted": 18428, + "frontend_question_id": 1006, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1047, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximize Sum Of Array After K Negations", + "question__title_slug": "maximize-sum-of-array-after-k-negations", + "question__hide": false, + "total_acs": 18388, + "total_submitted": 36487, + "frontend_question_id": 1005, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1046, + "question__article__live": true, + "question__article__slug": "max-consecutive-ones-iii", + "question__title": "Max Consecutive Ones III", + "question__title_slug": "max-consecutive-ones-iii", + "question__hide": false, + "total_acs": 26121, + "total_submitted": 47016, + "frontend_question_id": 1004, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1045, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Check If Word Is Valid After Substitutions", + "question__title_slug": "check-if-word-is-valid-after-substitutions", + "question__hide": false, + "total_acs": 14196, + "total_submitted": 26631, + "frontend_question_id": 1003, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1044, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Common Characters", + "question__title_slug": "find-common-characters", + "question__hide": false, + "total_acs": 45752, + "total_submitted": 69236, + "frontend_question_id": 1002, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1043, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Grid Illumination", + "question__title_slug": "grid-illumination", + "question__hide": false, + "total_acs": 6340, + "total_submitted": 18153, + "frontend_question_id": 1001, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1042, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Cost to Merge Stones", + "question__title_slug": "minimum-cost-to-merge-stones", + "question__hide": false, + "total_acs": 8841, + "total_submitted": 23784, + "frontend_question_id": 1000, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1041, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Available Captures for Rook", + "question__title_slug": "available-captures-for-rook", + "question__hide": false, + "total_acs": 21035, + "total_submitted": 31991, + "frontend_question_id": 999, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1040, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Binary Tree II", + "question__title_slug": "maximum-binary-tree-ii", + "question__hide": false, + "total_acs": 11528, + "total_submitted": 18708, + "frontend_question_id": 998, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1039, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find the Town Judge", + "question__title_slug": "find-the-town-judge", + "question__hide": false, + "total_acs": 36620, + "total_submitted": 74210, + "frontend_question_id": 997, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1038, + "question__article__live": true, + "question__article__slug": "number-of-squareful-arrays", + "question__title": "Number of Squareful Arrays", + "question__title_slug": "number-of-squareful-arrays", + "question__hide": false, + "total_acs": 8638, + "total_submitted": 18241, + "frontend_question_id": 996, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1037, + "question__article__live": true, + "question__article__slug": "minimum-number-of-k-consecutive-bit-flips", + "question__title": "Minimum Number of K Consecutive Bit Flips", + "question__title_slug": "minimum-number-of-k-consecutive-bit-flips", + "question__hide": false, + "total_acs": 6881, + "total_submitted": 14882, + "frontend_question_id": 995, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1036, + "question__article__live": true, + "question__article__slug": "rotting-oranges", + "question__title": "Rotting Oranges", + "question__title_slug": "rotting-oranges", + "question__hide": false, + "total_acs": 30339, + "total_submitted": 65337, + "frontend_question_id": 994, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1035, + "question__article__live": true, + "question__article__slug": "cousins-in-binary-tree", + "question__title": "Cousins in Binary Tree", + "question__title_slug": "cousins-in-binary-tree", + "question__hide": false, + "total_acs": 33057, + "total_submitted": 63573, + "frontend_question_id": 993, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1034, + "question__article__live": true, + "question__article__slug": "subarrays-with-k-different-integers", + "question__title": "Subarrays with K Different Integers", + "question__title_slug": "subarrays-with-k-different-integers", + "question__hide": false, + "total_acs": 15634, + "total_submitted": 34063, + "frontend_question_id": 992, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1033, + "question__article__live": true, + "question__article__slug": "broken-calculator", + "question__title": "Broken Calculator", + "question__title_slug": "broken-calculator", + "question__hide": false, + "total_acs": 10602, + "total_submitted": 24729, + "frontend_question_id": 991, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1032, + "question__article__live": true, + "question__article__slug": "satisfiability-of-equality-equations", + "question__title": "Satisfiability of Equality Equations", + "question__title_slug": "satisfiability-of-equality-equations", + "question__hide": false, + "total_acs": 11491, + "total_submitted": 27418, + "frontend_question_id": 990, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1031, + "question__article__live": true, + "question__article__slug": "add-to-array-form-of-integer", + "question__title": "Add to Array-Form of Integer", + "question__title_slug": "add-to-array-form-of-integer", + "question__hide": false, + "total_acs": 27212, + "total_submitted": 61777, + "frontend_question_id": 989, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1030, + "question__article__live": true, + "question__article__slug": "smallest-string-starting-from-leaf", + "question__title": "Smallest String Starting From Leaf", + "question__title_slug": "smallest-string-starting-from-leaf", + "question__hide": false, + "total_acs": 17132, + "total_submitted": 38243, + "frontend_question_id": 988, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1029, + "question__article__live": true, + "question__article__slug": "vertical-order-traversal-of-a-binary-tree", + "question__title": "Vertical Order Traversal of a Binary Tree", + "question__title_slug": "vertical-order-traversal-of-a-binary-tree", + "question__hide": false, + "total_acs": 24373, + "total_submitted": 72485, + "frontend_question_id": 987, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1028, + "question__article__live": true, + "question__article__slug": "interval-list-intersections", + "question__title": "Interval List Intersections", + "question__title_slug": "interval-list-intersections", + "question__hide": false, + "total_acs": 43941, + "total_submitted": 68013, + "frontend_question_id": 986, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1027, + "question__article__live": true, + "question__article__slug": "sum-of-even-numbers-after-queries", + "question__title": "Sum of Even Numbers After Queries", + "question__title_slug": "sum-of-even-numbers-after-queries", + "question__hide": false, + "total_acs": 31474, + "total_submitted": 50443, + "frontend_question_id": 985, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1026, + "question__article__live": true, + "question__article__slug": "string-without-aaa-or-bbb", + "question__title": "String Without AAA or BBB", + "question__title_slug": "string-without-aaa-or-bbb", + "question__hide": false, + "total_acs": 12903, + "total_submitted": 36685, + "frontend_question_id": 984, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1025, + "question__article__live": true, + "question__article__slug": "minimum-cost-for-tickets", + "question__title": "Minimum Cost For Tickets", + "question__title_slug": "minimum-cost-for-tickets", + "question__hide": false, + "total_acs": 26682, + "total_submitted": 46088, + "frontend_question_id": 983, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1024, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Triples with Bitwise AND Equal To Zero", + "question__title_slug": "triples-with-bitwise-and-equal-to-zero", + "question__hide": false, + "total_acs": 6070, + "total_submitted": 11063, + "frontend_question_id": 982, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1023, + "question__article__live": true, + "question__article__slug": "time-based-key-value-store", + "question__title": "Time Based Key-Value Store", + "question__title_slug": "time-based-key-value-store", + "question__hide": false, + "total_acs": 37970, + "total_submitted": 73275, + "frontend_question_id": 981, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1022, + "question__article__live": true, + "question__article__slug": "unique-paths-iii", + "question__title": "Unique Paths III", + "question__title_slug": "unique-paths-iii", + "question__hide": false, + "total_acs": 19834, + "total_submitted": 27677, + "frontend_question_id": 980, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1021, + "question__article__live": true, + "question__article__slug": "distribute-coins-in-binary-tree", + "question__title": "Distribute Coins in Binary Tree", + "question__title_slug": "distribute-coins-in-binary-tree", + "question__hide": false, + "total_acs": 25185, + "total_submitted": 36962, + "frontend_question_id": 979, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1020, + "question__article__live": true, + "question__article__slug": "longest-turbulent-subarray", + "question__title": "Longest Turbulent Subarray", + "question__title_slug": "longest-turbulent-subarray", + "question__hide": false, + "total_acs": 17312, + "total_submitted": 37628, + "frontend_question_id": 978, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1019, + "question__article__live": true, + "question__article__slug": "squares-of-a-sorted-array", + "question__title": "Squares of a Sorted Array", + "question__title_slug": "squares-of-a-sorted-array", + "question__hide": false, + "total_acs": 131150, + "total_submitted": 182448, + "frontend_question_id": 977, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1018, + "question__article__live": true, + "question__article__slug": "largest-perimeter-triangle", + "question__title": "Largest Perimeter Triangle", + "question__title_slug": "largest-perimeter-triangle", + "question__hide": false, + "total_acs": 23524, + "total_submitted": 41112, + "frontend_question_id": 976, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1017, + "question__article__live": true, + "question__article__slug": "odd-even-jump", + "question__title": "Odd Even Jump", + "question__title_slug": "odd-even-jump", + "question__hide": false, + "total_acs": 21085, + "total_submitted": 47393, + "frontend_question_id": 975, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1016, + "question__article__live": true, + "question__article__slug": "subarray-sums-divisible-by-k", + "question__title": "Subarray Sums Divisible by K", + "question__title_slug": "subarray-sums-divisible-by-k", + "question__hide": false, + "total_acs": 21301, + "total_submitted": 45149, + "frontend_question_id": 974, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1014, + "question__article__live": true, + "question__article__slug": "k-closest-points-to-origin", + "question__title": "K Closest Points to Origin", + "question__title_slug": "k-closest-points-to-origin", + "question__hide": false, + "total_acs": 152114, + "total_submitted": 247418, + "frontend_question_id": 973, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1013, + "question__article__live": true, + "question__article__slug": "fibonacci-number", + "question__title": "Fibonacci Number", + "question__title_slug": "fibonacci-number", + "question__hide": false, + "total_acs": 125692, + "total_submitted": 188640, + "frontend_question_id": 509, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1012, + "question__article__live": true, + "question__article__slug": "equal-rational-numbers", + "question__title": "Equal Rational Numbers", + "question__title_slug": "equal-rational-numbers", + "question__hide": false, + "total_acs": 3166, + "total_submitted": 7820, + "frontend_question_id": 972, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1011, + "question__article__live": true, + "question__article__slug": "flip-binary-tree-to-match-preorder-traversal", + "question__title": "Flip Binary Tree To Match Preorder Traversal", + "question__title_slug": "flip-binary-tree-to-match-preorder-traversal", + "question__hide": false, + "total_acs": 8718, + "total_submitted": 19794, + "frontend_question_id": 971, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1010, + "question__article__live": true, + "question__article__slug": "powerful-integers", + "question__title": "Powerful Integers", + "question__title_slug": "powerful-integers", + "question__hide": false, + "total_acs": 15971, + "total_submitted": 40289, + "frontend_question_id": 970, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1009, + "question__article__live": true, + "question__article__slug": "pancake-sorting", + "question__title": "Pancake Sorting", + "question__title_slug": "pancake-sorting", + "question__hide": false, + "total_acs": 18334, + "total_submitted": 28849, + "frontend_question_id": 969, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1008, + "question__article__live": true, + "question__article__slug": "binary-tree-cameras", + "question__title": "Binary Tree Cameras", + "question__title_slug": "binary-tree-cameras", + "question__hide": false, + "total_acs": 12262, + "total_submitted": 33535, + "frontend_question_id": 968, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1007, + "question__article__live": true, + "question__article__slug": "numbers-with-same-consecutive-differences", + "question__title": "Numbers With Same Consecutive Differences", + "question__title_slug": "numbers-with-same-consecutive-differences", + "question__hide": false, + "total_acs": 10299, + "total_submitted": 26971, + "frontend_question_id": 967, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1006, + "question__article__live": true, + "question__article__slug": "vowel-spellchecker", + "question__title": "Vowel Spellchecker", + "question__title_slug": "vowel-spellchecker", + "question__hide": false, + "total_acs": 7846, + "total_submitted": 17430, + "frontend_question_id": 966, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1005, + "question__article__live": true, + "question__article__slug": "univalued-binary-tree", + "question__title": "Univalued Binary Tree", + "question__title_slug": "univalued-binary-tree", + "question__hide": false, + "total_acs": 59915, + "total_submitted": 89524, + "frontend_question_id": 965, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1004, + "question__article__live": true, + "question__article__slug": "least-operators-to-express-number", + "question__title": "Least Operators to Express Number", + "question__title_slug": "least-operators-to-express-number", + "question__hide": false, + "total_acs": 3864, + "total_submitted": 9130, + "frontend_question_id": 964, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1003, + "question__article__live": true, + "question__article__slug": "minimum-area-rectangle-ii", + "question__title": "Minimum Area Rectangle II", + "question__title_slug": "minimum-area-rectangle-ii", + "question__hide": false, + "total_acs": 7939, + "total_submitted": 16460, + "frontend_question_id": 963, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1002, + "question__article__live": true, + "question__article__slug": "maximum-width-ramp", + "question__title": "Maximum Width Ramp", + "question__title_slug": "maximum-width-ramp", + "question__hide": false, + "total_acs": 13091, + "total_submitted": 30119, + "frontend_question_id": 962, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1001, + "question__article__live": true, + "question__article__slug": "n-repeated-element-in-size-2n-array", + "question__title": "N-Repeated Element in Size 2N Array", + "question__title_slug": "n-repeated-element-in-size-2n-array", + "question__hide": false, + "total_acs": 87555, + "total_submitted": 120342, + "frontend_question_id": 961, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1000, + "question__article__live": true, + "question__article__slug": "delete-columns-to-make-sorted-iii", + "question__title": "Delete Columns to Make Sorted III", + "question__title_slug": "delete-columns-to-make-sorted-iii", + "question__hide": false, + "total_acs": 4934, + "total_submitted": 9330, + "frontend_question_id": 960, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 999, + "question__article__live": true, + "question__article__slug": "regions-cut-by-slashes", + "question__title": "Regions Cut By Slashes", + "question__title_slug": "regions-cut-by-slashes", + "question__hide": false, + "total_acs": 11549, + "total_submitted": 18007, + "frontend_question_id": 959, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 998, + "question__article__live": true, + "question__article__slug": "check-completeness-of-a-binary-tree", + "question__title": "Check Completeness of a Binary Tree", + "question__title_slug": "check-completeness-of-a-binary-tree", + "question__hide": false, + "total_acs": 31825, + "total_submitted": 62945, + "frontend_question_id": 958, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 994, + "question__article__live": true, + "question__article__slug": "prison-cells-after-n-days", + "question__title": "Prison Cells After N Days", + "question__title_slug": "prison-cells-after-n-days", + "question__hide": false, + "total_acs": 30164, + "total_submitted": 78369, + "frontend_question_id": 957, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 993, + "question__article__live": true, + "question__article__slug": "tallest-billboard", + "question__title": "Tallest Billboard", + "question__title_slug": "tallest-billboard", + "question__hide": false, + "total_acs": 5383, + "total_submitted": 13934, + "frontend_question_id": 956, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 992, + "question__article__live": true, + "question__article__slug": "delete-columns-to-make-sorted-ii", + "question__title": "Delete Columns to Make Sorted II", + "question__title_slug": "delete-columns-to-make-sorted-ii", + "question__hide": false, + "total_acs": 7454, + "total_submitted": 22974, + "frontend_question_id": 955, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 991, + "question__article__live": true, + "question__article__slug": "array-of-doubled-pairs", + "question__title": "Array of Doubled Pairs", + "question__title_slug": "array-of-doubled-pairs", + "question__hide": false, + "total_acs": 13193, + "total_submitted": 37211, + "frontend_question_id": 954, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 990, + "question__article__live": true, + "question__article__slug": "verifying-an-alien-dictionary", + "question__title": "Verifying an Alien Dictionary", + "question__title_slug": "verifying-an-alien-dictionary", + "question__hide": false, + "total_acs": 51791, + "total_submitted": 93737, + "frontend_question_id": 953, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 989, + "question__article__live": true, + "question__article__slug": "largest-component-size-by-common-factor", + "question__title": "Largest Component Size by Common Factor", + "question__title_slug": "largest-component-size-by-common-factor", + "question__hide": false, + "total_acs": 6692, + "total_submitted": 23612, + "frontend_question_id": 952, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 988, + "question__article__live": true, + "question__article__slug": "flip-equivalent-binary-trees", + "question__title": "Flip Equivalent Binary Trees", + "question__title_slug": "flip-equivalent-binary-trees", + "question__hide": false, + "total_acs": 28712, + "total_submitted": 43943, + "frontend_question_id": 951, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 987, + "question__article__live": true, + "question__article__slug": "reveal-cards-in-increasing-order", + "question__title": "Reveal Cards In Increasing Order", + "question__title_slug": "reveal-cards-in-increasing-order", + "question__hide": false, + "total_acs": 25050, + "total_submitted": 34457, + "frontend_question_id": 950, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 986, + "question__article__live": true, + "question__article__slug": "largest-time-for-given-digits", + "question__title": "Largest Time for Given Digits", + "question__title_slug": "largest-time-for-given-digits", + "question__hide": false, + "total_acs": 11737, + "total_submitted": 33875, + "frontend_question_id": 949, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 985, + "question__article__live": true, + "question__article__slug": "bag-of-tokens", + "question__title": "Bag of Tokens", + "question__title_slug": "bag-of-tokens", + "question__hide": false, + "total_acs": 8443, + "total_submitted": 21180, + "frontend_question_id": 948, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 984, + "question__article__live": true, + "question__article__slug": "most-stones-removed-with-same-row-or-column", + "question__title": "Most Stones Removed with Same Row or Column", + "question__title_slug": "most-stones-removed-with-same-row-or-column", + "question__hide": false, + "total_acs": 36401, + "total_submitted": 66365, + "frontend_question_id": 947, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 983, + "question__article__live": true, + "question__article__slug": "validate-stack-sequences", + "question__title": "Validate Stack Sequences", + "question__title_slug": "validate-stack-sequences", + "question__hide": false, + "total_acs": 21431, + "total_submitted": 36700, + "frontend_question_id": 946, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 982, + "question__article__live": true, + "question__article__slug": "minimum-increment-to-make-array-unique", + "question__title": "Minimum Increment to Make Array Unique", + "question__title_slug": "minimum-increment-to-make-array-unique", + "question__hide": false, + "total_acs": 16653, + "total_submitted": 37506, + "frontend_question_id": 945, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 981, + "question__article__live": true, + "question__article__slug": "delete-columns-to-make-sorted", + "question__title": "Delete Columns to Make Sorted", + "question__title_slug": "delete-columns-to-make-sorted", + "question__hide": false, + "total_acs": 31825, + "total_submitted": 45606, + "frontend_question_id": 944, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 980, + "question__article__live": true, + "question__article__slug": "find-the-shortest-superstring", + "question__title": "Find the Shortest Superstring", + "question__title_slug": "find-the-shortest-superstring", + "question__hide": false, + "total_acs": 7539, + "total_submitted": 18415, + "frontend_question_id": 943, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 979, + "question__article__live": true, + "question__article__slug": "di-string-match", + "question__title": "DI String Match", + "question__title_slug": "di-string-match", + "question__hide": false, + "total_acs": 47813, + "total_submitted": 68008, + "frontend_question_id": 942, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 978, + "question__article__live": true, + "question__article__slug": "valid-mountain-array", + "question__title": "Valid Mountain Array", + "question__title_slug": "valid-mountain-array", + "question__hide": false, + "total_acs": 31588, + "total_submitted": 89437, + "frontend_question_id": 941, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 977, + "question__article__live": true, + "question__article__slug": "distinct-subsequences-ii", + "question__title": "Distinct Subsequences II", + "question__title_slug": "distinct-subsequences-ii", + "question__hide": false, + "total_acs": 7867, + "total_submitted": 19210, + "frontend_question_id": 940, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 976, + "question__article__live": true, + "question__article__slug": "minimum-area-rectangle", + "question__title": "Minimum Area Rectangle", + "question__title_slug": "minimum-area-rectangle", + "question__hide": false, + "total_acs": 31176, + "total_submitted": 60238, + "frontend_question_id": 939, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 975, + "question__article__live": true, + "question__article__slug": "range-sum-of-bst", + "question__title": "Range Sum of BST", + "question__title_slug": "range-sum-of-bst", + "question__hide": false, + "total_acs": 126133, + "total_submitted": 160441, + "frontend_question_id": 938, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 974, + "question__article__live": true, + "question__article__slug": "reorder-log-files", + "question__title": "Reorder Data in Log Files", + "question__title_slug": "reorder-data-in-log-files", + "question__hide": false, + "total_acs": 66738, + "total_submitted": 123810, + "frontend_question_id": 937, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 973, + "question__article__live": true, + "question__article__slug": "stamping-the-sequence", + "question__title": "Stamping The Sequence", + "question__title_slug": "stamping-the-sequence", + "question__hide": false, + "total_acs": 4098, + "total_submitted": 11323, + "frontend_question_id": 936, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 972, + "question__article__live": true, + "question__article__slug": "knight-dialer", + "question__title": "Knight Dialer", + "question__title_slug": "knight-dialer", + "question__hide": false, + "total_acs": 21843, + "total_submitted": 50966, + "frontend_question_id": 935, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 971, + "question__article__live": true, + "question__article__slug": "shortest-bridge", + "question__title": "Shortest Bridge", + "question__title_slug": "shortest-bridge", + "question__hide": false, + "total_acs": 16175, + "total_submitted": 35396, + "frontend_question_id": 934, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 969, + "question__article__live": true, + "question__article__slug": "number-of-recent-calls", + "question__title": "Number of Recent Calls", + "question__title_slug": "number-of-recent-calls", + "question__hide": false, + "total_acs": 33173, + "total_submitted": 47492, + "frontend_question_id": 933, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 968, + "question__article__live": true, + "question__article__slug": "beautiful-array", + "question__title": "Beautiful Array", + "question__title_slug": "beautiful-array", + "question__hide": false, + "total_acs": 8160, + "total_submitted": 14679, + "frontend_question_id": 932, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 967, + "question__article__live": true, + "question__article__slug": "minimum-path-falling-sum", + "question__title": "Minimum Falling Path Sum", + "question__title_slug": "minimum-falling-path-sum", + "question__hide": false, + "total_acs": 28222, + "total_submitted": 47087, + "frontend_question_id": 931, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 966, + "question__article__live": true, + "question__article__slug": "binary-subarrays-with-sum", + "question__title": "Binary Subarrays With Sum", + "question__title_slug": "binary-subarrays-with-sum", + "question__hide": false, + "total_acs": 13729, + "total_submitted": 34324, + "frontend_question_id": 930, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 965, + "question__article__live": true, + "question__article__slug": "unique-email-addresses", + "question__title": "Unique Email Addresses", + "question__title_slug": "unique-email-addresses", + "question__hide": false, + "total_acs": 161436, + "total_submitted": 237100, + "frontend_question_id": 929, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 964, + "question__article__live": true, + "question__article__slug": "minimize-malware-spread-ii", + "question__title": "Minimize Malware Spread II", + "question__title_slug": "minimize-malware-spread-ii", + "question__hide": false, + "total_acs": 6840, + "total_submitted": 17219, + "frontend_question_id": 928, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 963, + "question__article__live": true, + "question__article__slug": "three-equal-parts", + "question__title": "Three Equal Parts", + "question__title_slug": "three-equal-parts", + "question__hide": false, + "total_acs": 5256, + "total_submitted": 16680, + "frontend_question_id": 927, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 962, + "question__article__live": true, + "question__article__slug": "flip-string-to-monotone-increasing", + "question__title": "Flip String to Monotone Increasing", + "question__title_slug": "flip-string-to-monotone-increasing", + "question__hide": false, + "total_acs": 16283, + "total_submitted": 31817, + "frontend_question_id": 926, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 961, + "question__article__live": true, + "question__article__slug": "long-pressed-name", + "question__title": "Long Pressed Name", + "question__title_slug": "long-pressed-name", + "question__hide": false, + "total_acs": 26322, + "total_submitted": 59200, + "frontend_question_id": 925, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 960, + "question__article__live": true, + "question__article__slug": "minimize-malware-spread", + "question__title": "Minimize Malware Spread", + "question__title_slug": "minimize-malware-spread", + "question__hide": false, + "total_acs": 17388, + "total_submitted": 42218, + "frontend_question_id": 924, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 959, + "question__article__live": true, + "question__article__slug": "3sum-with-multiplicity", + "question__title": "3Sum With Multiplicity", + "question__title_slug": "3sum-with-multiplicity", + "question__hide": false, + "total_acs": 14988, + "total_submitted": 42777, + "frontend_question_id": 923, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 958, + "question__article__live": true, + "question__article__slug": "sort-array-by-parity-ii", + "question__title": "Sort Array By Parity II", + "question__title_slug": "sort-array-by-parity-ii", + "question__hide": false, + "total_acs": 67658, + "total_submitted": 100207, + "frontend_question_id": 922, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 957, + "question__article__live": true, + "question__article__slug": "minimum-add-to-make-parentheses-valid", + "question__title": "Minimum Add to Make Parentheses Valid", + "question__title_slug": "minimum-add-to-make-parentheses-valid", + "question__hide": false, + "total_acs": 41841, + "total_submitted": 58855, + "frontend_question_id": 921, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 956, + "question__article__live": true, + "question__article__slug": "number-of-music-playlists", + "question__title": "Number of Music Playlists", + "question__title_slug": "number-of-music-playlists", + "question__hide": false, + "total_acs": 7393, + "total_submitted": 16504, + "frontend_question_id": 920, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 955, + "question__article__live": true, + "question__article__slug": "complete-binary-tree-inserter", + "question__title": "Complete Binary Tree Inserter", + "question__title_slug": "complete-binary-tree-inserter", + "question__hide": false, + "total_acs": 12082, + "total_submitted": 21644, + "frontend_question_id": 919, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 954, + "question__article__live": true, + "question__article__slug": "maximum-sub-circular-subarray", + "question__title": "Maximum Sum Circular Subarray", + "question__title_slug": "maximum-sum-circular-subarray", + "question__hide": false, + "total_acs": 15082, + "total_submitted": 44978, + "frontend_question_id": 918, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 953, + "question__article__live": true, + "question__article__slug": "reverse-only-letters", + "question__title": "Reverse Only Letters", + "question__title_slug": "reverse-only-letters", + "question__hide": false, + "total_acs": 40393, + "total_submitted": 71292, + "frontend_question_id": 917, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 952, + "question__article__live": true, + "question__article__slug": "word-subsets", + "question__title": "Word Subsets", + "question__title_slug": "word-subsets", + "question__hide": false, + "total_acs": 14785, + "total_submitted": 31914, + "frontend_question_id": 916, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 951, + "question__article__live": true, + "question__article__slug": "parition-array-into-disjoint-intervals", + "question__title": "Partition Array into Disjoint Intervals", + "question__title_slug": "partition-array-into-disjoint-intervals", + "question__hide": false, + "total_acs": 14969, + "total_submitted": 33955, + "frontend_question_id": 915, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 950, + "question__article__live": true, + "question__article__slug": "x-of-a-kind-in-a-deck-of-cards", + "question__title": "X of a Kind in a Deck of Cards", + "question__title_slug": "x-of-a-kind-in-a-deck-of-cards", + "question__hide": false, + "total_acs": 26251, + "total_submitted": 77421, + "frontend_question_id": 914, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 949, + "question__article__live": true, + "question__article__slug": "cat-and-mouse-game", + "question__title": "Cat and Mouse", + "question__title_slug": "cat-and-mouse", + "question__hide": false, + "total_acs": 5894, + "total_submitted": 19660, + "frontend_question_id": 913, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 948, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sort an Array", + "question__title_slug": "sort-an-array", + "question__hide": false, + "total_acs": 38020, + "total_submitted": 60501, + "frontend_question_id": 912, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 947, + "question__article__live": true, + "question__article__slug": "online-election", + "question__title": "Online Election", + "question__title_slug": "online-election", + "question__hide": false, + "total_acs": 17511, + "total_submitted": 35878, + "frontend_question_id": 911, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 946, + "question__article__live": true, + "question__article__slug": "smallest-range-ii", + "question__title": "Smallest Range II", + "question__title_slug": "smallest-range-ii", + "question__hide": false, + "total_acs": 8117, + "total_submitted": 32168, + "frontend_question_id": 910, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 945, + "question__article__live": true, + "question__article__slug": "snakes-and-ladders", + "question__title": "Snakes and Ladders", + "question__title_slug": "snakes-and-ladders", + "question__hide": false, + "total_acs": 19444, + "total_submitted": 53251, + "frontend_question_id": 909, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 944, + "question__article__live": true, + "question__article__slug": "smallest-range-i", + "question__title": "Smallest Range I", + "question__title_slug": "smallest-range-i", + "question__hide": false, + "total_acs": 31628, + "total_submitted": 48616, + "frontend_question_id": 908, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 943, + "question__article__live": true, + "question__article__slug": "sum-of-subarray-minimums", + "question__title": "Sum of Subarray Minimums", + "question__title_slug": "sum-of-subarray-minimums", + "question__hide": false, + "total_acs": 16708, + "total_submitted": 56066, + "frontend_question_id": 907, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 942, + "question__article__live": true, + "question__article__slug": "super-palindromes", + "question__title": "Super Palindromes", + "question__title_slug": "super-palindromes", + "question__hide": false, + "total_acs": 4196, + "total_submitted": 13621, + "frontend_question_id": 906, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 941, + "question__article__live": true, + "question__article__slug": "sort-array-by-parity", + "question__title": "Sort Array By Parity", + "question__title_slug": "sort-array-by-parity", + "question__hide": false, + "total_acs": 145218, + "total_submitted": 198362, + "frontend_question_id": 905, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 940, + "question__article__live": true, + "question__article__slug": "fruit-into-baskets", + "question__title": "Fruit Into Baskets", + "question__title_slug": "fruit-into-baskets", + "question__hide": false, + "total_acs": 72715, + "total_submitted": 173488, + "frontend_question_id": 904, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 939, + "question__article__live": true, + "question__article__slug": "valid-permutations-for-di-sequence", + "question__title": "Valid Permutations for DI Sequence", + "question__title_slug": "valid-permutations-for-di-sequence", + "question__hide": false, + "total_acs": 4134, + "total_submitted": 8819, + "frontend_question_id": 903, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 938, + "question__article__live": true, + "question__article__slug": "numbers-at-most-n-given-digit-set", + "question__title": "Numbers At Most N Given Digit Set", + "question__title_slug": "numbers-at-most-n-given-digit-set", + "question__hide": false, + "total_acs": 5527, + "total_submitted": 18681, + "frontend_question_id": 902, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 937, + "question__article__live": true, + "question__article__slug": "online-stock-span", + "question__title": "Online Stock Span", + "question__title_slug": "online-stock-span", + "question__hide": false, + "total_acs": 15140, + "total_submitted": 28990, + "frontend_question_id": 901, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 936, + "question__article__live": true, + "question__article__slug": "rle-iterator", + "question__title": "RLE Iterator", + "question__title_slug": "rle-iterator", + "question__hide": false, + "total_acs": 17803, + "total_submitted": 34199, + "frontend_question_id": 900, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 935, + "question__article__live": true, + "question__article__slug": "orderly-queue", + "question__title": "Orderly Queue", + "question__title_slug": "orderly-queue", + "question__hide": false, + "total_acs": 5565, + "total_submitted": 11318, + "frontend_question_id": 899, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 934, + "question__article__live": true, + "question__article__slug": "bitwise-ors-of-subarrays", + "question__title": "Bitwise ORs of Subarrays", + "question__title_slug": "bitwise-ors-of-subarrays", + "question__hide": false, + "total_acs": 10868, + "total_submitted": 30282, + "frontend_question_id": 898, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 933, + "question__article__live": true, + "question__article__slug": "increasing-order-search-tree", + "question__title": "Increasing Order Search Tree", + "question__title_slug": "increasing-order-search-tree", + "question__hide": false, + "total_acs": 47240, + "total_submitted": 71031, + "frontend_question_id": 897, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 932, + "question__article__live": true, + "question__article__slug": "monotonic-array", + "question__title": "Monotonic Array", + "question__title_slug": "monotonic-array", + "question__hide": false, + "total_acs": 69593, + "total_submitted": 123242, + "frontend_question_id": 896, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 931, + "question__article__live": true, + "question__article__slug": "maximum-frequency-stack", + "question__title": "Maximum Frequency Stack", + "question__title_slug": "maximum-frequency-stack", + "question__hide": false, + "total_acs": 22171, + "total_submitted": 37646, + "frontend_question_id": 895, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 930, + "question__article__live": true, + "question__article__slug": "all-possible-full-binary-trees", + "question__title": "All Possible Full Binary Trees", + "question__title_slug": "all-possible-full-binary-trees", + "question__hide": false, + "total_acs": 26071, + "total_submitted": 35958, + "frontend_question_id": 894, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 929, + "question__article__live": true, + "question__article__slug": "groups-of-special-equivalent-strings", + "question__title": "Groups of Special-Equivalent Strings", + "question__title_slug": "groups-of-special-equivalent-strings", + "question__hide": false, + "total_acs": 20001, + "total_submitted": 31163, + "frontend_question_id": 893, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 928, + "question__article__live": true, + "question__article__slug": "surface-area-of-3d-shapes", + "question__title": "Surface Area of 3D Shapes", + "question__title_slug": "surface-area-of-3d-shapes", + "question__hide": false, + "total_acs": 14365, + "total_submitted": 25147, + "frontend_question_id": 892, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 927, + "question__article__live": true, + "question__article__slug": "sum-of-subsequence-widths", + "question__title": "Sum of Subsequence Widths", + "question__title_slug": "sum-of-subsequence-widths", + "question__hide": false, + "total_acs": 6396, + "total_submitted": 21044, + "frontend_question_id": 891, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 926, + "question__article__live": true, + "question__article__slug": "find-and-replace-pattern", + "question__title": "Find and Replace Pattern", + "question__title_slug": "find-and-replace-pattern", + "question__hide": false, + "total_acs": 39775, + "total_submitted": 54964, + "frontend_question_id": 890, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 925, + "question__article__live": true, + "question__article__slug": "construct-binary-tree-from-preorder-and-postorder-", + "question__title": "Construct Binary Tree from Preorder and Postorder Traversal", + "question__title_slug": "construct-binary-tree-from-preorder-and-postorder-traversal", + "question__hide": false, + "total_acs": 24400, + "total_submitted": 38624, + "frontend_question_id": 889, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 924, + "question__article__live": true, + "question__article__slug": "fair-candy-swap", + "question__title": "Fair Candy Swap", + "question__title_slug": "fair-candy-swap", + "question__hide": false, + "total_acs": 37365, + "total_submitted": 65545, + "frontend_question_id": 888, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 923, + "question__article__live": true, + "question__article__slug": "super-egg-drop", + "question__title": "Super Egg Drop", + "question__title_slug": "super-egg-drop", + "question__hide": false, + "total_acs": 11142, + "total_submitted": 43061, + "frontend_question_id": 887, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 922, + "question__article__live": true, + "question__article__slug": "possible-bipartition", + "question__title": "Possible Bipartition", + "question__title_slug": "possible-bipartition", + "question__hide": false, + "total_acs": 17192, + "total_submitted": 41170, + "frontend_question_id": 886, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 921, + "question__article__live": true, + "question__article__slug": "spiral-matrix-iii", + "question__title": "Spiral Matrix III", + "question__title_slug": "spiral-matrix-iii", + "question__hide": false, + "total_acs": 14051, + "total_submitted": 21009, + "frontend_question_id": 885, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 920, + "question__article__live": true, + "question__article__slug": "uncommon-words-from-two-sentences", + "question__title": "Uncommon Words from Two Sentences", + "question__title_slug": "uncommon-words-from-two-sentences", + "question__hide": false, + "total_acs": 41611, + "total_submitted": 67633, + "frontend_question_id": 884, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 919, + "question__article__live": true, + "question__article__slug": "projection-area-of-3d-shapes", + "question__title": "Projection Area of 3D Shapes", + "question__title_slug": "projection-area-of-3d-shapes", + "question__hide": false, + "total_acs": 23655, + "total_submitted": 35544, + "frontend_question_id": 883, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 918, + "question__article__live": true, + "question__article__slug": "reachable-nodes-in-subdivided-graph", + "question__title": "Reachable Nodes In Subdivided Graph", + "question__title_slug": "reachable-nodes-in-subdivided-graph", + "question__hide": false, + "total_acs": 4267, + "total_submitted": 10871, + "frontend_question_id": 882, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 917, + "question__article__live": true, + "question__article__slug": "boats-to-save-people", + "question__title": "Boats to Save People", + "question__title_slug": "boats-to-save-people", + "question__hide": false, + "total_acs": 21352, + "total_submitted": 47228, + "frontend_question_id": 881, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 916, + "question__article__live": true, + "question__article__slug": "decoded-string-at-index", + "question__title": "Decoded String at Index", + "question__title_slug": "decoded-string-at-index", + "question__hide": false, + "total_acs": 9655, + "total_submitted": 40721, + "frontend_question_id": 880, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 915, + "question__article__live": true, + "question__article__slug": "generate-random-point-in-a-circle", + "question__title": "Generate Random Point in a Circle", + "question__title_slug": "generate-random-point-in-a-circle", + "question__hide": false, + "total_acs": 7894, + "total_submitted": 20649, + "frontend_question_id": 478, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 914, + "question__article__live": true, + "question__article__slug": "random-point-in-non-overlapping-rectangles", + "question__title": "Random Point in Non-overlapping Rectangles", + "question__title_slug": "random-point-in-non-overlapping-rectangles", + "question__hide": false, + "total_acs": 9897, + "total_submitted": 26754, + "frontend_question_id": 497, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 913, + "question__article__live": true, + "question__article__slug": "random-flip-matrix", + "question__title": "Random Flip Matrix", + "question__title_slug": "random-flip-matrix", + "question__hide": false, + "total_acs": 5803, + "total_submitted": 16623, + "frontend_question_id": 519, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 912, + "question__article__live": true, + "question__article__slug": "random-pick-with-weight", + "question__title": "Random Pick with Weight", + "question__title_slug": "random-pick-with-weight", + "question__hide": false, + "total_acs": 44767, + "total_submitted": 103367, + "frontend_question_id": 528, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 911, + "question__article__live": true, + "question__article__slug": "profitable-schemes", + "question__title": "Profitable Schemes", + "question__title_slug": "profitable-schemes", + "question__hide": false, + "total_acs": 7278, + "total_submitted": 19216, + "frontend_question_id": 879, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 910, + "question__article__live": true, + "question__article__slug": "nth-magical-number", + "question__title": "Nth Magical Number", + "question__title_slug": "nth-magical-number", + "question__hide": false, + "total_acs": 7072, + "total_submitted": 25886, + "frontend_question_id": 878, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 909, + "question__article__live": true, + "question__article__slug": "stone-game", + "question__title": "Stone Game", + "question__title_slug": "stone-game", + "question__hide": false, + "total_acs": 39892, + "total_submitted": 63512, + "frontend_question_id": 877, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 908, + "question__article__live": true, + "question__article__slug": "middle-of-the-linked-list", + "question__title": "Middle of the Linked List", + "question__title_slug": "middle-of-the-linked-list", + "question__hide": false, + "total_acs": 96448, + "total_submitted": 147200, + "frontend_question_id": 876, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 907, + "question__article__live": true, + "question__article__slug": "koko-eating-bananas", + "question__title": "Koko Eating Bananas", + "question__title_slug": "koko-eating-bananas", + "question__hide": false, + "total_acs": 22508, + "total_submitted": 46474, + "frontend_question_id": 875, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 906, + "question__article__live": true, + "question__article__slug": "walking-robot-simulation", + "question__title": "Walking Robot Simulation", + "question__title_slug": "walking-robot-simulation", + "question__hide": false, + "total_acs": 13468, + "total_submitted": 40095, + "frontend_question_id": 874, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 905, + "question__article__live": true, + "question__article__slug": "length-of-longest-fibonacci-subsequence", + "question__title": "Length of Longest Fibonacci Subsequence", + "question__title_slug": "length-of-longest-fibonacci-subsequence", + "question__hide": false, + "total_acs": 21599, + "total_submitted": 45565, + "frontend_question_id": 873, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 904, + "question__article__live": true, + "question__article__slug": "leaf-similar-trees", + "question__title": "Leaf-Similar Trees", + "question__title_slug": "leaf-similar-trees", + "question__hide": false, + "total_acs": 62622, + "total_submitted": 97353, + "frontend_question_id": 872, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 903, + "question__article__live": true, + "question__article__slug": "implement-rand10-using-rand7", + "question__title": "Implement Rand10() Using Rand7()", + "question__title_slug": "implement-rand10-using-rand7", + "question__hide": false, + "total_acs": 15162, + "total_submitted": 33286, + "frontend_question_id": 470, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 902, + "question__article__live": true, + "question__article__slug": "minimum-number-of-refueling-stops", + "question__title": "Minimum Number of Refueling Stops", + "question__title_slug": "minimum-number-of-refueling-stops", + "question__hide": false, + "total_acs": 11421, + "total_submitted": 37504, + "frontend_question_id": 871, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 901, + "question__article__live": true, + "question__article__slug": "advantage-shuffle", + "question__title": "Advantage Shuffle", + "question__title_slug": "advantage-shuffle", + "question__hide": false, + "total_acs": 14998, + "total_submitted": 34192, + "frontend_question_id": 870, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 900, + "question__article__live": true, + "question__article__slug": "reordered-power-of-2", + "question__title": "Reordered Power of 2", + "question__title_slug": "reordered-power-of-2", + "question__hide": false, + "total_acs": 11546, + "total_submitted": 22366, + "frontend_question_id": 869, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 899, + "question__article__live": true, + "question__article__slug": "binary-gap", + "question__title": "Binary Gap", + "question__title_slug": "binary-gap", + "question__hide": false, + "total_acs": 29913, + "total_submitted": 49817, + "frontend_question_id": 868, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 898, + "question__article__live": true, + "question__article__slug": "transpose-matrix", + "question__title": "Transpose Matrix", + "question__title_slug": "transpose-matrix", + "question__hide": false, + "total_acs": 59800, + "total_submitted": 93752, + "frontend_question_id": 867, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 897, + "question__article__live": true, + "question__article__slug": "prime-palindrome", + "question__title": "Prime Palindrome", + "question__title_slug": "prime-palindrome", + "question__hide": false, + "total_acs": 12269, + "total_submitted": 55202, + "frontend_question_id": 866, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 896, + "question__article__live": true, + "question__article__slug": "smallest-subtree-with-all-the-deepest-nodes", + "question__title": "Smallest Subtree with all the Deepest Nodes", + "question__title_slug": "smallest-subtree-with-all-the-deepest-nodes", + "question__hide": false, + "total_acs": 27081, + "total_submitted": 46262, + "frontend_question_id": 865, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 895, + "question__article__live": true, + "question__article__slug": "shortest-path-to-get-all-keys", + "question__title": "Shortest Path to Get All Keys", + "question__title_slug": "shortest-path-to-get-all-keys", + "question__hide": false, + "total_acs": 7011, + "total_submitted": 18007, + "frontend_question_id": 864, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 894, + "question__article__live": true, + "question__article__slug": "random-pick-with-blacklist", + "question__title": "Random Pick with Blacklist", + "question__title_slug": "random-pick-with-blacklist", + "question__hide": false, + "total_acs": 9363, + "total_submitted": 28855, + "frontend_question_id": 710, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 893, + "question__article__live": true, + "question__article__slug": "all-nodes-distance-k-in-binary-tree", + "question__title": "All Nodes Distance K in Binary Tree", + "question__title_slug": "all-nodes-distance-k-in-binary-tree", + "question__hide": false, + "total_acs": 43874, + "total_submitted": 85545, + "frontend_question_id": 863, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 892, + "question__article__live": true, + "question__article__slug": "shortest-subarray-with-sum-atleast-k", + "question__title": "Shortest Subarray with Sum at Least K", + "question__title_slug": "shortest-subarray-with-sum-at-least-k", + "question__hide": false, + "total_acs": 18418, + "total_submitted": 81169, + "frontend_question_id": 862, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 891, + "question__article__live": true, + "question__article__slug": "score-after-flipping-matrix", + "question__title": "Score After Flipping Matrix", + "question__title_slug": "score-after-flipping-matrix", + "question__hide": false, + "total_acs": 16370, + "total_submitted": 23054, + "frontend_question_id": 861, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 890, + "question__article__live": true, + "question__article__slug": "lemonade-change", + "question__title": "Lemonade Change", + "question__title_slug": "lemonade-change", + "question__hide": false, + "total_acs": 38205, + "total_submitted": 74910, + "frontend_question_id": 860, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 889, + "question__article__live": true, + "question__article__slug": "buddy-strings", + "question__title": "Buddy Strings", + "question__title_slug": "buddy-strings", + "question__hide": false, + "total_acs": 33770, + "total_submitted": 121416, + "frontend_question_id": 859, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 888, + "question__article__live": true, + "question__article__slug": "mirror-reflection", + "question__title": "Mirror Reflection", + "question__title_slug": "mirror-reflection", + "question__hide": false, + "total_acs": 7744, + "total_submitted": 14770, + "frontend_question_id": 858, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 887, + "question__article__live": true, + "question__article__slug": "minimum-cost-to-hire-k-workers", + "question__title": "Minimum Cost to Hire K Workers", + "question__title_slug": "minimum-cost-to-hire-k-workers", + "question__hide": false, + "total_acs": 23031, + "total_submitted": 47229, + "frontend_question_id": 857, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 886, + "question__article__live": true, + "question__article__slug": "score-of-parentheses", + "question__title": "Score of Parentheses", + "question__title_slug": "score-of-parentheses", + "question__hide": false, + "total_acs": 26335, + "total_submitted": 45153, + "frontend_question_id": 856, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 885, + "question__article__live": true, + "question__article__slug": "exam-room", + "question__title": "Exam Room", + "question__title_slug": "exam-room", + "question__hide": false, + "total_acs": 21658, + "total_submitted": 53303, + "frontend_question_id": 855, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 884, + "question__article__live": true, + "question__article__slug": "k-similar-strings", + "question__title": "K-Similar Strings", + "question__title_slug": "k-similar-strings", + "question__hide": false, + "total_acs": 11794, + "total_submitted": 32278, + "frontend_question_id": 854, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 883, + "question__article__live": true, + "question__article__slug": "car-fleet", + "question__title": "Car Fleet", + "question__title_slug": "car-fleet", + "question__hide": false, + "total_acs": 21186, + "total_submitted": 50968, + "frontend_question_id": 853, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 882, + "question__article__live": true, + "question__article__slug": "peak-index-in-a-mountain-array", + "question__title": "Peak Index in a Mountain Array", + "question__title_slug": "peak-index-in-a-mountain-array", + "question__hide": false, + "total_acs": 111785, + "total_submitted": 158619, + "frontend_question_id": 852, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 881, + "question__article__live": true, + "question__article__slug": "loud-and-rich", + "question__title": "Loud and Rich", + "question__title_slug": "loud-and-rich", + "question__hide": false, + "total_acs": 10130, + "total_submitted": 20388, + "frontend_question_id": 851, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 880, + "question__article__live": true, + "question__article__slug": "rectangle-area-ii", + "question__title": "Rectangle Area II", + "question__title_slug": "rectangle-area-ii", + "question__hide": false, + "total_acs": 9004, + "total_submitted": 19479, + "frontend_question_id": 850, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 879, + "question__article__live": true, + "question__article__slug": "maximize-distance-to-closest-person", + "question__title": "Maximize Distance to Closest Person", + "question__title_slug": "maximize-distance-to-closest-person", + "question__hide": false, + "total_acs": 46124, + "total_submitted": 110138, + "frontend_question_id": 849, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 878, + "question__article__live": true, + "question__article__slug": "shifting-letters", + "question__title": "Shifting Letters", + "question__title_slug": "shifting-letters", + "question__hide": false, + "total_acs": 17552, + "total_submitted": 40945, + "frontend_question_id": 848, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 877, + "question__article__live": true, + "question__article__slug": "shortest-path-visiting-all-nodes", + "question__title": "Shortest Path Visiting All Nodes", + "question__title_slug": "shortest-path-visiting-all-nodes", + "question__hide": false, + "total_acs": 11546, + "total_submitted": 23367, + "frontend_question_id": 847, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 876, + "question__article__live": true, + "question__article__slug": "hand-of-straights", + "question__title": "Hand of Straights", + "question__title_slug": "hand-of-straights", + "question__hide": false, + "total_acs": 25600, + "total_submitted": 50460, + "frontend_question_id": 846, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 875, + "question__article__live": true, + "question__article__slug": "longest-mountain-in-array", + "question__title": "Longest Mountain in Array", + "question__title_slug": "longest-mountain-in-array", + "question__hide": false, + "total_acs": 24020, + "total_submitted": 67532, + "frontend_question_id": 845, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 874, + "question__article__live": true, + "question__article__slug": "backspace-string-compare", + "question__title": "Backspace String Compare", + "question__title_slug": "backspace-string-compare", + "question__hide": false, + "total_acs": 87474, + "total_submitted": 186753, + "frontend_question_id": 844, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 873, + "question__article__live": true, + "question__article__slug": "guess-the-word", + "question__title": "Guess the Word", + "question__title_slug": "guess-the-word", + "question__hide": false, + "total_acs": 31854, + "total_submitted": 70396, + "frontend_question_id": 843, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 872, + "question__article__live": true, + "question__article__slug": "split-array-into-fibonacci-sequence", + "question__title": "Split Array into Fibonacci Sequence", + "question__title_slug": "split-array-into-fibonacci-sequence", + "question__hide": false, + "total_acs": 14443, + "total_submitted": 40704, + "frontend_question_id": 842, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 871, + "question__article__live": true, + "question__article__slug": "keys-and-rooms", + "question__title": "Keys and Rooms", + "question__title_slug": "keys-and-rooms", + "question__hide": false, + "total_acs": 51253, + "total_submitted": 82669, + "frontend_question_id": 841, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 870, + "question__article__live": true, + "question__article__slug": "magic-squares-in-grid", + "question__title": "Magic Squares In Grid", + "question__title_slug": "magic-squares-in-grid", + "question__hide": false, + "total_acs": 17008, + "total_submitted": 46732, + "frontend_question_id": 840, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 869, + "question__article__live": true, + "question__article__slug": "similar-string-groups", + "question__title": "Similar String Groups", + "question__title_slug": "similar-string-groups", + "question__hide": false, + "total_acs": 13491, + "total_submitted": 36964, + "frontend_question_id": 839, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 868, + "question__article__live": true, + "question__article__slug": "push-dominoes", + "question__title": "Push Dominoes", + "question__title_slug": "push-dominoes", + "question__hide": false, + "total_acs": 15709, + "total_submitted": 34008, + "frontend_question_id": 838, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 867, + "question__article__live": true, + "question__article__slug": "new-21-game", + "question__title": "New 21 Game", + "question__title_slug": "new-21-game", + "question__hide": false, + "total_acs": 13217, + "total_submitted": 39699, + "frontend_question_id": 837, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 866, + "question__article__live": true, + "question__article__slug": "rectangle-overlap", + "question__title": "Rectangle Overlap", + "question__title_slug": "rectangle-overlap", + "question__hide": false, + "total_acs": 35827, + "total_submitted": 74825, + "frontend_question_id": 836, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 865, + "question__article__live": true, + "question__article__slug": "robot-room-cleaner", + "question__title": "Robot Room Cleaner", + "question__title_slug": "robot-room-cleaner", + "question__hide": false, + "total_acs": 36128, + "total_submitted": 53859, + "frontend_question_id": 489, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 864, + "question__article__live": true, + "question__article__slug": "image-overlap", + "question__title": "Image Overlap", + "question__title_slug": "image-overlap", + "question__hide": false, + "total_acs": 14075, + "total_submitted": 25745, + "frontend_question_id": 835, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 863, + "question__article__live": true, + "question__article__slug": "sum-of-distances-in-tree", + "question__title": "Sum of Distances in Tree", + "question__title_slug": "sum-of-distances-in-tree", + "question__hide": false, + "total_acs": 10414, + "total_submitted": 24926, + "frontend_question_id": 834, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 862, + "question__article__live": true, + "question__article__slug": "find-and-replace-in-string", + "question__title": "Find And Replace in String", + "question__title_slug": "find-and-replace-in-string", + "question__hide": false, + "total_acs": 27143, + "total_submitted": 56108, + "frontend_question_id": 833, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 861, + "question__article__live": true, + "question__article__slug": "flipping-an-image", + "question__title": "Flipping an Image", + "question__title_slug": "flipping-an-image", + "question__hide": false, + "total_acs": 137096, + "total_submitted": 185057, + "frontend_question_id": 832, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 860, + "question__article__live": true, + "question__article__slug": "design-circular-queue", + "question__title": "Design Circular Queue", + "question__title_slug": "design-circular-queue", + "question__hide": false, + "total_acs": 41218, + "total_submitted": 99379, + "frontend_question_id": 622, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 859, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Circular Deque", + "question__title_slug": "design-circular-deque", + "question__hide": false, + "total_acs": 10674, + "total_submitted": 21098, + "frontend_question_id": 641, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 858, + "question__article__live": true, + "question__article__slug": "masking-personal-information", + "question__title": "Masking Personal Information", + "question__title_slug": "masking-personal-information", + "question__hide": false, + "total_acs": 8232, + "total_submitted": 19211, + "frontend_question_id": 831, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 857, + "question__article__live": true, + "question__article__slug": "positions-of-large-groups", + "question__title": "Positions of Large Groups", + "question__title_slug": "positions-of-large-groups", + "question__hide": false, + "total_acs": 33840, + "total_submitted": 69908, + "frontend_question_id": 830, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 856, + "question__article__live": true, + "question__article__slug": "consecutive-numbers-sum", + "question__title": "Consecutive Numbers Sum", + "question__title_slug": "consecutive-numbers-sum", + "question__hide": false, + "total_acs": 16331, + "total_submitted": 45967, + "frontend_question_id": 829, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 855, + "question__article__live": true, + "question__article__slug": "unique-letter-string", + "question__title": "Unique Letter String", + "question__title_slug": "unique-letter-string", + "question__hide": false, + "total_acs": 7217, + "total_submitted": 17098, + "frontend_question_id": 828, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 854, + "question__article__live": true, + "question__article__slug": "making-a-large-island", + "question__title": "Making A Large Island", + "question__title_slug": "making-a-large-island", + "question__hide": false, + "total_acs": 12336, + "total_submitted": 27873, + "frontend_question_id": 827, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 853, + "question__article__live": true, + "question__article__slug": "most-profit-assigning-work", + "question__title": "Most Profit Assigning Work", + "question__title_slug": "most-profit-assigning-work", + "question__hide": false, + "total_acs": 14972, + "total_submitted": 40086, + "frontend_question_id": 826, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 852, + "question__article__live": true, + "question__article__slug": "friends-of-appropriate-ages", + "question__title": "Friends Of Appropriate Ages", + "question__title_slug": "friends-of-appropriate-ages", + "question__hide": false, + "total_acs": 25178, + "total_submitted": 62389, + "frontend_question_id": 825, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 851, + "question__article__live": true, + "question__article__slug": "goat-latin", + "question__title": "Goat Latin", + "question__title_slug": "goat-latin", + "question__hide": false, + "total_acs": 44735, + "total_submitted": 74691, + "frontend_question_id": 824, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 850, + "question__article__live": true, + "question__article__slug": "insert-into-a-cyclic-sorted-list", + "question__title": "Insert into a Sorted Circular Linked List", + "question__title_slug": "insert-into-a-sorted-circular-linked-list", + "question__hide": false, + "total_acs": 24403, + "total_submitted": 78481, + "frontend_question_id": 708, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 843, + "question__article__live": true, + "question__article__slug": "binary-trees-with-factors", + "question__title": "Binary Trees With Factors", + "question__title_slug": "binary-trees-with-factors", + "question__hide": false, + "total_acs": 9140, + "total_submitted": 26728, + "frontend_question_id": 823, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 842, + "question__article__live": true, + "question__article__slug": "card-flipping-game", + "question__title": "Card Flipping Game", + "question__title_slug": "card-flipping-game", + "question__hide": false, + "total_acs": 7473, + "total_submitted": 17940, + "frontend_question_id": 822, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 841, + "question__article__live": true, + "question__article__slug": "shortest-distance-to-a-character", + "question__title": "Shortest Distance to a Character", + "question__title_slug": "shortest-distance-to-a-character", + "question__hide": false, + "total_acs": 48925, + "total_submitted": 75323, + "frontend_question_id": 821, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 839, + "question__article__live": true, + "question__article__slug": "short-encoding-of-words", + "question__title": "Short Encoding of Words", + "question__title_slug": "short-encoding-of-words", + "question__hide": false, + "total_acs": 10708, + "total_submitted": 21917, + "frontend_question_id": 820, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 838, + "question__article__live": true, + "question__article__slug": "design-linked-list", + "question__title": "Design Linked List", + "question__title_slug": "design-linked-list", + "question__hide": false, + "total_acs": 38915, + "total_submitted": 183045, + "frontend_question_id": 707, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 837, + "question__article__live": true, + "question__article__slug": "most-common-word", + "question__title": "Most Common Word", + "question__title_slug": "most-common-word", + "question__hide": false, + "total_acs": 97864, + "total_submitted": 226253, + "frontend_question_id": 819, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 836, + "question__article__live": true, + "question__article__slug": "race-car", + "question__title": "Race Car", + "question__title_slug": "race-car", + "question__hide": false, + "total_acs": 14300, + "total_submitted": 38382, + "frontend_question_id": 818, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 835, + "question__article__live": true, + "question__article__slug": "linked-list-components", + "question__title": "Linked List Components", + "question__title_slug": "linked-list-components", + "question__hide": false, + "total_acs": 32535, + "total_submitted": 58136, + "frontend_question_id": 817, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 834, + "question__article__live": true, + "question__article__slug": "ambiguous-coordinates", + "question__title": "Ambiguous Coordinates", + "question__title_slug": "ambiguous-coordinates", + "question__hide": false, + "total_acs": 8063, + "total_submitted": 17663, + "frontend_question_id": 816, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 833, + "question__article__live": true, + "question__article__slug": "bus-routes", + "question__title": "Bus Routes", + "question__title_slug": "bus-routes", + "question__hide": false, + "total_acs": 28082, + "total_submitted": 67892, + "frontend_question_id": 815, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 832, + "question__article__live": true, + "question__article__slug": "binary-tree-pruning", + "question__title": "Binary Tree Pruning", + "question__title_slug": "binary-tree-pruning", + "question__hide": false, + "total_acs": 47589, + "total_submitted": 65680, + "frontend_question_id": 814, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 831, + "question__article__live": true, + "question__article__slug": "largest-sum-of-averages", + "question__title": "Largest Sum of Averages", + "question__title_slug": "largest-sum-of-averages", + "question__hide": false, + "total_acs": 17584, + "total_submitted": 37079, + "frontend_question_id": 813, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 830, + "question__article__live": true, + "question__article__slug": "largest-triangle-area", + "question__title": "Largest Triangle Area", + "question__title_slug": "largest-triangle-area", + "question__hide": false, + "total_acs": 17827, + "total_submitted": 31224, + "frontend_question_id": 812, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 829, + "question__article__live": true, + "question__article__slug": "subdomain-visit-count", + "question__title": "Subdomain Visit Count", + "question__title_slug": "subdomain-visit-count", + "question__hide": false, + "total_acs": 62803, + "total_submitted": 93553, + "frontend_question_id": 811, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 828, + "question__article__live": true, + "question__article__slug": "chalkboard-xor-game", + "question__title": "Chalkboard XOR Game", + "question__title_slug": "chalkboard-xor-game", + "question__hide": false, + "total_acs": 3228, + "total_submitted": 7046, + "frontend_question_id": 810, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 827, + "question__article__live": true, + "question__article__slug": "expressive-words", + "question__title": "Expressive Words", + "question__title_slug": "expressive-words", + "question__hide": false, + "total_acs": 23169, + "total_submitted": 50541, + "frontend_question_id": 809, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 826, + "question__article__live": true, + "question__article__slug": "soup-servings", + "question__title": "Soup Servings", + "question__title_slug": "soup-servings", + "question__hide": false, + "total_acs": 7637, + "total_submitted": 19798, + "frontend_question_id": 808, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 825, + "question__article__live": true, + "question__article__slug": "max-increase-to-keep-city-skyline", + "question__title": "Max Increase to Keep City Skyline", + "question__title_slug": "max-increase-to-keep-city-skyline", + "question__hide": false, + "total_acs": 68424, + "total_submitted": 82966, + "frontend_question_id": 807, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 824, + "question__article__live": true, + "question__article__slug": "number-of-lines-to-write-string", + "question__title": "Number of Lines To Write String", + "question__title_slug": "number-of-lines-to-write-string", + "question__hide": false, + "total_acs": 32612, + "total_submitted": 51145, + "frontend_question_id": 806, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 823, + "question__article__live": true, + "question__article__slug": "split-array-with-same-average", + "question__title": "Split Array With Same Average", + "question__title_slug": "split-array-with-same-average", + "question__hide": false, + "total_acs": 11977, + "total_submitted": 46864, + "frontend_question_id": 805, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 822, + "question__article__live": true, + "question__article__slug": "unique-morse-code-words", + "question__title": "Unique Morse Code Words", + "question__title_slug": "unique-morse-code-words", + "question__hide": false, + "total_acs": 117429, + "total_submitted": 155322, + "frontend_question_id": 804, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 821, + "question__article__live": true, + "question__article__slug": "bricks-falling-when-hit", + "question__title": "Bricks Falling When Hit", + "question__title_slug": "bricks-falling-when-hit", + "question__hide": false, + "total_acs": 12505, + "total_submitted": 42311, + "frontend_question_id": 803, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 820, + "question__article__live": true, + "question__article__slug": "find-eventual-safe-states", + "question__title": "Find Eventual Safe States", + "question__title_slug": "find-eventual-safe-states", + "question__hide": false, + "total_acs": 26009, + "total_submitted": 56130, + "frontend_question_id": 802, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 819, + "question__article__live": true, + "question__article__slug": "minimum-swaps-to-make-sequences-increasing", + "question__title": "Minimum Swaps To Make Sequences Increasing", + "question__title_slug": "minimum-swaps-to-make-sequences-increasing", + "question__hide": false, + "total_acs": 20190, + "total_submitted": 54550, + "frontend_question_id": 801, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 818, + "question__article__live": true, + "question__article__slug": "similar-rgb-color", + "question__title": "Similar RGB Color", + "question__title_slug": "similar-rgb-color", + "question__hide": false, + "total_acs": 8990, + "total_submitted": 14811, + "frontend_question_id": 800, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 817, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design HashMap", + "question__title_slug": "design-hashmap", + "question__hide": false, + "total_acs": 57594, + "total_submitted": 99352, + "frontend_question_id": 706, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 816, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design HashSet", + "question__title_slug": "design-hashset", + "question__hide": false, + "total_acs": 32823, + "total_submitted": 57522, + "frontend_question_id": 705, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 815, + "question__article__live": true, + "question__article__slug": "champagne-tower", + "question__title": "Champagne Tower", + "question__title_slug": "champagne-tower", + "question__hide": false, + "total_acs": 11906, + "total_submitted": 34154, + "frontend_question_id": 799, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 814, + "question__article__live": true, + "question__article__slug": "smallest-rotation-with-highest-score", + "question__title": "Smallest Rotation with Highest Score", + "question__title_slug": "smallest-rotation-with-highest-score", + "question__hide": false, + "total_acs": 5061, + "total_submitted": 12085, + "frontend_question_id": 798, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 813, + "question__article__live": true, + "question__article__slug": "all-paths-from-source-to-target", + "question__title": "All Paths From Source to Target", + "question__title_slug": "all-paths-from-source-to-target", + "question__hide": false, + "total_acs": 40032, + "total_submitted": 55197, + "frontend_question_id": 797, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 812, + "question__article__live": true, + "question__article__slug": "rotate-string", + "question__title": "Rotate String", + "question__title_slug": "rotate-string", + "question__hide": false, + "total_acs": 51988, + "total_submitted": 105309, + "frontend_question_id": 796, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 811, + "question__article__live": true, + "question__article__slug": "number-of-subarrays-with-bounded-maximum", + "question__title": "Number of Subarrays with Bounded Maximum", + "question__title_slug": "number-of-subarrays-with-bounded-maximum", + "question__hide": false, + "total_acs": 14353, + "total_submitted": 32226, + "frontend_question_id": 795, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 810, + "question__article__live": true, + "question__article__slug": "valid-tic-tac-toe-state", + "question__title": "Valid Tic-Tac-Toe State", + "question__title_slug": "valid-tic-tac-toe-state", + "question__hide": false, + "total_acs": 18628, + "total_submitted": 58773, + "frontend_question_id": 794, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 809, + "question__article__live": true, + "question__article__slug": "preimage-size-of-factorial-zeroes-function", + "question__title": "Preimage Size of Factorial Zeroes Function", + "question__title_slug": "preimage-size-of-factorial-zeroes-function", + "question__hide": false, + "total_acs": 6630, + "total_submitted": 16729, + "frontend_question_id": 793, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 808, + "question__article__live": true, + "question__article__slug": "number-of-matching-subsequences", + "question__title": "Number of Matching Subsequences", + "question__title_slug": "number-of-matching-subsequences", + "question__hide": false, + "total_acs": 28884, + "total_submitted": 63116, + "frontend_question_id": 792, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 807, + "question__article__live": true, + "question__article__slug": "custom-sort-string", + "question__title": "Custom Sort String", + "question__title_slug": "custom-sort-string", + "question__hide": false, + "total_acs": 46954, + "total_submitted": 73488, + "frontend_question_id": 791, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 806, + "question__article__live": true, + "question__article__slug": "domino-and-tromino-tiling", + "question__title": "Domino and Tromino Tiling", + "question__title_slug": "domino-and-tromino-tiling", + "question__hide": false, + "total_acs": 10772, + "total_submitted": 28774, + "frontend_question_id": 790, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 805, + "question__article__live": true, + "question__article__slug": "escape-the-ghosts", + "question__title": "Escape The Ghosts", + "question__title_slug": "escape-the-ghosts", + "question__hide": false, + "total_acs": 12193, + "total_submitted": 21717, + "frontend_question_id": 789, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 804, + "question__article__live": true, + "question__article__slug": "rotated-digits", + "question__title": "Rotated Digits", + "question__title_slug": "rotated-digits", + "question__hide": false, + "total_acs": 37828, + "total_submitted": 67691, + "frontend_question_id": 788, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 803, + "question__article__live": true, + "question__article__slug": "cheapest-flights-within-k-stops", + "question__title": "Cheapest Flights Within K Stops", + "question__title_slug": "cheapest-flights-within-k-stops", + "question__hide": false, + "total_acs": 60239, + "total_submitted": 163917, + "frontend_question_id": 787, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 802, + "question__article__live": true, + "question__article__slug": "k-th-smallest-prime-fraction", + "question__title": "K-th Smallest Prime Fraction", + "question__title_slug": "k-th-smallest-prime-fraction", + "question__hide": false, + "total_acs": 10290, + "total_submitted": 24818, + "frontend_question_id": 786, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 801, + "question__article__live": true, + "question__article__slug": "is-graph-bipartite", + "question__title": "Is Graph Bipartite?", + "question__title_slug": "is-graph-bipartite", + "question__hide": false, + "total_acs": 71133, + "total_submitted": 156503, + "frontend_question_id": 785, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 800, + "question__article__live": true, + "question__article__slug": "letter-case-permutation", + "question__title": "Letter Case Permutation", + "question__title_slug": "letter-case-permutation", + "question__hide": false, + "total_acs": 64656, + "total_submitted": 107039, + "frontend_question_id": 784, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 799, + "question__article__live": true, + "question__article__slug": "minimum-distance-between-bst-nodes", + "question__title": "Minimum Distance Between BST Nodes", + "question__title_slug": "minimum-distance-between-bst-nodes", + "question__hide": false, + "total_acs": 45183, + "total_submitted": 88452, + "frontend_question_id": 783, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 798, + "question__article__live": true, + "question__article__slug": "transform-to-chessboard", + "question__title": "Transform to Chessboard", + "question__title_slug": "transform-to-chessboard", + "question__hide": false, + "total_acs": 3722, + "total_submitted": 9145, + "frontend_question_id": 782, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 797, + "question__article__live": true, + "question__article__slug": "rabbits-in-forest", + "question__title": "Rabbits in Forest", + "question__title_slug": "rabbits-in-forest", + "question__hide": false, + "total_acs": 16222, + "total_submitted": 30683, + "frontend_question_id": 781, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 796, + "question__article__live": true, + "question__article__slug": "reaching-points", + "question__title": "Reaching Points", + "question__title_slug": "reaching-points", + "question__hide": false, + "total_acs": 13463, + "total_submitted": 47261, + "frontend_question_id": 780, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 795, + "question__article__live": true, + "question__article__slug": "k-th-symbol-in-grammar", + "question__title": "K-th Symbol in Grammar", + "question__title_slug": "k-th-symbol-in-grammar", + "question__hide": false, + "total_acs": 21067, + "total_submitted": 56439, + "frontend_question_id": 779, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 794, + "question__article__live": true, + "question__article__slug": "swim-in-rising-water", + "question__title": "Swim in Rising Water", + "question__title_slug": "swim-in-rising-water", + "question__hide": false, + "total_acs": 16845, + "total_submitted": 33781, + "frontend_question_id": 778, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 793, + "question__article__live": true, + "question__article__slug": "swap-adjacent-in-lr-string", + "question__title": "Swap Adjacent in LR String", + "question__title_slug": "swap-adjacent-in-lr-string", + "question__hide": false, + "total_acs": 19078, + "total_submitted": 55788, + "frontend_question_id": 777, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 792, + "question__article__live": true, + "question__article__slug": "binary-search", + "question__title": "Binary Search", + "question__title_slug": "binary-search", + "question__hide": false, + "total_acs": 86519, + "total_submitted": 173220, + "frontend_question_id": 704, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 791, + "question__article__live": true, + "question__article__slug": "split-bst", + "question__title": "Split BST", + "question__title_slug": "split-bst", + "question__hide": false, + "total_acs": 13191, + "total_submitted": 24561, + "frontend_question_id": 776, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 790, + "question__article__live": true, + "question__article__slug": "global-and-local-inversions", + "question__title": "Global and Local Inversions", + "question__title_slug": "global-and-local-inversions", + "question__hide": false, + "total_acs": 15766, + "total_submitted": 39096, + "frontend_question_id": 775, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 789, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Kth Largest Element in a Stream", + "question__title_slug": "kth-largest-element-in-a-stream", + "question__hide": false, + "total_acs": 51416, + "total_submitted": 107993, + "frontend_question_id": 703, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 788, + "question__article__live": true, + "question__article__slug": "minimize-max-distance-to-gas-station", + "question__title": "Minimize Max Distance to Gas Station", + "question__title_slug": "minimize-max-distance-to-gas-station", + "question__hide": false, + "total_acs": 12401, + "total_submitted": 28021, + "frontend_question_id": 774, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 787, + "question__article__live": true, + "question__article__slug": "sliding-puzzle", + "question__title": "Sliding Puzzle", + "question__title_slug": "sliding-puzzle", + "question__hide": false, + "total_acs": 23892, + "total_submitted": 42928, + "frontend_question_id": 773, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 786, + "question__article__live": true, + "question__article__slug": "search-in-a-sorted-array-of-unknown-size", + "question__title": "Search in a Sorted Array of Unknown Size", + "question__title_slug": "search-in-a-sorted-array-of-unknown-size", + "question__hide": false, + "total_acs": 16321, + "total_submitted": 25925, + "frontend_question_id": 702, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 785, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Basic Calculator III", + "question__title_slug": "basic-calculator-iii", + "question__hide": false, + "total_acs": 26161, + "total_submitted": 63836, + "frontend_question_id": 772, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 784, + "question__article__live": true, + "question__article__slug": "insert-into-a-bst", + "question__title": "Insert into a Binary Search Tree", + "question__title_slug": "insert-into-a-binary-search-tree", + "question__hide": false, + "total_acs": 72770, + "total_submitted": 93369, + "frontend_question_id": 701, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 783, + "question__article__live": true, + "question__article__slug": "search-in-a-bst", + "question__title": "Search in a Binary Search Tree", + "question__title_slug": "search-in-a-binary-search-tree", + "question__hide": false, + "total_acs": 94432, + "total_submitted": 135240, + "frontend_question_id": 700, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 782, + "question__article__live": true, + "question__article__slug": "jewels-and-stones", + "question__title": "Jewels and Stones", + "question__title_slug": "jewels-and-stones", + "question__hide": false, + "total_acs": 358309, + "total_submitted": 425917, + "frontend_question_id": 771, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 781, + "question__article__live": true, + "question__article__slug": "basic-calculator-iv", + "question__title": "Basic Calculator IV", + "question__title_slug": "basic-calculator-iv", + "question__hide": false, + "total_acs": 2906, + "total_submitted": 6263, + "frontend_question_id": 770, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 780, + "question__article__live": true, + "question__article__slug": "max-chunks-to-make-sorted-i", + "question__title": "Max Chunks To Make Sorted", + "question__title_slug": "max-chunks-to-make-sorted", + "question__hide": false, + "total_acs": 29656, + "total_submitted": 55705, + "frontend_question_id": 769, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 779, + "question__article__live": true, + "question__article__slug": "max-chunks-to-make-sorted-ii", + "question__title": "Max Chunks To Make Sorted II", + "question__title_slug": "max-chunks-to-make-sorted-ii", + "question__hide": false, + "total_acs": 15980, + "total_submitted": 33816, + "frontend_question_id": 768, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 778, + "question__article__live": true, + "question__article__slug": "reorganized-string", + "question__title": "Reorganize String", + "question__title_slug": "reorganize-string", + "question__hide": false, + "total_acs": 42769, + "total_submitted": 94524, + "frontend_question_id": 767, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 777, + "question__article__live": true, + "question__article__slug": "toeplitz-matrix", + "question__title": "Toeplitz Matrix", + "question__title_slug": "toeplitz-matrix", + "question__hide": false, + "total_acs": 74817, + "total_submitted": 118806, + "frontend_question_id": 766, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 776, + "question__article__live": true, + "question__article__slug": "n-ary-tree-postorder-transversal", + "question__title": "N-ary Tree Postorder Traversal", + "question__title_slug": "n-ary-tree-postorder-traversal", + "question__hide": false, + "total_acs": 61844, + "total_submitted": 88955, + "frontend_question_id": 590, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 775, + "question__article__live": true, + "question__article__slug": "n-ary-tree-preorder-traversal", + "question__title": "N-ary Tree Preorder Traversal", + "question__title_slug": "n-ary-tree-preorder-traversal", + "question__hide": false, + "total_acs": 69408, + "total_submitted": 99920, + "frontend_question_id": 589, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 774, + "question__article__live": true, + "question__article__slug": "maximum-depth-of-n-ary-tree", + "question__title": "Maximum Depth of N-ary Tree", + "question__title_slug": "maximum-depth-of-n-ary-tree", + "question__hide": false, + "total_acs": 77063, + "total_submitted": 115672, + "frontend_question_id": 559, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 773, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Quad Tree Intersection", + "question__title_slug": "quad-tree-intersection", + "question__hide": false, + "total_acs": 7034, + "total_submitted": 16362, + "frontend_question_id": 558, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 772, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Construct Quad Tree", + "question__title_slug": "construct-quad-tree", + "question__hide": false, + "total_acs": 17644, + "total_submitted": 29679, + "frontend_question_id": 427, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 771, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Encode N-ary Tree to Binary Tree", + "question__title_slug": "encode-n-ary-tree-to-binary-tree", + "question__hide": false, + "total_acs": 4010, + "total_submitted": 5911, + "frontend_question_id": 431, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 770, + "question__article__live": true, + "question__article__slug": "couples-holding-hands", + "question__title": "Couples Holding Hands", + "question__title_slug": "couples-holding-hands", + "question__hide": false, + "total_acs": 19068, + "total_submitted": 35986, + "frontend_question_id": 765, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 769, + "question__article__live": true, + "question__article__slug": "largest-plus-sign", + "question__title": "Largest Plus Sign", + "question__title_slug": "largest-plus-sign", + "question__hide": false, + "total_acs": 16489, + "total_submitted": 36704, + "frontend_question_id": 764, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 768, + "question__article__live": true, + "question__article__slug": "partition-labels", + "question__title": "Partition Labels", + "question__title_slug": "partition-labels", + "question__hide": false, + "total_acs": 79910, + "total_submitted": 109396, + "frontend_question_id": 763, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 767, + "question__article__live": true, + "question__article__slug": "prime-number-of-set-bits-in-binary-representation", + "question__title": "Prime Number of Set Bits in Binary Representation", + "question__title_slug": "prime-number-of-set-bits-in-binary-representation", + "question__hide": false, + "total_acs": 35489, + "total_submitted": 58213, + "frontend_question_id": 762, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 766, + "question__article__live": true, + "question__article__slug": "flatten-a-multilevel-doubly-linked-list", + "question__title": "Flatten a Multilevel Doubly Linked List", + "question__title_slug": "flatten-a-multilevel-doubly-linked-list", + "question__hide": false, + "total_acs": 45032, + "total_submitted": 96883, + "frontend_question_id": 430, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 765, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Serialize and Deserialize N-ary Tree", + "question__title_slug": "serialize-and-deserialize-n-ary-tree", + "question__hide": false, + "total_acs": 21004, + "total_submitted": 37155, + "frontend_question_id": 428, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 764, + "question__article__live": true, + "question__article__slug": "n-ary-tree-level-order-traversal", + "question__title": "N-ary Tree Level Order Traversal", + "question__title_slug": "n-ary-tree-level-order-traversal", + "question__hide": false, + "total_acs": 53371, + "total_submitted": 86788, + "frontend_question_id": 429, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 763, + "question__article__live": true, + "question__article__slug": "special-binary-string", + "question__title": "Special Binary String", + "question__title_slug": "special-binary-string", + "question__hide": false, + "total_acs": 6284, + "total_submitted": 11690, + "frontend_question_id": 761, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 762, + "question__article__live": true, + "question__article__slug": "find-anagram-mappings", + "question__title": "Find Anagram Mappings", + "question__title_slug": "find-anagram-mappings", + "question__hide": false, + "total_acs": 52293, + "total_submitted": 65265, + "frontend_question_id": 760, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 761, + "question__article__live": true, + "question__article__slug": "employee-free-time", + "question__title": "Employee Free Time", + "question__title_slug": "employee-free-time", + "question__hide": false, + "total_acs": 23910, + "total_submitted": 37648, + "frontend_question_id": 759, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 760, + "question__article__live": true, + "question__article__slug": "bold-words-in-string", + "question__title": "Bold Words in String", + "question__title_slug": "bold-words-in-string", + "question__hide": false, + "total_acs": 8914, + "total_submitted": 20304, + "frontend_question_id": 758, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 759, + "question__article__live": true, + "question__article__slug": "set-intersection-size-at-least-two", + "question__title": "Set Intersection Size At Least Two", + "question__title_slug": "set-intersection-size-at-least-two", + "question__hide": false, + "total_acs": 5454, + "total_submitted": 14637, + "frontend_question_id": 757, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 758, + "question__article__live": true, + "question__article__slug": "convert-binary-search-tree-to-sorted-doubly-linked", + "question__title": "Convert Binary Search Tree to Sorted Doubly Linked List", + "question__title_slug": "convert-binary-search-tree-to-sorted-doubly-linked-list", + "question__hide": false, + "total_acs": 50184, + "total_submitted": 90017, + "frontend_question_id": 426, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 757, + "question__article__live": true, + "question__article__slug": "pyramid-transition-matrix", + "question__title": "Pyramid Transition Matrix", + "question__title_slug": "pyramid-transition-matrix", + "question__hide": false, + "total_acs": 17060, + "total_submitted": 32142, + "frontend_question_id": 756, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 756, + "question__article__live": true, + "question__article__slug": "pour-water", + "question__title": "Pour Water", + "question__title_slug": "pour-water", + "question__hide": false, + "total_acs": 17909, + "total_submitted": 42032, + "frontend_question_id": 755, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 755, + "question__article__live": true, + "question__article__slug": "reach-a-number", + "question__title": "Reach a Number", + "question__title_slug": "reach-a-number", + "question__hide": false, + "total_acs": 14010, + "total_submitted": 41492, + "frontend_question_id": 754, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 754, + "question__article__live": true, + "question__article__slug": "cracking-the-safe", + "question__title": "Cracking the Safe", + "question__title_slug": "cracking-the-safe", + "question__hide": false, + "total_acs": 21645, + "total_submitted": 44228, + "frontend_question_id": 753, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 753, + "question__article__live": true, + "question__article__slug": "open-the-lock", + "question__title": "Open the Lock", + "question__title_slug": "open-the-lock", + "question__hide": false, + "total_acs": 32668, + "total_submitted": 67746, + "frontend_question_id": 752, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 752, + "question__article__live": true, + "question__article__slug": "ip-to-cidr", + "question__title": "IP to CIDR", + "question__title_slug": "ip-to-cidr", + "question__hide": false, + "total_acs": 9806, + "total_submitted": 15931, + "frontend_question_id": 751, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 751, + "question__article__live": true, + "question__article__slug": "number-of-corner-rectangles", + "question__title": "Number Of Corner Rectangles", + "question__title_slug": "number-of-corner-rectangles", + "question__hide": false, + "total_acs": 22966, + "total_submitted": 34835, + "frontend_question_id": 750, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 750, + "question__article__live": true, + "question__article__slug": "contain-virus", + "question__title": "Contain Virus", + "question__title_slug": "contain-virus", + "question__hide": false, + "total_acs": 3478, + "total_submitted": 8216, + "frontend_question_id": 749, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 749, + "question__article__live": true, + "question__article__slug": "shortest-completing-word", + "question__title": "Shortest Completing Word", + "question__title_slug": "shortest-completing-word", + "question__hide": false, + "total_acs": 26469, + "total_submitted": 47480, + "frontend_question_id": 748, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 748, + "question__article__live": true, + "question__article__slug": "largest-number-at-least-twice-of-others", + "question__title": "Largest Number At Least Twice of Others", + "question__title_slug": "largest-number-at-least-twice-of-others", + "question__hide": false, + "total_acs": 66819, + "total_submitted": 163005, + "frontend_question_id": 747, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 747, + "question__article__live": true, + "question__article__slug": "min-cost-climbing-stairs", + "question__title": "Min Cost Climbing Stairs", + "question__title_slug": "min-cost-climbing-stairs", + "question__hide": false, + "total_acs": 109164, + "total_submitted": 225168, + "frontend_question_id": 746, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 746, + "question__article__live": true, + "question__article__slug": "prefix-and-suffix-search", + "question__title": "Prefix and Suffix Search", + "question__title_slug": "prefix-and-suffix-search", + "question__hide": false, + "total_acs": 15137, + "total_submitted": 46754, + "frontend_question_id": 745, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 745, + "question__article__live": true, + "question__article__slug": "find-smallest-letter-greater-than-target", + "question__title": "Find Smallest Letter Greater Than Target", + "question__title_slug": "find-smallest-letter-greater-than-target", + "question__hide": false, + "total_acs": 54137, + "total_submitted": 121353, + "frontend_question_id": 744, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 744, + "question__article__live": true, + "question__article__slug": "network-delay-time", + "question__title": "Network Delay Time", + "question__title_slug": "network-delay-time", + "question__hide": false, + "total_acs": 56897, + "total_submitted": 127025, + "frontend_question_id": 743, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 743, + "question__article__live": true, + "question__article__slug": "closest-leaf-in-binary-tree", + "question__title": "Closest Leaf in a Binary Tree", + "question__title_slug": "closest-leaf-in-a-binary-tree", + "question__hide": false, + "total_acs": 15051, + "total_submitted": 36265, + "frontend_question_id": 742, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 742, + "question__article__live": null, + "question__article__slug": null, + "question__title": "To Lower Case", + "question__title_slug": "to-lower-case", + "question__hide": false, + "total_acs": 165436, + "total_submitted": 211862, + "frontend_question_id": 709, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 741, + "question__article__live": true, + "question__article__slug": "cherry-pickup", + "question__title": "Cherry Pickup", + "question__title_slug": "cherry-pickup", + "question__hide": false, + "total_acs": 16830, + "total_submitted": 51796, + "frontend_question_id": 741, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 740, + "question__article__live": true, + "question__article__slug": "delete-and-earn", + "question__title": "Delete and Earn", + "question__title_slug": "delete-and-earn", + "question__hide": false, + "total_acs": 28314, + "total_submitted": 59613, + "frontend_question_id": 740, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 739, + "question__article__live": true, + "question__article__slug": "daily-temperatures", + "question__title": "Daily Temperatures", + "question__title_slug": "daily-temperatures", + "question__hide": false, + "total_acs": 105448, + "total_submitted": 171829, + "frontend_question_id": 739, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 738, + "question__article__live": true, + "question__article__slug": "monotone-increasing-digits", + "question__title": "Monotone Increasing Digits", + "question__title_slug": "monotone-increasing-digits", + "question__hide": false, + "total_acs": 17015, + "total_submitted": 39705, + "frontend_question_id": 738, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 737, + "question__article__live": true, + "question__article__slug": "sentence-similarity-ii", + "question__title": "Sentence Similarity II", + "question__title_slug": "sentence-similarity-ii", + "question__hide": false, + "total_acs": 31116, + "total_submitted": 69580, + "frontend_question_id": 737, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 736, + "question__article__live": true, + "question__article__slug": "parse-lisp-expression", + "question__title": "Parse Lisp Expression", + "question__title_slug": "parse-lisp-expression", + "question__hide": false, + "total_acs": 8916, + "total_submitted": 19433, + "frontend_question_id": 736, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 735, + "question__article__live": true, + "question__article__slug": "asteroid-collision", + "question__title": "Asteroid Collision", + "question__title_slug": "asteroid-collision", + "question__hide": false, + "total_acs": 38250, + "total_submitted": 96704, + "frontend_question_id": 735, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 734, + "question__article__live": true, + "question__article__slug": "sentence-similarity", + "question__title": "Sentence Similarity", + "question__title_slug": "sentence-similarity", + "question__hide": false, + "total_acs": 28420, + "total_submitted": 68765, + "frontend_question_id": 734, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 733, + "question__article__live": true, + "question__article__slug": "flood-fill", + "question__title": "Flood Fill", + "question__title_slug": "flood-fill", + "question__hide": false, + "total_acs": 75799, + "total_submitted": 144467, + "frontend_question_id": 733, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 732, + "question__article__live": true, + "question__article__slug": "my-calendar-iii", + "question__title": "My Calendar III", + "question__title_slug": "my-calendar-iii", + "question__hide": false, + "total_acs": 16440, + "total_submitted": 28635, + "frontend_question_id": 732, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 731, + "question__article__live": true, + "question__article__slug": "my-calendar-ii", + "question__title": "My Calendar II", + "question__title_slug": "my-calendar-ii", + "question__hide": false, + "total_acs": 31463, + "total_submitted": 67052, + "frontend_question_id": 731, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 730, + "question__article__live": true, + "question__article__slug": "count-different-palindromic-subsequences", + "question__title": "Count Different Palindromic Subsequences", + "question__title_slug": "count-different-palindromic-subsequences", + "question__hide": false, + "total_acs": 11325, + "total_submitted": 28044, + "frontend_question_id": 730, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 729, + "question__article__live": true, + "question__article__slug": "my-calendar-i", + "question__title": "My Calendar I", + "question__title_slug": "my-calendar-i", + "question__hide": false, + "total_acs": 41864, + "total_submitted": 84815, + "frontend_question_id": 729, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 728, + "question__article__live": true, + "question__article__slug": "self-dividing-numbers", + "question__title": "Self Dividing Numbers", + "question__title_slug": "self-dividing-numbers", + "question__hide": false, + "total_acs": 102722, + "total_submitted": 142204, + "frontend_question_id": 728, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 727, + "question__article__live": true, + "question__article__slug": "minimum-window-subsequence", + "question__title": "Minimum Window Subsequence", + "question__title_slug": "minimum-window-subsequence", + "question__hide": false, + "total_acs": 23103, + "total_submitted": 58208, + "frontend_question_id": 727, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 726, + "question__article__live": true, + "question__article__slug": "number-of-atoms", + "question__title": "Number of Atoms", + "question__title_slug": "number-of-atoms", + "question__hide": false, + "total_acs": 14443, + "total_submitted": 31133, + "frontend_question_id": 726, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 725, + "question__article__live": true, + "question__article__slug": "split-linked-list-in-parts", + "question__title": "Split Linked List in Parts", + "question__title_slug": "split-linked-list-in-parts", + "question__hide": false, + "total_acs": 35238, + "total_submitted": 70148, + "frontend_question_id": 725, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 724, + "question__article__live": true, + "question__article__slug": "find-pivot-index", + "question__title": "Find Pivot Index", + "question__title_slug": "find-pivot-index", + "question__hide": false, + "total_acs": 95670, + "total_submitted": 226154, + "frontend_question_id": 724, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 723, + "question__article__live": true, + "question__article__slug": "candy-crush", + "question__title": "Candy Crush", + "question__title_slug": "candy-crush", + "question__hide": false, + "total_acs": 13673, + "total_submitted": 20622, + "frontend_question_id": 723, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 722, + "question__article__live": true, + "question__article__slug": "remove-comments", + "question__title": "Remove Comments", + "question__title_slug": "remove-comments", + "question__hide": false, + "total_acs": 19915, + "total_submitted": 61148, + "frontend_question_id": 722, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 721, + "question__article__live": true, + "question__article__slug": "accounts-merge", + "question__title": "Accounts Merge", + "question__title_slug": "accounts-merge", + "question__hide": false, + "total_acs": 52213, + "total_submitted": 117891, + "frontend_question_id": 721, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 720, + "question__article__live": true, + "question__article__slug": "longest-word-in-dictionary", + "question__title": "Longest Word in Dictionary", + "question__title_slug": "longest-word-in-dictionary", + "question__hide": false, + "total_acs": 46315, + "total_submitted": 99599, + "frontend_question_id": 720, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 719, + "question__article__live": true, + "question__article__slug": "find-k-th-smallest-pair-distance", + "question__title": "Find K-th Smallest Pair Distance", + "question__title_slug": "find-k-th-smallest-pair-distance", + "question__hide": false, + "total_acs": 24633, + "total_submitted": 81481, + "frontend_question_id": 719, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 718, + "question__article__live": true, + "question__article__slug": "maximum-length-of-repeated-subarray", + "question__title": "Maximum Length of Repeated Subarray", + "question__title_slug": "maximum-length-of-repeated-subarray", + "question__hide": false, + "total_acs": 45748, + "total_submitted": 95245, + "frontend_question_id": 718, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 717, + "question__article__live": true, + "question__article__slug": "1-bit-and-2-bit-characters", + "question__title": "1-bit and 2-bit Characters", + "question__title_slug": "1-bit-and-2-bit-characters", + "question__hide": false, + "total_acs": 49730, + "total_submitted": 101207, + "frontend_question_id": 717, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 716, + "question__article__live": true, + "question__article__slug": "max-stack", + "question__title": "Max Stack", + "question__title_slug": "max-stack", + "question__hide": false, + "total_acs": 38990, + "total_submitted": 93842, + "frontend_question_id": 716, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 715, + "question__article__live": true, + "question__article__slug": "range-module", + "question__title": "Range Module", + "question__title_slug": "range-module", + "question__hide": false, + "total_acs": 14846, + "total_submitted": 39951, + "frontend_question_id": 715, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 714, + "question__article__live": true, + "question__article__slug": "best-time-to-buy-and-sell-stock-with-transaction-fee", + "question__title": "Best Time to Buy and Sell Stock with Transaction Fee", + "question__title_slug": "best-time-to-buy-and-sell-stock-with-transaction-fee", + "question__hide": false, + "total_acs": 51771, + "total_submitted": 98761, + "frontend_question_id": 714, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 713, + "question__article__live": true, + "question__article__slug": "subarray-product-less-than-k", + "question__title": "Subarray Product Less Than K", + "question__title_slug": "subarray-product-less-than-k", + "question__hide": false, + "total_acs": 42885, + "total_submitted": 112253, + "frontend_question_id": 713, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 712, + "question__article__live": true, + "question__article__slug": "minimum-ascii-delete-sum-for-two-strings", + "question__title": "Minimum ASCII Delete Sum for Two Strings", + "question__title_slug": "minimum-ascii-delete-sum-for-two-strings", + "question__hide": false, + "total_acs": 26099, + "total_submitted": 46376, + "frontend_question_id": 712, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 711, + "question__article__live": true, + "question__article__slug": "number-of-distinct-islands-ii", + "question__title": "Number of Distinct Islands II", + "question__title_slug": "number-of-distinct-islands-ii", + "question__hide": false, + "total_acs": 4719, + "total_submitted": 9803, + "frontend_question_id": 711, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 699, + "question__article__live": true, + "question__article__slug": "falling-squares", + "question__title": "Falling Squares", + "question__title_slug": "falling-squares", + "question__hide": false, + "total_acs": 10897, + "total_submitted": 26742, + "frontend_question_id": 699, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 698, + "question__article__live": true, + "question__article__slug": "partition-to-k-equal-sum-subsets", + "question__title": "Partition to K Equal Sum Subsets", + "question__title_slug": "partition-to-k-equal-sum-subsets", + "question__hide": false, + "total_acs": 61095, + "total_submitted": 138265, + "frontend_question_id": 698, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 697, + "question__article__live": true, + "question__article__slug": "degree-of-an-array", + "question__title": "Degree of an Array", + "question__title_slug": "degree-of-an-array", + "question__hide": false, + "total_acs": 65270, + "total_submitted": 124989, + "frontend_question_id": 697, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 696, + "question__article__live": true, + "question__article__slug": "count-binary-substrings", + "question__title": "Count Binary Substrings", + "question__title_slug": "count-binary-substrings", + "question__hide": false, + "total_acs": 37297, + "total_submitted": 68353, + "frontend_question_id": 696, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 695, + "question__article__live": true, + "question__article__slug": "max-area-of-island", + "question__title": "Max Area of Island", + "question__title_slug": "max-area-of-island", + "question__hide": false, + "total_acs": 111037, + "total_submitted": 185966, + "frontend_question_id": 695, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 694, + "question__article__live": true, + "question__article__slug": "number-of-distinct-islands", + "question__title": "Number of Distinct Islands", + "question__title_slug": "number-of-distinct-islands", + "question__hide": false, + "total_acs": 37239, + "total_submitted": 69911, + "frontend_question_id": 694, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 693, + "question__article__live": true, + "question__article__slug": "binary-number-with-alternating-bits", + "question__title": "Binary Number with Alternating Bits", + "question__title_slug": "binary-number-with-alternating-bits", + "question__hide": false, + "total_acs": 50030, + "total_submitted": 85477, + "frontend_question_id": 693, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 692, + "question__article__live": true, + "question__article__slug": "top-k-frequent-words", + "question__title": "Top K Frequent Words", + "question__title_slug": "top-k-frequent-words", + "question__hide": false, + "total_acs": 101468, + "total_submitted": 210745, + "frontend_question_id": 692, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 691, + "question__article__live": true, + "question__article__slug": "stickers-to-spell-word", + "question__title": "Stickers to Spell Word", + "question__title_slug": "stickers-to-spell-word", + "question__hide": false, + "total_acs": 11630, + "total_submitted": 28687, + "frontend_question_id": 691, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 690, + "question__article__live": true, + "question__article__slug": "employee-importance", + "question__title": "Employee Importance", + "question__title_slug": "employee-importance", + "question__hide": false, + "total_acs": 56938, + "total_submitted": 102907, + "frontend_question_id": 690, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 689, + "question__article__live": true, + "question__article__slug": "maximum-sum-of-3-non-overlapping-intervals", + "question__title": "Maximum Sum of 3 Non-Overlapping Subarrays", + "question__title_slug": "maximum-sum-of-3-non-overlapping-subarrays", + "question__hide": false, + "total_acs": 30848, + "total_submitted": 68867, + "frontend_question_id": 689, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 688, + "question__article__live": true, + "question__article__slug": "knight-probability-in-chessboard", + "question__title": "Knight Probability in Chessboard", + "question__title_slug": "knight-probability-in-chessboard", + "question__hide": false, + "total_acs": 29429, + "total_submitted": 63309, + "frontend_question_id": 688, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 687, + "question__article__live": true, + "question__article__slug": "longest-univalue-path", + "question__title": "Longest Univalue Path", + "question__title_slug": "longest-univalue-path", + "question__hide": false, + "total_acs": 72645, + "total_submitted": 208780, + "frontend_question_id": 687, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 686, + "question__article__live": true, + "question__article__slug": "repeated-string-match", + "question__title": "Repeated String Match", + "question__title_slug": "repeated-string-match", + "question__hide": false, + "total_acs": 79565, + "total_submitted": 249308, + "frontend_question_id": 686, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 685, + "question__article__live": true, + "question__article__slug": "redundant-connection-ii", + "question__title": "Redundant Connection II", + "question__title_slug": "redundant-connection-ii", + "question__hide": false, + "total_acs": 28549, + "total_submitted": 89864, + "frontend_question_id": 685, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 684, + "question__article__live": true, + "question__article__slug": "redundant-connection", + "question__title": "Redundant Connection", + "question__title_slug": "redundant-connection", + "question__hide": false, + "total_acs": 69201, + "total_submitted": 126931, + "frontend_question_id": 684, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 683, + "question__article__live": true, + "question__article__slug": "k-empty-slots", + "question__title": "K Empty Slots", + "question__title_slug": "k-empty-slots", + "question__hide": false, + "total_acs": 41888, + "total_submitted": 119936, + "frontend_question_id": 683, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 682, + "question__article__live": true, + "question__article__slug": "baseball-game", + "question__title": "Baseball Game", + "question__title_slug": "baseball-game", + "question__hide": false, + "total_acs": 63504, + "total_submitted": 102452, + "frontend_question_id": 682, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 681, + "question__article__live": true, + "question__article__slug": "next-closest-time", + "question__title": "Next Closest Time", + "question__title_slug": "next-closest-time", + "question__hide": false, + "total_acs": 52515, + "total_submitted": 120728, + "frontend_question_id": 681, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 680, + "question__article__live": true, + "question__article__slug": "valid-palindrome-ii", + "question__title": "Valid Palindrome II", + "question__title_slug": "valid-palindrome-ii", + "question__hide": false, + "total_acs": 109061, + "total_submitted": 308034, + "frontend_question_id": 680, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 679, + "question__article__live": true, + "question__article__slug": "24-game", + "question__title": "24 Game", + "question__title_slug": "24-game", + "question__hide": false, + "total_acs": 27296, + "total_submitted": 61457, + "frontend_question_id": 679, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 678, + "question__article__live": true, + "question__article__slug": "valid-parenthesis-string", + "question__title": "Valid Parenthesis String", + "question__title_slug": "valid-parenthesis-string", + "question__hide": false, + "total_acs": 36379, + "total_submitted": 108418, + "frontend_question_id": 678, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 677, + "question__article__live": true, + "question__article__slug": "map-sum-pairs", + "question__title": "Map Sum Pairs", + "question__title_slug": "map-sum-pairs", + "question__hide": false, + "total_acs": 32029, + "total_submitted": 60985, + "frontend_question_id": 677, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 676, + "question__article__live": true, + "question__article__slug": "implement-magic-dictionary", + "question__title": "Implement Magic Dictionary", + "question__title_slug": "implement-magic-dictionary", + "question__hide": false, + "total_acs": 30866, + "total_submitted": 58603, + "frontend_question_id": 676, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 675, + "question__article__live": true, + "question__article__slug": "cutoff-trees-for-golf-event", + "question__title": "Cut Off Trees for Golf Event", + "question__title_slug": "cut-off-trees-for-golf-event", + "question__hide": false, + "total_acs": 23013, + "total_submitted": 69795, + "frontend_question_id": 675, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 674, + "question__article__live": true, + "question__article__slug": "longest-continuous-increasing-subsequence", + "question__title": "Longest Continuous Increasing Subsequence", + "question__title_slug": "longest-continuous-increasing-subsequence", + "question__hide": false, + "total_acs": 83804, + "total_submitted": 185929, + "frontend_question_id": 674, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 673, + "question__article__live": true, + "question__article__slug": "number-of-longest-increasing-subsequence", + "question__title": "Number of Longest Increasing Subsequence", + "question__title_slug": "number-of-longest-increasing-subsequence", + "question__hide": false, + "total_acs": 38363, + "total_submitted": 111189, + "frontend_question_id": 673, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 672, + "question__article__live": true, + "question__article__slug": "bulb-switcher-ii", + "question__title": "Bulb Switcher II", + "question__title_slug": "bulb-switcher-ii", + "question__hide": false, + "total_acs": 10871, + "total_submitted": 21602, + "frontend_question_id": 672, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 671, + "question__article__live": true, + "question__article__slug": "second-minimum-node-in-a-binary-tree", + "question__title": "Second Minimum Node In a Binary Tree", + "question__title_slug": "second-minimum-node-in-a-binary-tree", + "question__hide": false, + "total_acs": 60832, + "total_submitted": 141285, + "frontend_question_id": 671, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 670, + "question__article__live": true, + "question__article__slug": "maximum-swap", + "question__title": "Maximum Swap", + "question__title_slug": "maximum-swap", + "question__hide": false, + "total_acs": 47406, + "total_submitted": 114848, + "frontend_question_id": 670, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 669, + "question__article__live": true, + "question__article__slug": "trim-a-binary-search-tree", + "question__title": "Trim a Binary Search Tree", + "question__title_slug": "trim-a-binary-search-tree", + "question__hide": false, + "total_acs": 80813, + "total_submitted": 131779, + "frontend_question_id": 669, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 668, + "question__article__live": true, + "question__article__slug": "kth-smallest-number-in-multiplication-table", + "question__title": "Kth Smallest Number in Multiplication Table", + "question__title_slug": "kth-smallest-number-in-multiplication-table", + "question__hide": false, + "total_acs": 16348, + "total_submitted": 37338, + "frontend_question_id": 668, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 667, + "question__article__live": true, + "question__article__slug": "beautiful-arrangement-ii", + "question__title": "Beautiful Arrangement II", + "question__title_slug": "beautiful-arrangement-ii", + "question__hide": false, + "total_acs": 20708, + "total_submitted": 39094, + "frontend_question_id": 667, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 666, + "question__article__live": true, + "question__article__slug": "path-sum-iv", + "question__title": "Path Sum IV", + "question__title_slug": "path-sum-iv", + "question__hide": false, + "total_acs": 10151, + "total_submitted": 18829, + "frontend_question_id": 666, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 665, + "question__article__live": true, + "question__article__slug": "non-decreasing-array", + "question__title": "Non-decreasing Array", + "question__title_slug": "non-decreasing-array", + "question__hide": false, + "total_acs": 69572, + "total_submitted": 359855, + "frontend_question_id": 665, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 664, + "question__article__live": true, + "question__article__slug": "strange-printer", + "question__title": "Strange Printer", + "question__title_slug": "strange-printer", + "question__hide": false, + "total_acs": 11432, + "total_submitted": 29781, + "frontend_question_id": 664, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 663, + "question__article__live": true, + "question__article__slug": "equal-tree-partition", + "question__title": "Equal Tree Partition", + "question__title_slug": "equal-tree-partition", + "question__hide": false, + "total_acs": 15988, + "total_submitted": 41278, + "frontend_question_id": 663, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 662, + "question__article__live": true, + "question__article__slug": "maximum-width-of-binary-tree", + "question__title": "Maximum Width of Binary Tree", + "question__title_slug": "maximum-width-of-binary-tree", + "question__hide": false, + "total_acs": 42939, + "total_submitted": 108546, + "frontend_question_id": 662, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 661, + "question__article__live": true, + "question__article__slug": "image-smoother", + "question__title": "Image Smoother", + "question__title_slug": "image-smoother", + "question__hide": false, + "total_acs": 41248, + "total_submitted": 82778, + "frontend_question_id": 661, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 660, + "question__article__live": true, + "question__article__slug": "remove-9", + "question__title": "Remove 9", + "question__title_slug": "remove-9", + "question__hide": false, + "total_acs": 6194, + "total_submitted": 11694, + "frontend_question_id": 660, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 659, + "question__article__live": true, + "question__article__slug": "split-array-into-consecutive-subsequences", + "question__title": "Split Array into Consecutive Subsequences", + "question__title_slug": "split-array-into-consecutive-subsequences", + "question__hide": false, + "total_acs": 27944, + "total_submitted": 65908, + "frontend_question_id": 659, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 658, + "question__article__live": true, + "question__article__slug": "find-k-closest-elements", + "question__title": "Find K Closest Elements", + "question__title_slug": "find-k-closest-elements", + "question__hide": false, + "total_acs": 72099, + "total_submitted": 183637, + "frontend_question_id": 658, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 657, + "question__article__live": true, + "question__article__slug": "judge-route-circle", + "question__title": "Robot Return to Origin", + "question__title_slug": "robot-return-to-origin", + "question__hide": false, + "total_acs": 200744, + "total_submitted": 276674, + "frontend_question_id": 657, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 656, + "question__article__live": true, + "question__article__slug": "coin-path", + "question__title": "Coin Path", + "question__title_slug": "coin-path", + "question__hide": false, + "total_acs": 7770, + "total_submitted": 27922, + "frontend_question_id": 656, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 655, + "question__article__live": true, + "question__article__slug": "print-binary-tree", + "question__title": "Print Binary Tree", + "question__title_slug": "print-binary-tree", + "question__hide": false, + "total_acs": 26064, + "total_submitted": 49152, + "frontend_question_id": 655, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 654, + "question__article__live": true, + "question__article__slug": "maximum-binary-tree", + "question__title": "Maximum Binary Tree", + "question__title_slug": "maximum-binary-tree", + "question__hide": false, + "total_acs": 106775, + "total_submitted": 137385, + "frontend_question_id": 654, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 653, + "question__article__live": true, + "question__article__slug": "two-sum-iv", + "question__title": "Two Sum IV - Input is a BST", + "question__title_slug": "two-sum-iv-input-is-a-bst", + "question__hide": false, + "total_acs": 111288, + "total_submitted": 206735, + "frontend_question_id": 653, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 652, + "question__article__live": true, + "question__article__slug": "find-duplicate-subtrees", + "question__title": "Find Duplicate Subtrees", + "question__title_slug": "find-duplicate-subtrees", + "question__hide": false, + "total_acs": 47919, + "total_submitted": 100147, + "frontend_question_id": 652, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 651, + "question__article__live": true, + "question__article__slug": "4-keys-keyboard", + "question__title": "4 Keys Keyboard", + "question__title_slug": "4-keys-keyboard", + "question__hide": false, + "total_acs": 13918, + "total_submitted": 27024, + "frontend_question_id": 651, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 650, + "question__article__live": true, + "question__article__slug": "2-keys-keyboard", + "question__title": "2 Keys Keyboard", + "question__title_slug": "2-keys-keyboard", + "question__hide": false, + "total_acs": 41417, + "total_submitted": 86976, + "frontend_question_id": 650, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 649, + "question__article__live": true, + "question__article__slug": "dota2-senate", + "question__title": "Dota2 Senate", + "question__title_slug": "dota2-senate", + "question__hide": false, + "total_acs": 10361, + "total_submitted": 27083, + "frontend_question_id": 649, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 648, + "question__article__live": true, + "question__article__slug": "replace-words", + "question__title": "Replace Words", + "question__title_slug": "replace-words", + "question__hide": false, + "total_acs": 42961, + "total_submitted": 79405, + "frontend_question_id": 648, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 647, + "question__article__live": true, + "question__article__slug": "palindromic-substrings", + "question__title": "Palindromic Substrings", + "question__title_slug": "palindromic-substrings", + "question__hide": false, + "total_acs": 134674, + "total_submitted": 230070, + "frontend_question_id": 647, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 646, + "question__article__live": true, + "question__article__slug": "maximum-length-of-pair-chain", + "question__title": "Maximum Length of Pair Chain", + "question__title_slug": "maximum-length-of-pair-chain", + "question__hide": false, + "total_acs": 44459, + "total_submitted": 88704, + "frontend_question_id": 646, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 645, + "question__article__live": true, + "question__article__slug": "set-mismatch", + "question__title": "Set Mismatch", + "question__title_slug": "set-mismatch", + "question__hide": false, + "total_acs": 58148, + "total_submitted": 140915, + "frontend_question_id": 645, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 644, + "question__article__live": true, + "question__article__slug": "maximum-average-subarray-ii", + "question__title": "Maximum Average Subarray II", + "question__title_slug": "maximum-average-subarray-ii", + "question__hide": false, + "total_acs": 9519, + "total_submitted": 31566, + "frontend_question_id": 644, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 643, + "question__article__live": true, + "question__article__slug": "maximum-average-subarray", + "question__title": "Maximum Average Subarray I", + "question__title_slug": "maximum-average-subarray-i", + "question__hide": false, + "total_acs": 62899, + "total_submitted": 155168, + "frontend_question_id": 643, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 642, + "question__article__live": true, + "question__article__slug": "design-search-autocomplete-system", + "question__title": "Design Search Autocomplete System", + "question__title_slug": "design-search-autocomplete-system", + "question__hide": false, + "total_acs": 37770, + "total_submitted": 91102, + "frontend_question_id": 642, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 640, + "question__article__live": true, + "question__article__slug": "solve-the-equation", + "question__title": "Solve the Equation", + "question__title_slug": "solve-the-equation", + "question__hide": false, + "total_acs": 20735, + "total_submitted": 50618, + "frontend_question_id": 640, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 639, + "question__article__live": true, + "question__article__slug": "decode-ways-ii", + "question__title": "Decode Ways II", + "question__title_slug": "decode-ways-ii", + "question__hide": false, + "total_acs": 25513, + "total_submitted": 99149, + "frontend_question_id": 639, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 638, + "question__article__live": true, + "question__article__slug": "shopping-offers", + "question__title": "Shopping Offers", + "question__title_slug": "shopping-offers", + "question__hide": false, + "total_acs": 25242, + "total_submitted": 50245, + "frontend_question_id": 638, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 637, + "question__article__live": true, + "question__article__slug": "average-of-levels", + "question__title": "Average of Levels in Binary Tree", + "question__title_slug": "average-of-levels-in-binary-tree", + "question__hide": false, + "total_acs": 96854, + "total_submitted": 160223, + "frontend_question_id": 637, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 636, + "question__article__live": true, + "question__article__slug": "exclusive-time-of-functions", + "question__title": "Exclusive Time of Functions", + "question__title_slug": "exclusive-time-of-functions", + "question__hide": false, + "total_acs": 52999, + "total_submitted": 105602, + "frontend_question_id": 636, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 635, + "question__article__live": true, + "question__article__slug": "design-log-storage", + "question__title": "Design Log Storage System", + "question__title_slug": "design-log-storage-system", + "question__hide": false, + "total_acs": 14201, + "total_submitted": 24981, + "frontend_question_id": 635, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 634, + "question__article__live": true, + "question__article__slug": "find-derangements", + "question__title": "Find the Derangement of An Array", + "question__title_slug": "find-the-derangement-of-an-array", + "question__hide": false, + "total_acs": 5585, + "total_submitted": 14310, + "frontend_question_id": 634, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 633, + "question__article__live": true, + "question__article__slug": "sum-of-square-numbers", + "question__title": "Sum of Square Numbers", + "question__title_slug": "sum-of-square-numbers", + "question__hide": false, + "total_acs": 54168, + "total_submitted": 166358, + "frontend_question_id": 633, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 632, + "question__article__live": true, + "question__article__slug": "smallest-range", + "question__title": "Smallest Range Covering Elements from K Lists", + "question__title_slug": "smallest-range-covering-elements-from-k-lists", + "question__hide": false, + "total_acs": 30195, + "total_submitted": 60359, + "frontend_question_id": 632, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 631, + "question__article__live": true, + "question__article__slug": "design-excel-sum-formula", + "question__title": "Design Excel Sum Formula", + "question__title_slug": "design-excel-sum-formula", + "question__hide": false, + "total_acs": 3469, + "total_submitted": 11423, + "frontend_question_id": 631, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 630, + "question__article__live": true, + "question__article__slug": "course-schedule-iii", + "question__title": "Course Schedule III", + "question__title_slug": "course-schedule-iii", + "question__hide": false, + "total_acs": 15461, + "total_submitted": 47284, + "frontend_question_id": 630, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 629, + "question__article__live": true, + "question__article__slug": "k-inverse-pairs-array", + "question__title": "K Inverse Pairs Array", + "question__title_slug": "k-inverse-pairs-array", + "question__hide": false, + "total_acs": 9173, + "total_submitted": 30403, + "frontend_question_id": 629, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 628, + "question__article__live": true, + "question__article__slug": "maximmum-product-of-three-numbers", + "question__title": "Maximum Product of Three Numbers", + "question__title_slug": "maximum-product-of-three-numbers", + "question__hide": false, + "total_acs": 89318, + "total_submitted": 190937, + "frontend_question_id": 628, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 625, + "question__article__live": true, + "question__article__slug": "minimum-factorization", + "question__title": "Minimum Factorization", + "question__title_slug": "minimum-factorization", + "question__hide": false, + "total_acs": 7216, + "total_submitted": 22218, + "frontend_question_id": 625, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 624, + "question__article__live": true, + "question__article__slug": "maximum-distance-in-array", + "question__title": "Maximum Distance in Arrays", + "question__title_slug": "maximum-distance-in-arrays", + "question__hide": false, + "total_acs": 16937, + "total_submitted": 44350, + "frontend_question_id": 624, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 623, + "question__article__live": true, + "question__article__slug": "add-one-row-in-a-tree", + "question__title": "Add One Row to Tree", + "question__title_slug": "add-one-row-to-tree", + "question__hide": false, + "total_acs": 30891, + "total_submitted": 64282, + "frontend_question_id": 623, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 621, + "question__article__live": true, + "question__article__slug": "task-scheduler", + "question__title": "Task Scheduler", + "question__title_slug": "task-scheduler", + "question__hide": false, + "total_acs": 119649, + "total_submitted": 254218, + "frontend_question_id": 621, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 617, + "question__article__live": true, + "question__article__slug": "merge-two-binary-trees", + "question__title": "Merge Two Binary Trees", + "question__title_slug": "merge-two-binary-trees", + "question__hide": false, + "total_acs": 229485, + "total_submitted": 319247, + "frontend_question_id": 617, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 616, + "question__article__live": true, + "question__article__slug": "add-bold-tag-in-a-string", + "question__title": "Add Bold Tag in String", + "question__title_slug": "add-bold-tag-in-string", + "question__hide": false, + "total_acs": 27761, + "total_submitted": 68504, + "frontend_question_id": 616, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 611, + "question__article__live": true, + "question__article__slug": "valid-triangle-number", + "question__title": "Valid Triangle Number", + "question__title_slug": "valid-triangle-number", + "question__hide": false, + "total_acs": 48937, + "total_submitted": 104390, + "frontend_question_id": 611, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 609, + "question__article__live": true, + "question__article__slug": "find-duplicate", + "question__title": "Find Duplicate File in System", + "question__title_slug": "find-duplicate-file-in-system", + "question__hide": false, + "total_acs": 38053, + "total_submitted": 66386, + "frontend_question_id": 609, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 606, + "question__article__live": true, + "question__article__slug": "construct-string-from-binary-tree", + "question__title": "Construct String from Binary Tree", + "question__title_slug": "construct-string-from-binary-tree", + "question__hide": false, + "total_acs": 69195, + "total_submitted": 131590, + "frontend_question_id": 606, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 605, + "question__article__live": true, + "question__article__slug": "can-place-flowers", + "question__title": "Can Place Flowers", + "question__title_slug": "can-place-flowers", + "question__hide": false, + "total_acs": 78574, + "total_submitted": 249549, + "frontend_question_id": 605, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 604, + "question__article__live": true, + "question__article__slug": "desing-compressed-string-iterator", + "question__title": "Design Compressed String Iterator", + "question__title_slug": "design-compressed-string-iterator", + "question__hide": false, + "total_acs": 14713, + "total_submitted": 41091, + "frontend_question_id": 604, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 600, + "question__article__live": true, + "question__article__slug": "non-negative-integers-without-consecutive-ones", + "question__title": "Non-negative Integers without Consecutive Ones", + "question__title_slug": "non-negative-integers-without-consecutive-ones", + "question__hide": false, + "total_acs": 10130, + "total_submitted": 30402, + "frontend_question_id": 600, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 599, + "question__article__live": true, + "question__article__slug": "minimum-index-sum-of-two-lists", + "question__title": "Minimum Index Sum of Two Lists", + "question__title_slug": "minimum-index-sum-of-two-lists", + "question__hide": false, + "total_acs": 71412, + "total_submitted": 145176, + "frontend_question_id": 599, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 598, + "question__article__live": true, + "question__article__slug": "range-addition-ii", + "question__title": "Range Addition II", + "question__title_slug": "range-addition-ii", + "question__hide": false, + "total_acs": 35444, + "total_submitted": 72096, + "frontend_question_id": 598, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 594, + "question__article__live": true, + "question__article__slug": "longest-harmonious-subsequence", + "question__title": "Longest Harmonious Subsequence", + "question__title_slug": "longest-harmonious-subsequence", + "question__hide": false, + "total_acs": 44227, + "total_submitted": 98570, + "frontend_question_id": 594, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 593, + "question__article__live": true, + "question__article__slug": "valid-square", + "question__title": "Valid Square", + "question__title_slug": "valid-square", + "question__hide": false, + "total_acs": 24203, + "total_submitted": 58564, + "frontend_question_id": 593, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 592, + "question__article__live": true, + "question__article__slug": "kill-process-3", + "question__title": "Fraction Addition and Subtraction", + "question__title_slug": "fraction-addition-and-subtraction", + "question__hide": false, + "total_acs": 15038, + "total_submitted": 31502, + "frontend_question_id": 592, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 591, + "question__article__live": true, + "question__article__slug": "tag-validator", + "question__title": "Tag Validator", + "question__title_slug": "tag-validator", + "question__hide": false, + "total_acs": 6427, + "total_submitted": 19180, + "frontend_question_id": 591, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 588, + "question__article__live": true, + "question__article__slug": "design-in-memory-file-system", + "question__title": "Design In-Memory File System", + "question__title_slug": "design-in-memory-file-system", + "question__hide": false, + "total_acs": 9283, + "total_submitted": 21810, + "frontend_question_id": 588, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 587, + "question__article__live": true, + "question__article__slug": "erect-the-fence", + "question__title": "Erect the Fence", + "question__title_slug": "erect-the-fence", + "question__hide": false, + "total_acs": 7915, + "total_submitted": 22702, + "frontend_question_id": 587, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 583, + "question__article__live": true, + "question__article__slug": "delete-operation-for-two-strings", + "question__title": "Delete Operation for Two Strings", + "question__title_slug": "delete-operation-for-two-strings", + "question__hide": false, + "total_acs": 38664, + "total_submitted": 83623, + "frontend_question_id": 583, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 582, + "question__article__live": true, + "question__article__slug": "kill-process", + "question__title": "Kill Process", + "question__title_slug": "kill-process", + "question__hide": false, + "total_acs": 28229, + "total_submitted": 48508, + "frontend_question_id": 582, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 581, + "question__article__live": true, + "question__article__slug": "shortest-unsorted-continous-subarray", + "question__title": "Shortest Unsorted Continuous Subarray", + "question__title_slug": "shortest-unsorted-continuous-subarray", + "question__hide": false, + "total_acs": 89730, + "total_submitted": 293248, + "frontend_question_id": 581, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 576, + "question__article__live": true, + "question__article__slug": "out-of-boundary-paths", + "question__title": "Out of Boundary Paths", + "question__title_slug": "out-of-boundary-paths", + "question__hide": false, + "total_acs": 21500, + "total_submitted": 64581, + "frontend_question_id": 576, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 575, + "question__article__live": true, + "question__article__slug": "distribute-candies", + "question__title": "Distribute Candies", + "question__title_slug": "distribute-candies", + "question__hide": false, + "total_acs": 84084, + "total_submitted": 139360, + "frontend_question_id": 575, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 573, + "question__article__live": true, + "question__article__slug": "squirrel-simulation", + "question__title": "Squirrel Simulation", + "question__title_slug": "squirrel-simulation", + "question__hide": false, + "total_acs": 6723, + "total_submitted": 12251, + "frontend_question_id": 573, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 572, + "question__article__live": true, + "question__article__slug": "subtree-of-another-tree", + "question__title": "Subtree of Another Tree", + "question__title_slug": "subtree-of-another-tree", + "question__hide": false, + "total_acs": 150258, + "total_submitted": 347882, + "frontend_question_id": 572, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 568, + "question__article__live": true, + "question__article__slug": "maximum-vacation-days", + "question__title": "Maximum Vacation Days", + "question__title_slug": "maximum-vacation-days", + "question__hide": false, + "total_acs": 20406, + "total_submitted": 52266, + "frontend_question_id": 568, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 567, + "question__article__live": true, + "question__article__slug": "short-permutation-in-a-long-string", + "question__title": "Permutation in String", + "question__title_slug": "permutation-in-string", + "question__hide": false, + "total_acs": 67680, + "total_submitted": 170860, + "frontend_question_id": 567, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 566, + "question__article__live": true, + "question__article__slug": "reshape-the-matrix", + "question__title": "Reshape the Matrix", + "question__title_slug": "reshape-the-matrix", + "question__hide": false, + "total_acs": 88269, + "total_submitted": 148201, + "frontend_question_id": 566, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 565, + "question__article__live": true, + "question__article__slug": "array-nesting", + "question__title": "Array Nesting", + "question__title_slug": "array-nesting", + "question__hide": false, + "total_acs": 43428, + "total_submitted": 80135, + "frontend_question_id": 565, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 564, + "question__article__live": true, + "question__article__slug": "find-the-closest-palindrome", + "question__title": "Find the Closest Palindrome", + "question__title_slug": "find-the-closest-palindrome", + "question__hide": false, + "total_acs": 16970, + "total_submitted": 88164, + "frontend_question_id": 564, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 563, + "question__article__live": true, + "question__article__slug": "binary-tree-tilt", + "question__title": "Binary Tree Tilt", + "question__title_slug": "binary-tree-tilt", + "question__hide": false, + "total_acs": 62181, + "total_submitted": 131251, + "frontend_question_id": 563, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 562, + "question__article__live": true, + "question__article__slug": "longest-line-of-consecutive-one-in-a-matrix", + "question__title": "Longest Line of Consecutive One in Matrix", + "question__title_slug": "longest-line-of-consecutive-one-in-matrix", + "question__hide": false, + "total_acs": 19347, + "total_submitted": 43278, + "frontend_question_id": 562, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 561, + "question__article__live": true, + "question__article__slug": "array-partitioning-i", + "question__title": "Array Partition I", + "question__title_slug": "array-partition-i", + "question__hide": false, + "total_acs": 177082, + "total_submitted": 251280, + "frontend_question_id": 561, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 560, + "question__article__live": true, + "question__article__slug": "subarray-sum-equals-k", + "question__title": "Subarray Sum Equals K", + "question__title_slug": "subarray-sum-equals-k", + "question__hide": false, + "total_acs": 167302, + "total_submitted": 387322, + "frontend_question_id": 560, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 557, + "question__article__live": true, + "question__article__slug": "reverse-words-in-a-string-iii", + "question__title": "Reverse Words in a String III", + "question__title_slug": "reverse-words-in-a-string-iii", + "question__hide": false, + "total_acs": 160956, + "total_submitted": 241980, + "frontend_question_id": 557, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 556, + "question__article__live": true, + "question__article__slug": "next-greater-element-iii", + "question__title": "Next Greater Element III", + "question__title_slug": "next-greater-element-iii", + "question__hide": false, + "total_acs": 32038, + "total_submitted": 104174, + "frontend_question_id": 556, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 555, + "question__article__live": true, + "question__article__slug": "split-assembled-strings", + "question__title": "Split Concatenated Strings", + "question__title_slug": "split-concatenated-strings", + "question__hide": false, + "total_acs": 4257, + "total_submitted": 10421, + "frontend_question_id": 555, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 554, + "question__article__live": true, + "question__article__slug": "brick-wall", + "question__title": "Brick Wall", + "question__title_slug": "brick-wall", + "question__hide": false, + "total_acs": 45166, + "total_submitted": 92872, + "frontend_question_id": 554, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 553, + "question__article__live": true, + "question__article__slug": "optimal-division", + "question__title": "Optimal Division", + "question__title_slug": "optimal-division", + "question__hide": false, + "total_acs": 22369, + "total_submitted": 40009, + "frontend_question_id": 553, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 552, + "question__article__live": true, + "question__article__slug": "student-attendance-record-ii", + "question__title": "Student Attendance Record II", + "question__title_slug": "student-attendance-record-ii", + "question__hide": false, + "total_acs": 16847, + "total_submitted": 48561, + "frontend_question_id": 552, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 551, + "question__article__live": true, + "question__article__slug": "student-attendance-record-i", + "question__title": "Student Attendance Record I", + "question__title_slug": "student-attendance-record-i", + "question__hide": false, + "total_acs": 65418, + "total_submitted": 141607, + "frontend_question_id": 551, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 549, + "question__article__live": true, + "question__article__slug": "binary-tree-longest-consecutive-sequence-ii", + "question__title": "Binary Tree Longest Consecutive Sequence II", + "question__title_slug": "binary-tree-longest-consecutive-sequence-ii", + "question__hide": false, + "total_acs": 20568, + "total_submitted": 45024, + "frontend_question_id": 549, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 548, + "question__article__live": true, + "question__article__slug": "split-array-with-equal-sum", + "question__title": "Split Array with Equal Sum", + "question__title_slug": "split-array-with-equal-sum", + "question__hide": false, + "total_acs": 9855, + "total_submitted": 22277, + "frontend_question_id": 548, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 547, + "question__article__live": true, + "question__article__slug": "friend-circles", + "question__title": "Friend Circles", + "question__title_slug": "friend-circles", + "question__hide": false, + "total_acs": 119510, + "total_submitted": 213200, + "frontend_question_id": 547, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 546, + "question__article__live": true, + "question__article__slug": "remove-boxes", + "question__title": "Remove Boxes", + "question__title_slug": "remove-boxes", + "question__hide": false, + "total_acs": 11422, + "total_submitted": 28563, + "frontend_question_id": 546, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 545, + "question__article__live": true, + "question__article__slug": "boundary-of-binary-tree", + "question__title": "Boundary of Binary Tree", + "question__title_slug": "boundary-of-binary-tree", + "question__hide": false, + "total_acs": 33276, + "total_submitted": 89552, + "frontend_question_id": 545, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 544, + "question__article__live": true, + "question__article__slug": "output-contest-matches", + "question__title": "Output Contest Matches", + "question__title_slug": "output-contest-matches", + "question__hide": false, + "total_acs": 17836, + "total_submitted": 24068, + "frontend_question_id": 544, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 543, + "question__article__live": true, + "question__article__slug": "diameter-of-binary-tree", + "question__title": "Diameter of Binary Tree", + "question__title_slug": "diameter-of-binary-tree", + "question__hide": false, + "total_acs": 182515, + "total_submitted": 381070, + "frontend_question_id": 543, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 542, + "question__article__live": true, + "question__article__slug": "01-matrix", + "question__title": "01 Matrix", + "question__title_slug": "01-matrix", + "question__hide": false, + "total_acs": 61125, + "total_submitted": 162205, + "frontend_question_id": 542, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 541, + "question__article__live": true, + "question__article__slug": "reverse-string-ii", + "question__title": "Reverse String II", + "question__title_slug": "reverse-string-ii", + "question__hide": false, + "total_acs": 72739, + "total_submitted": 155686, + "frontend_question_id": 541, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 540, + "question__article__live": true, + "question__article__slug": "single-element-in-a-sorted-array", + "question__title": "Single Element in a Sorted Array", + "question__title_slug": "single-element-in-a-sorted-array", + "question__hide": false, + "total_acs": 71034, + "total_submitted": 123412, + "frontend_question_id": 540, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 539, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Time Difference", + "question__title_slug": "minimum-time-difference", + "question__hide": false, + "total_acs": 38080, + "total_submitted": 76195, + "frontend_question_id": 539, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 538, + "question__article__live": true, + "question__article__slug": "convert-bst-to-greater-tree", + "question__title": "Convert BST to Greater Tree", + "question__title_slug": "convert-bst-to-greater-tree", + "question__hide": false, + "total_acs": 99049, + "total_submitted": 187247, + "frontend_question_id": 538, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 537, + "question__article__live": true, + "question__article__slug": "complex-number-multiplication", + "question__title": "Complex Number Multiplication", + "question__title_slug": "complex-number-multiplication", + "question__hide": false, + "total_acs": 41305, + "total_submitted": 62279, + "frontend_question_id": 537, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 536, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Construct Binary Tree from String", + "question__title_slug": "construct-binary-tree-from-string", + "question__hide": false, + "total_acs": 22907, + "total_submitted": 48956, + "frontend_question_id": 536, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 535, + "question__article__live": true, + "question__article__slug": "encode-and-decode-tinyurl", + "question__title": "Encode and Decode TinyURL", + "question__title_slug": "encode-and-decode-tinyurl", + "question__hide": false, + "total_acs": 90416, + "total_submitted": 115574, + "frontend_question_id": 535, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 533, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Lonely Pixel II", + "question__title_slug": "lonely-pixel-ii", + "question__hide": false, + "total_acs": 9297, + "total_submitted": 19786, + "frontend_question_id": 533, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 532, + "question__article__live": null, + "question__article__slug": null, + "question__title": "K-diff Pairs in an Array", + "question__title_slug": "k-diff-pairs-in-an-array", + "question__hide": false, + "total_acs": 79904, + "total_submitted": 261122, + "frontend_question_id": 532, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 531, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Lonely Pixel I", + "question__title_slug": "lonely-pixel-i", + "question__hide": false, + "total_acs": 19046, + "total_submitted": 32809, + "frontend_question_id": 531, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 530, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Absolute Difference in BST", + "question__title_slug": "minimum-absolute-difference-in-bst", + "question__hide": false, + "total_acs": 72130, + "total_submitted": 139129, + "frontend_question_id": 530, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 529, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minesweeper", + "question__title_slug": "minesweeper", + "question__hide": false, + "total_acs": 45766, + "total_submitted": 82138, + "frontend_question_id": 529, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 527, + "question__article__live": true, + "question__article__slug": "word-abbreviation", + "question__title": "Word Abbreviation", + "question__title_slug": "word-abbreviation", + "question__hide": false, + "total_acs": 13741, + "total_submitted": 26293, + "frontend_question_id": 527, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 526, + "question__article__live": true, + "question__article__slug": "beautiful-arrangement", + "question__title": "Beautiful Arrangement", + "question__title_slug": "beautiful-arrangement", + "question__hide": false, + "total_acs": 43252, + "total_submitted": 77054, + "frontend_question_id": 526, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 525, + "question__article__live": true, + "question__article__slug": "contiguous-array", + "question__title": "Contiguous Array", + "question__title_slug": "contiguous-array", + "question__hide": false, + "total_acs": 49695, + "total_submitted": 112219, + "frontend_question_id": 525, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 524, + "question__article__live": true, + "question__article__slug": "longest-word-in-dictionary-through-deletion", + "question__title": "Longest Word in Dictionary through Deleting", + "question__title_slug": "longest-word-in-dictionary-through-deleting", + "question__hide": false, + "total_acs": 54239, + "total_submitted": 114859, + "frontend_question_id": 524, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 523, + "question__article__live": true, + "question__article__slug": "continous-subarray-sum", + "question__title": "Continuous Subarray Sum", + "question__title_slug": "continuous-subarray-sum", + "question__hide": false, + "total_acs": 90432, + "total_submitted": 370707, + "frontend_question_id": 523, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 522, + "question__article__live": true, + "question__article__slug": "longest-uncommon-subsequence-ii", + "question__title": "Longest Uncommon Subsequence II", + "question__title_slug": "longest-uncommon-subsequence-ii", + "question__hide": false, + "total_acs": 19081, + "total_submitted": 57189, + "frontend_question_id": 522, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 521, + "question__article__live": true, + "question__article__slug": "longest-uncommon-subsequence-i", + "question__title": "Longest Uncommon Subsequence I ", + "question__title_slug": "longest-uncommon-subsequence-i", + "question__hide": false, + "total_acs": 52605, + "total_submitted": 92300, + "frontend_question_id": 521, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 520, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Detect Capital", + "question__title_slug": "detect-capital", + "question__hide": false, + "total_acs": 97024, + "total_submitted": 183659, + "frontend_question_id": 520, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 518, + "question__article__live": true, + "question__article__slug": "coin-change-ii", + "question__title": "Coin Change 2", + "question__title_slug": "coin-change-2", + "question__hide": false, + "total_acs": 65814, + "total_submitted": 145471, + "frontend_question_id": 518, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 517, + "question__article__live": true, + "question__article__slug": "super-washing-machines", + "question__title": "Super Washing Machines", + "question__title_slug": "super-washing-machines", + "question__hide": false, + "total_acs": 14157, + "total_submitted": 37802, + "frontend_question_id": 517, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 516, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Palindromic Subsequence", + "question__title_slug": "longest-palindromic-subsequence", + "question__hide": false, + "total_acs": 83334, + "total_submitted": 168157, + "frontend_question_id": 516, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 515, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Largest Value in Each Tree Row", + "question__title_slug": "find-largest-value-in-each-tree-row", + "question__hide": false, + "total_acs": 76603, + "total_submitted": 129996, + "frontend_question_id": 515, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 514, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Freedom Trail", + "question__title_slug": "freedom-trail", + "question__hide": false, + "total_acs": 15503, + "total_submitted": 37388, + "frontend_question_id": 514, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 513, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Bottom Left Tree Value", + "question__title_slug": "find-bottom-left-tree-value", + "question__hide": false, + "total_acs": 85677, + "total_submitted": 143217, + "frontend_question_id": 513, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 511, + "question__article__live": null, + "question__article__slug": null, + "question__title": "All Paths from Source Lead to Destination", + "question__title_slug": "all-paths-from-source-lead-to-destination", + "question__hide": false, + "total_acs": 3703, + "total_submitted": 8185, + "frontend_question_id": 1059, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 509, + "question__article__live": true, + "question__article__slug": "inorder-successor-in-a-bst-ii", + "question__title": "Inorder Successor in BST II", + "question__title_slug": "inorder-successor-in-bst-ii", + "question__hide": false, + "total_acs": 8453, + "total_submitted": 15140, + "frontend_question_id": 510, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 508, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Most Frequent Subtree Sum", + "question__title_slug": "most-frequent-subtree-sum", + "question__hide": false, + "total_acs": 58096, + "total_submitted": 103642, + "frontend_question_id": 508, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 507, + "question__article__live": true, + "question__article__slug": "perfect-number", + "question__title": "Perfect Number", + "question__title_slug": "perfect-number", + "question__hide": false, + "total_acs": 50884, + "total_submitted": 144946, + "frontend_question_id": 507, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 506, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Relative Ranks", + "question__title_slug": "relative-ranks", + "question__hide": false, + "total_acs": 48102, + "total_submitted": 97620, + "frontend_question_id": 506, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 505, + "question__article__live": true, + "question__article__slug": "the-maze-ii", + "question__title": "The Maze II", + "question__title_slug": "the-maze-ii", + "question__hide": false, + "total_acs": 37723, + "total_submitted": 82237, + "frontend_question_id": 505, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 504, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Base 7", + "question__title_slug": "base-7", + "question__hide": false, + "total_acs": 47634, + "total_submitted": 104870, + "frontend_question_id": 504, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 503, + "question__article__live": true, + "question__article__slug": "next-greater-element-ii", + "question__title": "Next Greater Element II", + "question__title_slug": "next-greater-element-ii", + "question__hide": false, + "total_acs": 66665, + "total_submitted": 125651, + "frontend_question_id": 503, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 502, + "question__article__live": true, + "question__article__slug": "ipo", + "question__title": "IPO", + "question__title_slug": "ipo", + "question__hide": false, + "total_acs": 13989, + "total_submitted": 36184, + "frontend_question_id": 502, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 501, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Mode in Binary Search Tree", + "question__title_slug": "find-mode-in-binary-search-tree", + "question__hide": false, + "total_acs": 68366, + "total_submitted": 168498, + "frontend_question_id": 501, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 500, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Keyboard Row", + "question__title_slug": "keyboard-row", + "question__hide": false, + "total_acs": 98957, + "total_submitted": 156431, + "frontend_question_id": 500, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 499, + "question__article__live": null, + "question__article__slug": null, + "question__title": "The Maze III", + "question__title_slug": "the-maze-iii", + "question__hide": false, + "total_acs": 12296, + "total_submitted": 31337, + "frontend_question_id": 499, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 498, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Diagonal Traverse", + "question__title_slug": "diagonal-traverse", + "question__hide": false, + "total_acs": 57316, + "total_submitted": 123590, + "frontend_question_id": 498, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 496, + "question__article__live": true, + "question__article__slug": "greater-element-i", + "question__title": "Next Greater Element I", + "question__title_slug": "next-greater-element-i", + "question__hide": false, + "total_acs": 119954, + "total_submitted": 195530, + "frontend_question_id": 496, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 495, + "question__article__live": true, + "question__article__slug": "teemo-attacking", + "question__title": "Teemo Attacking", + "question__title_slug": "teemo-attacking", + "question__hide": false, + "total_acs": 41662, + "total_submitted": 78718, + "frontend_question_id": 495, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 494, + "question__article__live": true, + "question__article__slug": "target-sum", + "question__title": "Target Sum", + "question__title_slug": "target-sum", + "question__hide": false, + "total_acs": 122007, + "total_submitted": 265083, + "frontend_question_id": 494, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 493, + "question__article__live": true, + "question__article__slug": "reverse-pairs", + "question__title": "Reverse Pairs", + "question__title_slug": "reverse-pairs", + "question__hide": false, + "total_acs": 30397, + "total_submitted": 126303, + "frontend_question_id": 493, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 492, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Construct the Rectangle", + "question__title_slug": "construct-the-rectangle", + "question__hide": false, + "total_acs": 50120, + "total_submitted": 102306, + "frontend_question_id": 492, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 491, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Increasing Subsequences", + "question__title_slug": "increasing-subsequences", + "question__hide": false, + "total_acs": 38066, + "total_submitted": 87691, + "frontend_question_id": 491, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 490, + "question__article__live": true, + "question__article__slug": "the-maze", + "question__title": "The Maze", + "question__title_slug": "the-maze", + "question__hide": false, + "total_acs": 47968, + "total_submitted": 96972, + "frontend_question_id": 490, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 488, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Zuma Game", + "question__title_slug": "zuma-game", + "question__hide": false, + "total_acs": 11798, + "total_submitted": 29275, + "frontend_question_id": 488, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 487, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Max Consecutive Ones II", + "question__title_slug": "max-consecutive-ones-ii", + "question__hide": false, + "total_acs": 29628, + "total_submitted": 61920, + "frontend_question_id": 487, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 486, + "question__article__live": true, + "question__article__slug": "predict-the-winner", + "question__title": "Predict the Winner", + "question__title_slug": "predict-the-winner", + "question__hide": false, + "total_acs": 58674, + "total_submitted": 124324, + "frontend_question_id": 486, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 485, + "question__article__live": true, + "question__article__slug": "max-consecutive-ones", + "question__title": "Max Consecutive Ones", + "question__title_slug": "max-consecutive-ones", + "question__hide": false, + "total_acs": 161684, + "total_submitted": 289463, + "frontend_question_id": 485, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 484, + "question__article__live": true, + "question__article__slug": "find-permutation", + "question__title": "Find Permutation", + "question__title_slug": "find-permutation", + "question__hide": false, + "total_acs": 15114, + "total_submitted": 25551, + "frontend_question_id": 484, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 483, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Smallest Good Base", + "question__title_slug": "smallest-good-base", + "question__hide": false, + "total_acs": 11220, + "total_submitted": 32271, + "frontend_question_id": 483, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 482, + "question__article__live": null, + "question__article__slug": null, + "question__title": "License Key Formatting", + "question__title_slug": "license-key-formatting", + "question__hide": false, + "total_acs": 106287, + "total_submitted": 251758, + "frontend_question_id": 482, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 481, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Magical String", + "question__title_slug": "magical-string", + "question__hide": false, + "total_acs": 20256, + "total_submitted": 43334, + "frontend_question_id": 481, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 480, + "question__article__live": true, + "question__article__slug": "sliding-window-median", + "question__title": "Sliding Window Median", + "question__title_slug": "sliding-window-median", + "question__hide": false, + "total_acs": 35711, + "total_submitted": 103064, + "frontend_question_id": 480, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 479, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Largest Palindrome Product", + "question__title_slug": "largest-palindrome-product", + "question__hide": false, + "total_acs": 15698, + "total_submitted": 55990, + "frontend_question_id": 479, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 477, + "question__article__live": true, + "question__article__slug": "total-hamming-distance", + "question__title": "Total Hamming Distance", + "question__title_slug": "total-hamming-distance", + "question__hide": false, + "total_acs": 54683, + "total_submitted": 109328, + "frontend_question_id": 477, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 476, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number Complement", + "question__title_slug": "number-complement", + "question__hide": false, + "total_acs": 118969, + "total_submitted": 189091, + "frontend_question_id": 476, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 475, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Heaters", + "question__title_slug": "heaters", + "question__hide": false, + "total_acs": 55512, + "total_submitted": 171126, + "frontend_question_id": 475, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 474, + "question__article__live": true, + "question__article__slug": "ones-and-zeroes", + "question__title": "Ones and Zeroes", + "question__title_slug": "ones-and-zeroes", + "question__hide": false, + "total_acs": 37324, + "total_submitted": 90937, + "frontend_question_id": 474, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 473, + "question__article__live": true, + "question__article__slug": "matchsticks-to-square", + "question__title": "Matchsticks to Square", + "question__title_slug": "matchsticks-to-square", + "question__hide": false, + "total_acs": 29557, + "total_submitted": 80577, + "frontend_question_id": 473, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 472, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Concatenated Words", + "question__title_slug": "concatenated-words", + "question__hide": false, + "total_acs": 35325, + "total_submitted": 90633, + "frontend_question_id": 472, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 471, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Encode String with Shortest Length", + "question__title_slug": "encode-string-with-shortest-length", + "question__hide": false, + "total_acs": 13908, + "total_submitted": 30238, + "frontend_question_id": 471, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 469, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Convex Polygon", + "question__title_slug": "convex-polygon", + "question__hide": false, + "total_acs": 7610, + "total_submitted": 21027, + "frontend_question_id": 469, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 468, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Validate IP Address", + "question__title_slug": "validate-ip-address", + "question__hide": false, + "total_acs": 36831, + "total_submitted": 167942, + "frontend_question_id": 468, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 467, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Unique Substrings in Wraparound String", + "question__title_slug": "unique-substrings-in-wraparound-string", + "question__hide": false, + "total_acs": 21362, + "total_submitted": 61629, + "frontend_question_id": 467, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 466, + "question__article__live": true, + "question__article__slug": "count-the-repetitions", + "question__title": "Count The Repetitions", + "question__title_slug": "count-the-repetitions", + "question__hide": false, + "total_acs": 8994, + "total_submitted": 32522, + "frontend_question_id": 466, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 465, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Optimal Account Balancing", + "question__title_slug": "optimal-account-balancing", + "question__hide": false, + "total_acs": 23356, + "total_submitted": 51927, + "frontend_question_id": 465, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 464, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Can I Win", + "question__title_slug": "can-i-win", + "question__hide": false, + "total_acs": 43366, + "total_submitted": 153479, + "frontend_question_id": 464, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 463, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Island Perimeter", + "question__title_slug": "island-perimeter", + "question__hide": false, + "total_acs": 157699, + "total_submitted": 253325, + "frontend_question_id": 463, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 462, + "question__article__live": true, + "question__article__slug": "minimum-moves-to-equal-array-elements-ii", + "question__title": "Minimum Moves to Equal Array Elements II", + "question__title_slug": "minimum-moves-to-equal-array-elements-ii", + "question__hide": false, + "total_acs": 39872, + "total_submitted": 75313, + "frontend_question_id": 462, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 461, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Hamming Distance", + "question__title_slug": "hamming-distance", + "question__hide": false, + "total_acs": 270332, + "total_submitted": 381546, + "frontend_question_id": 461, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 460, + "question__article__live": null, + "question__article__slug": null, + "question__title": "LFU Cache", + "question__title_slug": "lfu-cache", + "question__hide": false, + "total_acs": 54798, + "total_submitted": 174349, + "frontend_question_id": 460, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 459, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Repeated Substring Pattern", + "question__title_slug": "repeated-substring-pattern", + "question__hide": false, + "total_acs": 98087, + "total_submitted": 239777, + "frontend_question_id": 459, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 458, + "question__article__live": true, + "question__article__slug": "poor-pigs", + "question__title": "Poor Pigs", + "question__title_slug": "poor-pigs", + "question__hide": false, + "total_acs": 17144, + "total_submitted": 36884, + "frontend_question_id": 458, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 457, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Circular Array Loop", + "question__title_slug": "circular-array-loop", + "question__hide": false, + "total_acs": 24562, + "total_submitted": 86978, + "frontend_question_id": 457, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 456, + "question__article__live": true, + "question__article__slug": "132-pattern", + "question__title": "132 Pattern", + "question__title_slug": "132-pattern", + "question__hide": false, + "total_acs": 39341, + "total_submitted": 140007, + "frontend_question_id": 456, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 455, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Assign Cookies", + "question__title_slug": "assign-cookies", + "question__hide": false, + "total_acs": 77482, + "total_submitted": 158426, + "frontend_question_id": 455, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 454, + "question__article__live": null, + "question__article__slug": null, + "question__title": "4Sum II", + "question__title_slug": "4sum-ii", + "question__hide": false, + "total_acs": 84331, + "total_submitted": 162581, + "frontend_question_id": 454, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 453, + "question__article__live": true, + "question__article__slug": "minimum-moves-to-equal-array-elements", + "question__title": "Minimum Moves to Equal Array Elements", + "question__title_slug": "minimum-moves-to-equal-array-elements", + "question__hide": false, + "total_acs": 64685, + "total_submitted": 130178, + "frontend_question_id": 453, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 452, + "question__article__live": true, + "question__article__slug": "minimum-number-of-arrows-to-burst-balloons", + "question__title": "Minimum Number of Arrows to Burst Balloons", + "question__title_slug": "minimum-number-of-arrows-to-burst-balloons", + "question__hide": false, + "total_acs": 48744, + "total_submitted": 102270, + "frontend_question_id": 452, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 451, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sort Characters By Frequency", + "question__title_slug": "sort-characters-by-frequency", + "question__hide": false, + "total_acs": 118020, + "total_submitted": 203425, + "frontend_question_id": 451, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 450, + "question__article__live": true, + "question__article__slug": "delete-node-in-a-bst", + "question__title": "Delete Node in a BST", + "question__title_slug": "delete-node-in-a-bst", + "question__hide": false, + "total_acs": 84216, + "total_submitted": 204677, + "frontend_question_id": 450, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 449, + "question__article__live": true, + "question__article__slug": "serialize-and-deserialize-bst", + "question__title": "Serialize and Deserialize BST", + "question__title_slug": "serialize-and-deserialize-bst", + "question__hide": false, + "total_acs": 78716, + "total_submitted": 158607, + "frontend_question_id": 449, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 448, + "question__article__live": true, + "question__article__slug": "find-all-numbers-disappeared-in-an-array", + "question__title": "Find All Numbers Disappeared in an Array", + "question__title_slug": "find-all-numbers-disappeared-in-an-array", + "question__hide": false, + "total_acs": 192923, + "total_submitted": 353314, + "frontend_question_id": 448, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 447, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Boomerangs", + "question__title_slug": "number-of-boomerangs", + "question__hide": false, + "total_acs": 60888, + "total_submitted": 119826, + "frontend_question_id": 447, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 446, + "question__article__live": true, + "question__article__slug": "arithmetic-slices-ii-subsequence", + "question__title": "Arithmetic Slices II - Subsequence", + "question__title_slug": "arithmetic-slices-ii-subsequence", + "question__hide": false, + "total_acs": 17360, + "total_submitted": 55118, + "frontend_question_id": 446, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 445, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Add Two Numbers II", + "question__title_slug": "add-two-numbers-ii", + "question__hide": false, + "total_acs": 119234, + "total_submitted": 228857, + "frontend_question_id": 445, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 444, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sequence Reconstruction", + "question__title_slug": "sequence-reconstruction", + "question__hide": false, + "total_acs": 20459, + "total_submitted": 96994, + "frontend_question_id": 444, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 443, + "question__article__live": true, + "question__article__slug": "string-compression", + "question__title": "String Compression", + "question__title_slug": "string-compression", + "question__hide": false, + "total_acs": 77068, + "total_submitted": 197046, + "frontend_question_id": 443, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 442, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find All Duplicates in an Array", + "question__title_slug": "find-all-duplicates-in-an-array", + "question__hide": false, + "total_acs": 123849, + "total_submitted": 196307, + "frontend_question_id": 442, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 441, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Arranging Coins", + "question__title_slug": "arranging-coins", + "question__hide": false, + "total_acs": 82721, + "total_submitted": 212427, + "frontend_question_id": 441, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 440, + "question__article__live": null, + "question__article__slug": null, + "question__title": "K-th Smallest in Lexicographical Order", + "question__title_slug": "k-th-smallest-in-lexicographical-order", + "question__hide": false, + "total_acs": 10194, + "total_submitted": 36796, + "frontend_question_id": 440, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 439, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Ternary Expression Parser", + "question__title_slug": "ternary-expression-parser", + "question__hide": false, + "total_acs": 17074, + "total_submitted": 31222, + "frontend_question_id": 439, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 438, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find All Anagrams in a String", + "question__title_slug": "find-all-anagrams-in-a-string", + "question__hide": false, + "total_acs": 163292, + "total_submitted": 413920, + "frontend_question_id": 438, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 437, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Path Sum III", + "question__title_slug": "path-sum-iii", + "question__hide": false, + "total_acs": 136894, + "total_submitted": 308965, + "frontend_question_id": 437, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 436, + "question__article__live": true, + "question__article__slug": "find-right-interval", + "question__title": "Find Right Interval", + "question__title_slug": "find-right-interval", + "question__hide": false, + "total_acs": 30452, + "total_submitted": 69388, + "frontend_question_id": 436, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 435, + "question__article__live": true, + "question__article__slug": "non-overlapping-intervals", + "question__title": "Non-overlapping Intervals", + "question__title_slug": "non-overlapping-intervals", + "question__hide": false, + "total_acs": 52196, + "total_submitted": 124567, + "frontend_question_id": 435, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 434, + "question__article__live": true, + "question__article__slug": "number-of-segments-in-a-string", + "question__title": "Number of Segments in a String", + "question__title_slug": "number-of-segments-in-a-string", + "question__hide": false, + "total_acs": 65114, + "total_submitted": 174243, + "frontend_question_id": 434, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 433, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Genetic Mutation", + "question__title_slug": "minimum-genetic-mutation", + "question__hide": false, + "total_acs": 25476, + "total_submitted": 64044, + "frontend_question_id": 433, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 432, + "question__article__live": null, + "question__article__slug": null, + "question__title": "All O`one Data Structure", + "question__title_slug": "all-oone-data-structure", + "question__hide": false, + "total_acs": 24271, + "total_submitted": 78321, + "frontend_question_id": 432, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 425, + "question__article__live": true, + "question__article__slug": "word-squares", + "question__title": "Word Squares", + "question__title_slug": "word-squares", + "question__hide": false, + "total_acs": 29220, + "total_submitted": 63421, + "frontend_question_id": 425, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 424, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Repeating Character Replacement", + "question__title_slug": "longest-repeating-character-replacement", + "question__hide": false, + "total_acs": 44358, + "total_submitted": 98835, + "frontend_question_id": 424, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 423, + "question__article__live": true, + "question__article__slug": "reconstruct-original-digits-from-english", + "question__title": "Reconstruct Original Digits from English", + "question__title_slug": "reconstruct-original-digits-from-english", + "question__hide": false, + "total_acs": 21343, + "total_submitted": 46145, + "frontend_question_id": 423, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 422, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Word Square", + "question__title_slug": "valid-word-square", + "question__hide": false, + "total_acs": 25023, + "total_submitted": 67884, + "frontend_question_id": 422, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 421, + "question__article__live": true, + "question__article__slug": "maximum-xor-of-two-numbers-in-an-array", + "question__title": "Maximum XOR of Two Numbers in an Array", + "question__title_slug": "maximum-xor-of-two-numbers-in-an-array", + "question__hide": false, + "total_acs": 43381, + "total_submitted": 82912, + "frontend_question_id": 421, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 420, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Strong Password Checker", + "question__title_slug": "strong-password-checker", + "question__hide": false, + "total_acs": 7569, + "total_submitted": 46430, + "frontend_question_id": 420, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 419, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Battleships in a Board", + "question__title_slug": "battleships-in-a-board", + "question__hide": false, + "total_acs": 73499, + "total_submitted": 109319, + "frontend_question_id": 419, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 418, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sentence Screen Fitting", + "question__title_slug": "sentence-screen-fitting", + "question__hide": false, + "total_acs": 38226, + "total_submitted": 120129, + "frontend_question_id": 418, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 417, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Pacific Atlantic Water Flow", + "question__title_slug": "pacific-atlantic-water-flow", + "question__hide": false, + "total_acs": 56072, + "total_submitted": 144229, + "frontend_question_id": 417, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 416, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Partition Equal Subset Sum", + "question__title_slug": "partition-equal-subset-sum", + "question__hide": false, + "total_acs": 122888, + "total_submitted": 293354, + "frontend_question_id": 416, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 415, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Add Strings", + "question__title_slug": "add-strings", + "question__hide": false, + "total_acs": 127670, + "total_submitted": 281419, + "frontend_question_id": 415, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 414, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Third Maximum Number", + "question__title_slug": "third-maximum-number", + "question__hide": false, + "total_acs": 112416, + "total_submitted": 378904, + "frontend_question_id": 414, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 413, + "question__article__live": true, + "question__article__slug": "arithmetic-slices", + "question__title": "Arithmetic Slices", + "question__title_slug": "arithmetic-slices", + "question__hide": false, + "total_acs": 73300, + "total_submitted": 129104, + "frontend_question_id": 413, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 412, + "question__article__live": true, + "question__article__slug": "fizz-buzz", + "question__title": "Fizz Buzz", + "question__title_slug": "fizz-buzz", + "question__hide": false, + "total_acs": 258429, + "total_submitted": 426784, + "frontend_question_id": 412, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 411, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Unique Word Abbreviation", + "question__title_slug": "minimum-unique-word-abbreviation", + "question__hide": false, + "total_acs": 10382, + "total_submitted": 29212, + "frontend_question_id": 411, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 410, + "question__article__live": true, + "question__article__slug": "split-array-largest-sum", + "question__title": "Split Array Largest Sum", + "question__title_slug": "split-array-largest-sum", + "question__hide": false, + "total_acs": 65685, + "total_submitted": 151506, + "frontend_question_id": 410, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 409, + "question__article__live": true, + "question__article__slug": "longest-palindrome", + "question__title": "Longest Palindrome", + "question__title_slug": "longest-palindrome", + "question__hide": false, + "total_acs": 117262, + "total_submitted": 238732, + "frontend_question_id": 409, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 408, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Word Abbreviation", + "question__title_slug": "valid-word-abbreviation", + "question__hide": false, + "total_acs": 27162, + "total_submitted": 90499, + "frontend_question_id": 408, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 407, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Trapping Rain Water II", + "question__title_slug": "trapping-rain-water-ii", + "question__hide": false, + "total_acs": 33098, + "total_submitted": 82044, + "frontend_question_id": 407, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 406, + "question__article__live": true, + "question__article__slug": "queue-reconstruction-by-height", + "question__title": "Queue Reconstruction by Height", + "question__title_slug": "queue-reconstruction-by-height", + "question__hide": false, + "total_acs": 97601, + "total_submitted": 158012, + "frontend_question_id": 406, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 405, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Convert a Number to Hexadecimal", + "question__title_slug": "convert-a-number-to-hexadecimal", + "question__hide": false, + "total_acs": 55757, + "total_submitted": 130111, + "frontend_question_id": 405, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 404, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sum of Left Leaves", + "question__title_slug": "sum-of-left-leaves", + "question__hide": false, + "total_acs": 147302, + "total_submitted": 294909, + "frontend_question_id": 404, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 403, + "question__article__live": true, + "question__article__slug": "frog-jump", + "question__title": "Frog Jump", + "question__title_slug": "frog-jump", + "question__hide": false, + "total_acs": 64886, + "total_submitted": 172383, + "frontend_question_id": 403, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 402, + "question__article__live": true, + "question__article__slug": "remove-k-digits", + "question__title": "Remove K Digits", + "question__title_slug": "remove-k-digits", + "question__hide": false, + "total_acs": 78756, + "total_submitted": 288938, + "frontend_question_id": 402, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 401, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Watch", + "question__title_slug": "binary-watch", + "question__hide": false, + "total_acs": 72320, + "total_submitted": 157126, + "frontend_question_id": 401, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 400, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Nth Digit", + "question__title_slug": "nth-digit", + "question__hide": false, + "total_acs": 52429, + "total_submitted": 170107, + "frontend_question_id": 400, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 399, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Evaluate Division", + "question__title_slug": "evaluate-division", + "question__hide": false, + "total_acs": 102449, + "total_submitted": 207442, + "frontend_question_id": 399, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 398, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Random Pick Index", + "question__title_slug": "random-pick-index", + "question__hide": false, + "total_acs": 65846, + "total_submitted": 126093, + "frontend_question_id": 398, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 397, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Integer Replacement", + "question__title_slug": "integer-replacement", + "question__hide": false, + "total_acs": 46954, + "total_submitted": 146114, + "frontend_question_id": 397, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 396, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Rotate Function", + "question__title_slug": "rotate-function", + "question__hide": false, + "total_acs": 38741, + "total_submitted": 108722, + "frontend_question_id": 396, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 395, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Substring with At Least K Repeating Characters", + "question__title_slug": "longest-substring-with-at-least-k-repeating-characters", + "question__hide": false, + "total_acs": 59787, + "total_submitted": 150256, + "frontend_question_id": 395, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 394, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Decode String", + "question__title_slug": "decode-string", + "question__hide": false, + "total_acs": 149801, + "total_submitted": 316577, + "frontend_question_id": 394, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 393, + "question__article__live": true, + "question__article__slug": "utf-8-validation", + "question__title": "UTF-8 Validation", + "question__title_slug": "utf-8-validation", + "question__hide": false, + "total_acs": 42339, + "total_submitted": 115536, + "frontend_question_id": 393, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 392, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Is Subsequence", + "question__title_slug": "is-subsequence", + "question__hide": false, + "total_acs": 121073, + "total_submitted": 253788, + "frontend_question_id": 392, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 391, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Perfect Rectangle", + "question__title_slug": "perfect-rectangle", + "question__hide": false, + "total_acs": 21125, + "total_submitted": 72456, + "frontend_question_id": 391, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 390, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Elimination Game", + "question__title_slug": "elimination-game", + "question__hide": false, + "total_acs": 27161, + "total_submitted": 61650, + "frontend_question_id": 390, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 389, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find the Difference", + "question__title_slug": "find-the-difference", + "question__hide": false, + "total_acs": 166598, + "total_submitted": 308494, + "frontend_question_id": 389, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 388, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Longest Absolute File Path", + "question__title_slug": "longest-absolute-file-path", + "question__hide": false, + "total_acs": 75202, + "total_submitted": 185978, + "frontend_question_id": 388, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 387, + "question__article__live": true, + "question__article__slug": "first-unique-character-in-a-string", + "question__title": "First Unique Character in a String", + "question__title_slug": "first-unique-character-in-a-string", + "question__hide": false, + "total_acs": 354408, + "total_submitted": 693938, + "frontend_question_id": 387, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 386, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Lexicographical Numbers", + "question__title_slug": "lexicographical-numbers", + "question__hide": false, + "total_acs": 46664, + "total_submitted": 95853, + "frontend_question_id": 386, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 385, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Mini Parser", + "question__title_slug": "mini-parser", + "question__hide": false, + "total_acs": 33767, + "total_submitted": 103516, + "frontend_question_id": 385, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 384, + "question__article__live": true, + "question__article__slug": "shuffle-an-array", + "question__title": "Shuffle an Array", + "question__title_slug": "shuffle-an-array", + "question__hide": false, + "total_acs": 97415, + "total_submitted": 189679, + "frontend_question_id": 384, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 383, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Ransom Note", + "question__title_slug": "ransom-note", + "question__hide": false, + "total_acs": 131055, + "total_submitted": 256470, + "frontend_question_id": 383, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 382, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Linked List Random Node", + "question__title_slug": "linked-list-random-node", + "question__hide": false, + "total_acs": 61197, + "total_submitted": 120792, + "frontend_question_id": 382, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 381, + "question__article__live": true, + "question__article__slug": "insert-delete-getrandom-o1-duplicates-allowed", + "question__title": "Insert Delete GetRandom O(1) - Duplicates allowed", + "question__title_slug": "insert-delete-getrandom-o1-duplicates-allowed", + "question__hide": false, + "total_acs": 52078, + "total_submitted": 157578, + "frontend_question_id": 381, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 380, + "question__article__live": true, + "question__article__slug": "insert-delete-getrandom-o1", + "question__title": "Insert Delete GetRandom O(1)", + "question__title_slug": "insert-delete-getrandom-o1", + "question__hide": false, + "total_acs": 152405, + "total_submitted": 341989, + "frontend_question_id": 380, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 379, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Phone Directory", + "question__title_slug": "design-phone-directory", + "question__hide": false, + "total_acs": 30041, + "total_submitted": 67409, + "frontend_question_id": 379, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 378, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Kth Smallest Element in a Sorted Matrix", + "question__title_slug": "kth-smallest-element-in-a-sorted-matrix", + "question__hide": false, + "total_acs": 141013, + "total_submitted": 273872, + "frontend_question_id": 378, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 377, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Combination Sum IV", + "question__title_slug": "combination-sum-iv", + "question__hide": false, + "total_acs": 100585, + "total_submitted": 227978, + "frontend_question_id": 377, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 376, + "question__article__live": true, + "question__article__slug": "wiggle-subsequence", + "question__title": "Wiggle Subsequence", + "question__title_slug": "wiggle-subsequence", + "question__hide": false, + "total_acs": 56325, + "total_submitted": 146124, + "frontend_question_id": 376, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 375, + "question__article__live": true, + "question__article__slug": "guess-number-higher-or-lower-ii", + "question__title": "Guess Number Higher or Lower II", + "question__title_slug": "guess-number-higher-or-lower-ii", + "question__hide": false, + "total_acs": 51963, + "total_submitted": 133025, + "frontend_question_id": 375, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 374, + "question__article__live": true, + "question__article__slug": "guess-number-higher-or-lower", + "question__title": "Guess Number Higher or Lower", + "question__title_slug": "guess-number-higher-or-lower", + "question__hide": false, + "total_acs": 126152, + "total_submitted": 308659, + "frontend_question_id": 374, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 373, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find K Pairs with Smallest Sums", + "question__title_slug": "find-k-pairs-with-smallest-sums", + "question__hide": false, + "total_acs": 80260, + "total_submitted": 229821, + "frontend_question_id": 373, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 372, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Super Pow", + "question__title_slug": "super-pow", + "question__hide": false, + "total_acs": 31141, + "total_submitted": 86279, + "frontend_question_id": 372, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 371, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sum of Two Integers", + "question__title_slug": "sum-of-two-integers", + "question__hide": false, + "total_acs": 156566, + "total_submitted": 308500, + "frontend_question_id": 371, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 370, + "question__article__live": true, + "question__article__slug": "range-addition", + "question__title": "Range Addition", + "question__title_slug": "range-addition", + "question__hide": false, + "total_acs": 27613, + "total_submitted": 44852, + "frontend_question_id": 370, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 369, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Plus One Linked List", + "question__title_slug": "plus-one-linked-list", + "question__hide": false, + "total_acs": 39700, + "total_submitted": 69270, + "frontend_question_id": 369, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 368, + "question__article__live": true, + "question__article__slug": "largest-divisible-subset", + "question__title": "Largest Divisible Subset", + "question__title_slug": "largest-divisible-subset", + "question__hide": false, + "total_acs": 53224, + "total_submitted": 149388, + "frontend_question_id": 368, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 367, + "question__article__live": true, + "question__article__slug": "valid-perfect-square", + "question__title": "Valid Perfect Square", + "question__title_slug": "valid-perfect-square", + "question__hide": false, + "total_acs": 134334, + "total_submitted": 330687, + "frontend_question_id": 367, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 366, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find Leaves of Binary Tree", + "question__title_slug": "find-leaves-of-binary-tree", + "question__hide": false, + "total_acs": 57252, + "total_submitted": 83728, + "frontend_question_id": 366, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 365, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Water and Jug Problem", + "question__title_slug": "water-and-jug-problem", + "question__hide": false, + "total_acs": 32911, + "total_submitted": 110610, + "frontend_question_id": 365, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 364, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Nested List Weight Sum II", + "question__title_slug": "nested-list-weight-sum-ii", + "question__hide": false, + "total_acs": 48779, + "total_submitted": 81001, + "frontend_question_id": 364, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 363, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Max Sum of Rectangle No Larger Than K", + "question__title_slug": "max-sum-of-rectangle-no-larger-than-k", + "question__hide": false, + "total_acs": 32497, + "total_submitted": 90508, + "frontend_question_id": 363, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 362, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Hit Counter", + "question__title_slug": "design-hit-counter", + "question__hide": false, + "total_acs": 58330, + "total_submitted": 95173, + "frontend_question_id": 362, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 361, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Bomb Enemy", + "question__title_slug": "bomb-enemy", + "question__hide": false, + "total_acs": 39657, + "total_submitted": 88737, + "frontend_question_id": 361, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 360, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sort Transformed Array", + "question__title_slug": "sort-transformed-array", + "question__hide": false, + "total_acs": 30397, + "total_submitted": 63865, + "frontend_question_id": 360, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 359, + "question__article__live": true, + "question__article__slug": "logger-rate-limiter", + "question__title": "Logger Rate Limiter", + "question__title_slug": "logger-rate-limiter", + "question__hide": false, + "total_acs": 64713, + "total_submitted": 95658, + "frontend_question_id": 359, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 358, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Rearrange String k Distance Apart", + "question__title_slug": "rearrange-string-k-distance-apart", + "question__hide": false, + "total_acs": 28020, + "total_submitted": 82542, + "frontend_question_id": 358, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 357, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Numbers with Unique Digits", + "question__title_slug": "count-numbers-with-unique-digits", + "question__hide": false, + "total_acs": 68939, + "total_submitted": 144618, + "frontend_question_id": 357, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 356, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Line Reflection", + "question__title_slug": "line-reflection", + "question__hide": false, + "total_acs": 20408, + "total_submitted": 65304, + "frontend_question_id": 356, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 355, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Twitter", + "question__title_slug": "design-twitter", + "question__hide": false, + "total_acs": 41980, + "total_submitted": 146258, + "frontend_question_id": 355, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 354, + "question__article__live": true, + "question__article__slug": "russian-doll-envelopes", + "question__title": "Russian Doll Envelopes", + "question__title_slug": "russian-doll-envelopes", + "question__hide": false, + "total_acs": 53943, + "total_submitted": 155369, + "frontend_question_id": 354, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 353, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Snake Game", + "question__title_slug": "design-snake-game", + "question__hide": false, + "total_acs": 26878, + "total_submitted": 83222, + "frontend_question_id": 353, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 352, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Data Stream as Disjoint Intervals", + "question__title_slug": "data-stream-as-disjoint-intervals", + "question__hide": false, + "total_acs": 28092, + "total_submitted": 62984, + "frontend_question_id": 352, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 351, + "question__article__live": true, + "question__article__slug": "android-unlock-patterns", + "question__title": "Android Unlock Patterns", + "question__title_slug": "android-unlock-patterns", + "question__hide": false, + "total_acs": 34605, + "total_submitted": 73371, + "frontend_question_id": 351, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 350, + "question__article__live": true, + "question__article__slug": "intersection-of-two-arrays-ii", + "question__title": "Intersection of Two Arrays II", + "question__title_slug": "intersection-of-two-arrays-ii", + "question__hide": false, + "total_acs": 264762, + "total_submitted": 531930, + "frontend_question_id": 350, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 349, + "question__article__live": true, + "question__article__slug": "intersection-of-two-arrays", + "question__title": "Intersection of Two Arrays", + "question__title_slug": "intersection-of-two-arrays", + "question__hide": false, + "total_acs": 278076, + "total_submitted": 478324, + "frontend_question_id": 349, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 348, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Design Tic-Tac-Toe", + "question__title_slug": "design-tic-tac-toe", + "question__hide": false, + "total_acs": 66643, + "total_submitted": 128232, + "frontend_question_id": 348, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 347, + "question__article__live": true, + "question__article__slug": "top-k-frequent-elements", + "question__title": "Top K Frequent Elements", + "question__title_slug": "top-k-frequent-elements", + "question__hide": false, + "total_acs": 279172, + "total_submitted": 483110, + "frontend_question_id": 347, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 346, + "question__article__live": true, + "question__article__slug": "moving-average-from-data-stream", + "question__title": "Moving Average from Data Stream", + "question__title_slug": "moving-average-from-data-stream", + "question__hide": false, + "total_acs": 96704, + "total_submitted": 141611, + "frontend_question_id": 346, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 345, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reverse Vowels of a String", + "question__title_slug": "reverse-vowels-of-a-string", + "question__hide": false, + "total_acs": 183036, + "total_submitted": 430226, + "frontend_question_id": 345, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 344, + "question__article__live": true, + "question__article__slug": "reverse-string", + "question__title": "Reverse String", + "question__title_slug": "reverse-string", + "question__hide": false, + "total_acs": 547668, + "total_submitted": 844677, + "frontend_question_id": 344, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 343, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Integer Break", + "question__title_slug": "integer-break", + "question__hide": false, + "total_acs": 91963, + "total_submitted": 187953, + "frontend_question_id": 343, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 342, + "question__article__live": true, + "question__article__slug": "power-of-four", + "question__title": "Power of Four", + "question__title_slug": "power-of-four", + "question__hide": false, + "total_acs": 129373, + "total_submitted": 316062, + "frontend_question_id": 342, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 341, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flatten Nested List Iterator", + "question__title_slug": "flatten-nested-list-iterator", + "question__hide": false, + "total_acs": 138819, + "total_submitted": 275307, + "frontend_question_id": 341, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 340, + "question__article__live": true, + "question__article__slug": "longest-substring-with-at-most-k-distinct-characte", + "question__title": "Longest Substring with At Most K Distinct Characters", + "question__title_slug": "longest-substring-with-at-most-k-distinct-characters", + "question__hide": false, + "total_acs": 98883, + "total_submitted": 235994, + "frontend_question_id": 340, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 339, + "question__article__live": true, + "question__article__slug": "nested-list-weight-sum", + "question__title": "Nested List Weight Sum", + "question__title_slug": "nested-list-weight-sum", + "question__hide": false, + "total_acs": 70705, + "total_submitted": 99869, + "frontend_question_id": 339, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 338, + "question__article__live": true, + "question__article__slug": "counting-bits", + "question__title": "Counting Bits", + "question__title_slug": "counting-bits", + "question__hide": false, + "total_acs": 204779, + "total_submitted": 309405, + "frontend_question_id": 338, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 337, + "question__article__live": null, + "question__article__slug": null, + "question__title": "House Robber III", + "question__title_slug": "house-robber-iii", + "question__hide": false, + "total_acs": 125046, + "total_submitted": 253653, + "frontend_question_id": 337, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 336, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Palindrome Pairs", + "question__title_slug": "palindrome-pairs", + "question__hide": false, + "total_acs": 84966, + "total_submitted": 262814, + "frontend_question_id": 336, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 335, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Self Crossing", + "question__title_slug": "self-crossing", + "question__hide": false, + "total_acs": 20609, + "total_submitted": 75394, + "frontend_question_id": 335, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 334, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Increasing Triplet Subsequence", + "question__title_slug": "increasing-triplet-subsequence", + "question__hide": false, + "total_acs": 116328, + "total_submitted": 292919, + "frontend_question_id": 334, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 333, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Largest BST Subtree", + "question__title_slug": "largest-bst-subtree", + "question__hide": false, + "total_acs": 38136, + "total_submitted": 110901, + "frontend_question_id": 333, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 332, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reconstruct Itinerary", + "question__title_slug": "reconstruct-itinerary", + "question__hide": false, + "total_acs": 107260, + "total_submitted": 321393, + "frontend_question_id": 332, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 331, + "question__article__live": true, + "question__article__slug": "verify-preorder-serialization-of-a-binary-tree", + "question__title": "Verify Preorder Serialization of a Binary Tree", + "question__title_slug": "verify-preorder-serialization-of-a-binary-tree", + "question__hide": false, + "total_acs": 64624, + "total_submitted": 164014, + "frontend_question_id": 331, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 330, + "question__article__live": true, + "question__article__slug": "patching-array", + "question__title": "Patching Array", + "question__title_slug": "patching-array", + "question__hide": false, + "total_acs": 33679, + "total_submitted": 99431, + "frontend_question_id": 330, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 329, + "question__article__live": true, + "question__article__slug": "longest-increasing-path-matrix", + "question__title": "Longest Increasing Path in a Matrix", + "question__title_slug": "longest-increasing-path-in-a-matrix", + "question__hide": false, + "total_acs": 112116, + "total_submitted": 269715, + "frontend_question_id": 329, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 328, + "question__article__live": true, + "question__article__slug": "odd-even-linked-list", + "question__title": "Odd Even Linked List", + "question__title_slug": "odd-even-linked-list", + "question__hide": false, + "total_acs": 182475, + "total_submitted": 356390, + "frontend_question_id": 328, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 327, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count of Range Sum", + "question__title_slug": "count-of-range-sum", + "question__hide": false, + "total_acs": 36844, + "total_submitted": 108331, + "frontend_question_id": 327, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 326, + "question__article__live": true, + "question__article__slug": "power-of-three", + "question__title": "Power of Three", + "question__title_slug": "power-of-three", + "question__hide": false, + "total_acs": 216141, + "total_submitted": 515967, + "frontend_question_id": 326, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 325, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Size Subarray Sum Equals k", + "question__title_slug": "maximum-size-subarray-sum-equals-k", + "question__hide": false, + "total_acs": 89203, + "total_submitted": 194697, + "frontend_question_id": 325, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 324, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Wiggle Sort II", + "question__title_slug": "wiggle-sort-ii", + "question__hide": false, + "total_acs": 70716, + "total_submitted": 244804, + "frontend_question_id": 324, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 323, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Number of Connected Components in an Undirected Graph", + "question__title_slug": "number-of-connected-components-in-an-undirected-graph", + "question__hide": false, + "total_acs": 75094, + "total_submitted": 140295, + "frontend_question_id": 323, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 322, + "question__article__live": true, + "question__article__slug": "coin-change", + "question__title": "Coin Change", + "question__title_slug": "coin-change", + "question__hide": false, + "total_acs": 279242, + "total_submitted": 854148, + "frontend_question_id": 322, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 321, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Create Maximum Number", + "question__title_slug": "create-maximum-number", + "question__hide": false, + "total_acs": 34105, + "total_submitted": 130932, + "frontend_question_id": 321, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 320, + "question__article__live": true, + "question__article__slug": "generalized-abbreviation", + "question__title": "Generalized Abbreviation", + "question__title_slug": "generalized-abbreviation", + "question__hide": false, + "total_acs": 41445, + "total_submitted": 82898, + "frontend_question_id": 320, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 319, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Bulb Switcher", + "question__title_slug": "bulb-switcher", + "question__hide": false, + "total_acs": 68058, + "total_submitted": 152182, + "frontend_question_id": 319, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 318, + "question__article__live": true, + "question__article__slug": "maximum-product-of-word-lengths", + "question__title": "Maximum Product of Word Lengths", + "question__title_slug": "maximum-product-of-word-lengths", + "question__hide": false, + "total_acs": 87789, + "total_submitted": 176640, + "frontend_question_id": 318, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 317, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Distance from All Buildings", + "question__title_slug": "shortest-distance-from-all-buildings", + "question__hide": false, + "total_acs": 52802, + "total_submitted": 133346, + "frontend_question_id": 317, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 316, + "question__article__live": true, + "question__article__slug": "remove-duplicate-letters", + "question__title": "Remove Duplicate Letters", + "question__title_slug": "remove-duplicate-letters", + "question__hide": false, + "total_acs": 66182, + "total_submitted": 195580, + "frontend_question_id": 316, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 315, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count of Smaller Numbers After Self", + "question__title_slug": "count-of-smaller-numbers-after-self", + "question__hide": false, + "total_acs": 98533, + "total_submitted": 246067, + "frontend_question_id": 315, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 314, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Tree Vertical Order Traversal", + "question__title_slug": "binary-tree-vertical-order-traversal", + "question__hide": false, + "total_acs": 90820, + "total_submitted": 212881, + "frontend_question_id": 314, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 313, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Super Ugly Number", + "question__title_slug": "super-ugly-number", + "question__hide": false, + "total_acs": 68120, + "total_submitted": 157741, + "frontend_question_id": 313, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 312, + "question__article__live": true, + "question__article__slug": "burst-balloons", + "question__title": "Burst Balloons", + "question__title_slug": "burst-balloons", + "question__hide": false, + "total_acs": 78213, + "total_submitted": 158764, + "frontend_question_id": 312, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 311, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sparse Matrix Multiplication", + "question__title_slug": "sparse-matrix-multiplication", + "question__hide": false, + "total_acs": 75197, + "total_submitted": 128709, + "frontend_question_id": 311, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 310, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Minimum Height Trees", + "question__title_slug": "minimum-height-trees", + "question__hide": false, + "total_acs": 77687, + "total_submitted": 249612, + "frontend_question_id": 310, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 309, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Best Time to Buy and Sell Stock with Cooldown", + "question__title_slug": "best-time-to-buy-and-sell-stock-with-cooldown", + "question__hide": false, + "total_acs": 112025, + "total_submitted": 247890, + "frontend_question_id": 309, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 308, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Range Sum Query 2D - Mutable", + "question__title_slug": "range-sum-query-2d-mutable", + "question__hide": false, + "total_acs": 41058, + "total_submitted": 122037, + "frontend_question_id": 308, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 307, + "question__article__live": true, + "question__article__slug": "range-sum-query-mutable", + "question__title": "Range Sum Query - Mutable", + "question__title_slug": "range-sum-query-mutable", + "question__hide": false, + "total_acs": 87029, + "total_submitted": 278435, + "frontend_question_id": 307, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 306, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Additive Number", + "question__title_slug": "additive-number", + "question__hide": false, + "total_acs": 45518, + "total_submitted": 157925, + "frontend_question_id": 306, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 305, + "question__article__live": true, + "question__article__slug": "number-of-islands-ii", + "question__title": "Number of Islands II", + "question__title_slug": "number-of-islands-ii", + "question__hide": false, + "total_acs": 64759, + "total_submitted": 158872, + "frontend_question_id": 305, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 304, + "question__article__live": true, + "question__article__slug": "range-sum-query-2d-immutable", + "question__title": "Range Sum Query 2D - Immutable", + "question__title_slug": "range-sum-query-2d-immutable", + "question__hide": false, + "total_acs": 89433, + "total_submitted": 253661, + "frontend_question_id": 304, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 303, + "question__article__live": true, + "question__article__slug": "range-sum-query-immutable", + "question__title": "Range Sum Query - Immutable", + "question__title_slug": "range-sum-query-immutable", + "question__hide": false, + "total_acs": 165462, + "total_submitted": 405012, + "frontend_question_id": 303, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 302, + "question__article__live": true, + "question__article__slug": "smallest-rectangle-enclosing-black-pixels", + "question__title": "Smallest Rectangle Enclosing Black Pixels", + "question__title_slug": "smallest-rectangle-enclosing-black-pixels", + "question__hide": false, + "total_acs": 25044, + "total_submitted": 49745, + "frontend_question_id": 302, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 301, + "question__article__live": true, + "question__article__slug": "remove-invalid-parentheses", + "question__title": "Remove Invalid Parentheses", + "question__title_slug": "remove-invalid-parentheses", + "question__hide": false, + "total_acs": 161806, + "total_submitted": 393808, + "frontend_question_id": 301, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 300, + "question__article__live": true, + "question__article__slug": "longest-increasing-subsequence", + "question__title": "Longest Increasing Subsequence", + "question__title_slug": "longest-increasing-subsequence", + "question__hide": false, + "total_acs": 288160, + "total_submitted": 690739, + "frontend_question_id": 300, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 299, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Bulls and Cows", + "question__title_slug": "bulls-and-cows", + "question__hide": false, + "total_acs": 120625, + "total_submitted": 294570, + "frontend_question_id": 299, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 298, + "question__article__live": true, + "question__article__slug": "binary-tree-longest-consecutive-sequence", + "question__title": "Binary Tree Longest Consecutive Sequence", + "question__title_slug": "binary-tree-longest-consecutive-sequence", + "question__hide": false, + "total_acs": 70797, + "total_submitted": 155761, + "frontend_question_id": 298, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 297, + "question__article__live": true, + "question__article__slug": "serialize-and-deserialize-binary-tree", + "question__title": "Serialize and Deserialize Binary Tree", + "question__title_slug": "serialize-and-deserialize-binary-tree", + "question__hide": false, + "total_acs": 244883, + "total_submitted": 556321, + "frontend_question_id": 297, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 296, + "question__article__live": true, + "question__article__slug": "best-meeting-point", + "question__title": "Best Meeting Point", + "question__title_slug": "best-meeting-point", + "question__hide": false, + "total_acs": 30262, + "total_submitted": 53625, + "frontend_question_id": 296, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 295, + "question__article__live": true, + "question__article__slug": "find-median-from-data-stream", + "question__title": "Find Median from Data Stream", + "question__title_slug": "find-median-from-data-stream", + "question__hide": false, + "total_acs": 145333, + "total_submitted": 363566, + "frontend_question_id": 295, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 294, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flip Game II", + "question__title_slug": "flip-game-ii", + "question__hide": false, + "total_acs": 48077, + "total_submitted": 97714, + "frontend_question_id": 294, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 293, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flip Game", + "question__title_slug": "flip-game", + "question__hide": false, + "total_acs": 44845, + "total_submitted": 75157, + "frontend_question_id": 293, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 292, + "question__article__live": true, + "question__article__slug": "nim-game", + "question__title": "Nim Game", + "question__title_slug": "nim-game", + "question__hide": false, + "total_acs": 196291, + "total_submitted": 350870, + "frontend_question_id": 292, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 291, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Word Pattern II", + "question__title_slug": "word-pattern-ii", + "question__hide": false, + "total_acs": 39243, + "total_submitted": 92533, + "frontend_question_id": 291, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 290, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Word Pattern", + "question__title_slug": "word-pattern", + "question__hide": false, + "total_acs": 163555, + "total_submitted": 454941, + "frontend_question_id": 290, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 289, + "question__article__live": true, + "question__article__slug": "game-of-life", + "question__title": "Game of Life", + "question__title_slug": "game-of-life", + "question__hide": false, + "total_acs": 143496, + "total_submitted": 289046, + "frontend_question_id": 289, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 288, + "question__article__live": true, + "question__article__slug": "unique-word-abbreviation", + "question__title": "Unique Word Abbreviation", + "question__title_slug": "unique-word-abbreviation", + "question__hide": false, + "total_acs": 46064, + "total_submitted": 220741, + "frontend_question_id": 288, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 287, + "question__article__live": true, + "question__article__slug": "find-the-duplicate-number", + "question__title": "Find the Duplicate Number", + "question__title_slug": "find-the-duplicate-number", + "question__hide": false, + "total_acs": 240231, + "total_submitted": 463982, + "frontend_question_id": 287, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 286, + "question__article__live": true, + "question__article__slug": "walls-and-gates", + "question__title": "Walls and Gates", + "question__title_slug": "walls-and-gates", + "question__hide": false, + "total_acs": 92763, + "total_submitted": 180349, + "frontend_question_id": 286, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 285, + "question__article__live": true, + "question__article__slug": "inorder-successor-in-bst", + "question__title": "Inorder Successor in BST", + "question__title_slug": "inorder-successor-in-bst", + "question__hide": false, + "total_acs": 125984, + "total_submitted": 337866, + "frontend_question_id": 285, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 284, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Peeking Iterator", + "question__title_slug": "peeking-iterator", + "question__hide": false, + "total_acs": 84308, + "total_submitted": 197924, + "frontend_question_id": 284, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 283, + "question__article__live": true, + "question__article__slug": "move-zeroes", + "question__title": "Move Zeroes", + "question__title_slug": "move-zeroes", + "question__hide": false, + "total_acs": 571882, + "total_submitted": 1026262, + "frontend_question_id": 283, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 282, + "question__article__live": true, + "question__article__slug": "expression-add-operators", + "question__title": "Expression Add Operators", + "question__title_slug": "expression-add-operators", + "question__hide": false, + "total_acs": 83349, + "total_submitted": 243417, + "frontend_question_id": 282, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 281, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Zigzag Iterator", + "question__title_slug": "zigzag-iterator", + "question__hide": false, + "total_acs": 58406, + "total_submitted": 102187, + "frontend_question_id": 281, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 280, + "question__article__live": true, + "question__article__slug": "wiggle-sort", + "question__title": "Wiggle Sort", + "question__title_slug": "wiggle-sort", + "question__hide": false, + "total_acs": 75096, + "total_submitted": 120820, + "frontend_question_id": 280, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 279, + "question__article__live": true, + "question__article__slug": "perfect-squares", + "question__title": "Perfect Squares", + "question__title_slug": "perfect-squares", + "question__hide": false, + "total_acs": 225461, + "total_submitted": 517137, + "frontend_question_id": 279, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 278, + "question__article__live": true, + "question__article__slug": "first-bad-version", + "question__title": "First Bad Version", + "question__title_slug": "first-bad-version", + "question__hide": false, + "total_acs": 275226, + "total_submitted": 855551, + "frontend_question_id": 278, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 277, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Find the Celebrity", + "question__title_slug": "find-the-celebrity", + "question__hide": false, + "total_acs": 100671, + "total_submitted": 256992, + "frontend_question_id": 277, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 276, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Paint Fence", + "question__title_slug": "paint-fence", + "question__hide": false, + "total_acs": 47845, + "total_submitted": 128326, + "frontend_question_id": 276, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 275, + "question__article__live": true, + "question__article__slug": "h-index-ii", + "question__title": "H-Index II", + "question__title_slug": "h-index-ii", + "question__hide": false, + "total_acs": 89247, + "total_submitted": 248442, + "frontend_question_id": 275, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 274, + "question__article__live": true, + "question__article__slug": "h-index", + "question__title": "H-Index", + "question__title_slug": "h-index", + "question__hide": false, + "total_acs": 136099, + "total_submitted": 388488, + "frontend_question_id": 274, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 273, + "question__article__live": true, + "question__article__slug": "integer-to-english-words", + "question__title": "Integer to English Words", + "question__title_slug": "integer-to-english-words", + "question__hide": false, + "total_acs": 130662, + "total_submitted": 514573, + "frontend_question_id": 273, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 272, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Closest Binary Search Tree Value II", + "question__title_slug": "closest-binary-search-tree-value-ii", + "question__hide": false, + "total_acs": 46463, + "total_submitted": 97271, + "frontend_question_id": 272, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 271, + "question__article__live": true, + "question__article__slug": "encode-and-decode-strings", + "question__title": "Encode and Decode Strings", + "question__title_slug": "encode-and-decode-strings", + "question__hide": false, + "total_acs": 48808, + "total_submitted": 167900, + "frontend_question_id": 271, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 270, + "question__article__live": true, + "question__article__slug": "closest-bst-value", + "question__title": "Closest Binary Search Tree Value", + "question__title_slug": "closest-binary-search-tree-value", + "question__hide": false, + "total_acs": 104716, + "total_submitted": 230177, + "frontend_question_id": 270, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 269, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Alien Dictionary", + "question__title_slug": "alien-dictionary", + "question__hide": false, + "total_acs": 105621, + "total_submitted": 316425, + "frontend_question_id": 269, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 268, + "question__article__live": true, + "question__article__slug": "missing-number", + "question__title": "Missing Number", + "question__title_slug": "missing-number", + "question__hide": false, + "total_acs": 347170, + "total_submitted": 698678, + "frontend_question_id": 268, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 267, + "question__article__live": true, + "question__article__slug": "palindrome-permutation-ii", + "question__title": "Palindrome Permutation II", + "question__title_slug": "palindrome-permutation-ii", + "question__hide": false, + "total_acs": 31169, + "total_submitted": 89323, + "frontend_question_id": 267, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 266, + "question__article__live": true, + "question__article__slug": "palindrome-permutation", + "question__title": "Palindrome Permutation", + "question__title_slug": "palindrome-permutation", + "question__hide": false, + "total_acs": 75882, + "total_submitted": 124702, + "frontend_question_id": 266, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 265, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Paint House II", + "question__title_slug": "paint-house-ii", + "question__hide": false, + "total_acs": 51826, + "total_submitted": 120274, + "frontend_question_id": 265, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 264, + "question__article__live": true, + "question__article__slug": "ugly-number-ii", + "question__title": "Ugly Number II", + "question__title_slug": "ugly-number-ii", + "question__hide": false, + "total_acs": 122942, + "total_submitted": 322898, + "frontend_question_id": 264, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 263, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Ugly Number", + "question__title_slug": "ugly-number", + "question__hide": false, + "total_acs": 177446, + "total_submitted": 431986, + "frontend_question_id": 263, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 261, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Graph Valid Tree", + "question__title_slug": "graph-valid-tree", + "question__hide": false, + "total_acs": 105991, + "total_submitted": 259670, + "frontend_question_id": 261, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 260, + "question__article__live": true, + "question__article__slug": "single-number-iii", + "question__title": "Single Number III", + "question__title_slug": "single-number-iii", + "question__hide": false, + "total_acs": 120441, + "total_submitted": 204662, + "frontend_question_id": 260, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 259, + "question__article__live": true, + "question__article__slug": "3sum-smaller", + "question__title": "3Sum Smaller", + "question__title_slug": "3sum-smaller", + "question__hide": false, + "total_acs": 57504, + "total_submitted": 124714, + "frontend_question_id": 259, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 258, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Add Digits", + "question__title_slug": "add-digits", + "question__hide": false, + "total_acs": 260372, + "total_submitted": 471890, + "frontend_question_id": 258, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 257, + "question__article__live": true, + "question__article__slug": "binary-tree-paths", + "question__title": "Binary Tree Paths", + "question__title_slug": "binary-tree-paths", + "question__hide": false, + "total_acs": 263194, + "total_submitted": 546562, + "frontend_question_id": 257, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 256, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Paint House", + "question__title_slug": "paint-house", + "question__hide": false, + "total_acs": 68241, + "total_submitted": 134644, + "frontend_question_id": 256, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 255, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Verify Preorder Sequence in Binary Search Tree", + "question__title_slug": "verify-preorder-sequence-in-binary-search-tree", + "question__hide": false, + "total_acs": 42142, + "total_submitted": 94150, + "frontend_question_id": 255, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 254, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Factor Combinations", + "question__title_slug": "factor-combinations", + "question__hide": false, + "total_acs": 62523, + "total_submitted": 137233, + "frontend_question_id": 254, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 253, + "question__article__live": true, + "question__article__slug": "meeting-rooms-ii", + "question__title": "Meeting Rooms II", + "question__title_slug": "meeting-rooms-ii", + "question__hide": false, + "total_acs": 214692, + "total_submitted": 485571, + "frontend_question_id": 253, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 252, + "question__article__live": true, + "question__article__slug": "meeting-rooms", + "question__title": "Meeting Rooms", + "question__title_slug": "meeting-rooms", + "question__hide": false, + "total_acs": 107946, + "total_submitted": 202194, + "frontend_question_id": 252, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 251, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flatten 2D Vector", + "question__title_slug": "flatten-2d-vector", + "question__hide": false, + "total_acs": 67211, + "total_submitted": 150028, + "frontend_question_id": 251, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 250, + "question__article__live": true, + "question__article__slug": "count-univalue-subtrees", + "question__title": "Count Univalue Subtrees", + "question__title_slug": "count-univalue-subtrees", + "question__hide": false, + "total_acs": 50020, + "total_submitted": 98738, + "frontend_question_id": 250, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 249, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Group Shifted Strings", + "question__title_slug": "group-shifted-strings", + "question__hide": false, + "total_acs": 55987, + "total_submitted": 110596, + "frontend_question_id": 249, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 248, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Strobogrammatic Number III", + "question__title_slug": "strobogrammatic-number-iii", + "question__hide": false, + "total_acs": 23405, + "total_submitted": 61489, + "frontend_question_id": 248, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 247, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Strobogrammatic Number II", + "question__title_slug": "strobogrammatic-number-ii", + "question__hide": false, + "total_acs": 60029, + "total_submitted": 130702, + "frontend_question_id": 247, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 246, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Strobogrammatic Number", + "question__title_slug": "strobogrammatic-number", + "question__hide": false, + "total_acs": 63896, + "total_submitted": 146600, + "frontend_question_id": 246, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 245, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Shortest Word Distance III", + "question__title_slug": "shortest-word-distance-iii", + "question__hide": false, + "total_acs": 44047, + "total_submitted": 80901, + "frontend_question_id": 245, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 244, + "question__article__live": true, + "question__article__slug": "shortest-word-distance-ii", + "question__title": "Shortest Word Distance II", + "question__title_slug": "shortest-word-distance-ii", + "question__hide": false, + "total_acs": 60190, + "total_submitted": 119860, + "frontend_question_id": 244, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 243, + "question__article__live": true, + "question__article__slug": "shortest-word-distance", + "question__title": "Shortest Word Distance", + "question__title_slug": "shortest-word-distance", + "question__hide": false, + "total_acs": 81076, + "total_submitted": 136943, + "frontend_question_id": 243, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 242, + "question__article__live": true, + "question__article__slug": "valid-anagram", + "question__title": "Valid Anagram", + "question__title_slug": "valid-anagram", + "question__hide": false, + "total_acs": 435144, + "total_submitted": 800469, + "frontend_question_id": 242, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 241, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Different Ways to Add Parentheses", + "question__title_slug": "different-ways-to-add-parentheses", + "question__hide": false, + "total_acs": 86916, + "total_submitted": 165536, + "frontend_question_id": 241, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 240, + "question__article__live": true, + "question__article__slug": "search-a-2d-matrix-ii", + "question__title": "Search a 2D Matrix II", + "question__title_slug": "search-a-2d-matrix-ii", + "question__hide": false, + "total_acs": 237997, + "total_submitted": 566202, + "frontend_question_id": 240, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 239, + "question__article__live": true, + "question__article__slug": "sliding-window-maximum", + "question__title": "Sliding Window Maximum", + "question__title_slug": "sliding-window-maximum", + "question__hide": false, + "total_acs": 204976, + "total_submitted": 510606, + "frontend_question_id": 239, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 238, + "question__article__live": true, + "question__article__slug": "product-of-array-except-self", + "question__title": "Product of Array Except Self", + "question__title_slug": "product-of-array-except-self", + "question__hide": false, + "total_acs": 347348, + "total_submitted": 602644, + "frontend_question_id": 238, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 237, + "question__article__live": true, + "question__article__slug": "delete-node-linked-list", + "question__title": "Delete Node in a Linked List", + "question__title_slug": "delete-node-in-a-linked-list", + "question__hide": false, + "total_acs": 336391, + "total_submitted": 591594, + "frontend_question_id": 237, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 236, + "question__article__live": true, + "question__article__slug": "lowest-common-ancestor-of-a-binary-tree", + "question__title": "Lowest Common Ancestor of a Binary Tree", + "question__title_slug": "lowest-common-ancestor-of-a-binary-tree", + "question__hide": false, + "total_acs": 358885, + "total_submitted": 870935, + "frontend_question_id": 236, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 235, + "question__article__live": true, + "question__article__slug": "lowest-common-ancestor-of-a-binary-search-tree", + "question__title": "Lowest Common Ancestor of a Binary Search Tree", + "question__title_slug": "lowest-common-ancestor-of-a-binary-search-tree", + "question__hide": false, + "total_acs": 336702, + "total_submitted": 713352, + "frontend_question_id": 235, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 234, + "question__article__live": true, + "question__article__slug": "palindrome-linked-list", + "question__title": "Palindrome Linked List", + "question__title_slug": "palindrome-linked-list", + "question__hide": false, + "total_acs": 324794, + "total_submitted": 867035, + "frontend_question_id": 234, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 233, + "question__article__live": true, + "question__article__slug": "number-of-digit-one", + "question__title": "Number of Digit One", + "question__title_slug": "number-of-digit-one", + "question__hide": false, + "total_acs": 44430, + "total_submitted": 144205, + "frontend_question_id": 233, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 232, + "question__article__live": true, + "question__article__slug": "implement-queue-using-stacks", + "question__title": "Implement Queue using Stacks", + "question__title_slug": "implement-queue-using-stacks", + "question__hide": false, + "total_acs": 177505, + "total_submitted": 385752, + "frontend_question_id": 232, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 231, + "question__article__live": true, + "question__article__slug": "power-of-two", + "question__title": "Power of Two", + "question__title_slug": "power-of-two", + "question__hide": false, + "total_acs": 259762, + "total_submitted": 609941, + "frontend_question_id": 231, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 230, + "question__article__live": true, + "question__article__slug": "kth-smallest-element-in-a-bst", + "question__title": "Kth Smallest Element in a BST", + "question__title_slug": "kth-smallest-element-in-a-bst", + "question__hide": false, + "total_acs": 279540, + "total_submitted": 511433, + "frontend_question_id": 230, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 229, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Majority Element II", + "question__title_slug": "majority-element-ii", + "question__hide": false, + "total_acs": 118991, + "total_submitted": 353643, + "frontend_question_id": 229, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 228, + "question__article__live": true, + "question__article__slug": "summary-ranges", + "question__title": "Summary Ranges", + "question__title_slug": "summary-ranges", + "question__hide": false, + "total_acs": 147126, + "total_submitted": 392491, + "frontend_question_id": 228, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 227, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Basic Calculator II", + "question__title_slug": "basic-calculator-ii", + "question__hide": false, + "total_acs": 141380, + "total_submitted": 401262, + "frontend_question_id": 227, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 226, + "question__article__live": true, + "question__article__slug": "invert-binary-tree", + "question__title": "Invert Binary Tree", + "question__title_slug": "invert-binary-tree", + "question__hide": false, + "total_acs": 388493, + "total_submitted": 640815, + "frontend_question_id": 226, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 225, + "question__article__live": true, + "question__article__slug": "implement-stack-using-queues", + "question__title": "Implement Stack using Queues", + "question__title_slug": "implement-stack-using-queues", + "question__hide": false, + "total_acs": 151397, + "total_submitted": 361900, + "frontend_question_id": 225, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 224, + "question__article__live": true, + "question__article__slug": "basic-calculator", + "question__title": "Basic Calculator", + "question__title_slug": "basic-calculator", + "question__hide": false, + "total_acs": 132585, + "total_submitted": 380980, + "frontend_question_id": 224, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 223, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Rectangle Area", + "question__title_slug": "rectangle-area", + "question__hide": false, + "total_acs": 96244, + "total_submitted": 261912, + "frontend_question_id": 223, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 222, + "question__article__live": true, + "question__article__slug": "count-complete-tree-nodes", + "question__title": "Count Complete Tree Nodes", + "question__title_slug": "count-complete-tree-nodes", + "question__hide": false, + "total_acs": 163460, + "total_submitted": 417528, + "frontend_question_id": 222, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 221, + "question__article__live": true, + "question__article__slug": "maximal-square", + "question__title": "Maximal Square", + "question__title_slug": "maximal-square", + "question__hide": false, + "total_acs": 168136, + "total_submitted": 484089, + "frontend_question_id": 221, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 220, + "question__article__live": true, + "question__article__slug": "contains-duplicate-iii", + "question__title": "Contains Duplicate III", + "question__title_slug": "contains-duplicate-iii", + "question__hide": false, + "total_acs": 106314, + "total_submitted": 523707, + "frontend_question_id": 220, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 219, + "question__article__live": true, + "question__article__slug": "contains-duplicate-ii", + "question__title": "Contains Duplicate II", + "question__title_slug": "contains-duplicate-ii", + "question__hide": false, + "total_acs": 229001, + "total_submitted": 629296, + "frontend_question_id": 219, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 218, + "question__article__live": true, + "question__article__slug": "skyline-problem", + "question__title": "The Skyline Problem", + "question__title_slug": "the-skyline-problem", + "question__hide": false, + "total_acs": 110217, + "total_submitted": 334770, + "frontend_question_id": 218, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 217, + "question__article__live": true, + "question__article__slug": "contains-duplicate", + "question__title": "Contains Duplicate", + "question__title_slug": "contains-duplicate", + "question__hide": false, + "total_acs": 428860, + "total_submitted": 792490, + "frontend_question_id": 217, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 216, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Combination Sum III", + "question__title_slug": "combination-sum-iii", + "question__hide": false, + "total_acs": 142107, + "total_submitted": 264107, + "frontend_question_id": 216, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 215, + "question__article__live": true, + "question__article__slug": "kth-largest-element-in-an-array", + "question__title": "Kth Largest Element in an Array", + "question__title_slug": "kth-largest-element-in-an-array", + "question__hide": false, + "total_acs": 482000, + "total_submitted": 942217, + "frontend_question_id": 215, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 214, + "question__article__live": true, + "question__article__slug": "shortest-palindrome", + "question__title": "Shortest Palindrome", + "question__title_slug": "shortest-palindrome", + "question__hide": false, + "total_acs": 84959, + "total_submitted": 297720, + "frontend_question_id": 214, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 213, + "question__article__live": null, + "question__article__slug": null, + "question__title": "House Robber II", + "question__title_slug": "house-robber-ii", + "question__hide": false, + "total_acs": 139514, + "total_submitted": 390195, + "frontend_question_id": 213, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 212, + "question__article__live": true, + "question__article__slug": "word-search-ii", + "question__title": "Word Search II", + "question__title_slug": "word-search-ii", + "question__hide": false, + "total_acs": 148481, + "total_submitted": 476665, + "frontend_question_id": 212, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 211, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Add and Search Word - Data structure design", + "question__title_slug": "add-and-search-word-data-structure-design", + "question__hide": false, + "total_acs": 140870, + "total_submitted": 426860, + "frontend_question_id": 211, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 210, + "question__article__live": true, + "question__article__slug": "course-schedule-ii", + "question__title": "Course Schedule II", + "question__title_slug": "course-schedule-ii", + "question__hide": false, + "total_acs": 193090, + "total_submitted": 518631, + "frontend_question_id": 210, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 209, + "question__article__live": true, + "question__article__slug": "minimum-size-subarray-sum", + "question__title": "Minimum Size Subarray Sum", + "question__title_slug": "minimum-size-subarray-sum", + "question__hide": false, + "total_acs": 211011, + "total_submitted": 584496, + "frontend_question_id": 209, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 208, + "question__article__live": true, + "question__article__slug": "implement-trie-prefix-tree", + "question__title": "Implement Trie (Prefix Tree)", + "question__title_slug": "implement-trie-prefix-tree", + "question__hide": false, + "total_acs": 222093, + "total_submitted": 525045, + "frontend_question_id": 208, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 207, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Course Schedule", + "question__title_slug": "course-schedule", + "question__hide": false, + "total_acs": 291547, + "total_submitted": 726829, + "frontend_question_id": 207, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 206, + "question__article__live": true, + "question__article__slug": "reverse-linked-list", + "question__title": "Reverse Linked List", + "question__title_slug": "reverse-linked-list", + "question__hide": false, + "total_acs": 756975, + "total_submitted": 1299420, + "frontend_question_id": 206, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 205, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Isomorphic Strings", + "question__title_slug": "isomorphic-strings", + "question__hide": false, + "total_acs": 247275, + "total_submitted": 639302, + "frontend_question_id": 205, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 204, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count Primes", + "question__title_slug": "count-primes", + "question__hide": false, + "total_acs": 288078, + "total_submitted": 953322, + "frontend_question_id": 204, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 203, + "question__article__live": true, + "question__article__slug": "remove-linked-list-elements", + "question__title": "Remove Linked List Elements", + "question__title_slug": "remove-linked-list-elements", + "question__hide": false, + "total_acs": 266337, + "total_submitted": 724736, + "frontend_question_id": 203, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 202, + "question__article__live": true, + "question__article__slug": "happy-number", + "question__title": "Happy Number", + "question__title_slug": "happy-number", + "question__hide": false, + "total_acs": 295522, + "total_submitted": 621168, + "frontend_question_id": 202, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 201, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Bitwise AND of Numbers Range", + "question__title_slug": "bitwise-and-of-numbers-range", + "question__hide": false, + "total_acs": 91996, + "total_submitted": 249740, + "frontend_question_id": 201, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 200, + "question__article__live": true, + "question__article__slug": "number-of-islands", + "question__title": "Number of Islands", + "question__title_slug": "number-of-islands", + "question__hide": false, + "total_acs": 489596, + "total_submitted": 1115236, + "frontend_question_id": 200, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 199, + "question__article__live": true, + "question__article__slug": "binary-tree-right-side-view", + "question__title": "Binary Tree Right Side View", + "question__title_slug": "binary-tree-right-side-view", + "question__hide": false, + "total_acs": 213542, + "total_submitted": 421837, + "frontend_question_id": 199, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 198, + "question__article__live": true, + "question__article__slug": "house-robber", + "question__title": "House Robber", + "question__title_slug": "house-robber", + "question__hide": false, + "total_acs": 402220, + "total_submitted": 969796, + "frontend_question_id": 198, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 191, + "question__article__live": true, + "question__article__slug": "number-1-bits", + "question__title": "Number of 1 Bits", + "question__title_slug": "number-of-1-bits", + "question__hide": false, + "total_acs": 298344, + "total_submitted": 650696, + "frontend_question_id": 191, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 190, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reverse Bits", + "question__title_slug": "reverse-bits", + "question__hide": false, + "total_acs": 210215, + "total_submitted": 620238, + "frontend_question_id": 190, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 189, + "question__article__live": true, + "question__article__slug": "rotate-array", + "question__title": "Rotate Array", + "question__title_slug": "rotate-array", + "question__hide": false, + "total_acs": 375670, + "total_submitted": 1165964, + "frontend_question_id": 189, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 188, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Best Time to Buy and Sell Stock IV", + "question__title_slug": "best-time-to-buy-and-sell-stock-iv", + "question__hide": false, + "total_acs": 105597, + "total_submitted": 388968, + "frontend_question_id": 188, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 187, + "question__article__live": true, + "question__article__slug": "repeated-dna-sequences", + "question__title": "Repeated DNA Sequences", + "question__title_slug": "repeated-dna-sequences", + "question__hide": false, + "total_acs": 141823, + "total_submitted": 379402, + "frontend_question_id": 187, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 186, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reverse Words in a String II", + "question__title_slug": "reverse-words-in-a-string-ii", + "question__hide": false, + "total_acs": 75925, + "total_submitted": 187784, + "frontend_question_id": 186, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 179, + "question__article__live": true, + "question__article__slug": "largest-number", + "question__title": "Largest Number", + "question__title_slug": "largest-number", + "question__hide": false, + "total_acs": 150612, + "total_submitted": 558212, + "frontend_question_id": 179, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 174, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Dungeon Game", + "question__title_slug": "dungeon-game", + "question__hide": false, + "total_acs": 75298, + "total_submitted": 264463, + "frontend_question_id": 174, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 173, + "question__article__live": true, + "question__article__slug": "binary-search-tree-iterator", + "question__title": "Binary Search Tree Iterator", + "question__title_slug": "binary-search-tree-iterator", + "question__hide": false, + "total_acs": 247391, + "total_submitted": 476069, + "frontend_question_id": 173, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 172, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Factorial Trailing Zeroes", + "question__title_slug": "factorial-trailing-zeroes", + "question__hide": false, + "total_acs": 179568, + "total_submitted": 476736, + "frontend_question_id": 172, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 171, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Excel Sheet Column Number", + "question__title_slug": "excel-sheet-column-number", + "question__hide": false, + "total_acs": 250224, + "total_submitted": 473882, + "frontend_question_id": 171, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 170, + "question__article__live": true, + "question__article__slug": "two-sum-iii-data-structure-design", + "question__title": "Two Sum III - Data structure design", + "question__title_slug": "two-sum-iii-data-structure-design", + "question__hide": false, + "total_acs": 69718, + "total_submitted": 216911, + "frontend_question_id": 170, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 169, + "question__article__live": true, + "question__article__slug": "majority-element", + "question__title": "Majority Element", + "question__title_slug": "majority-element", + "question__hide": false, + "total_acs": 469196, + "total_submitted": 852984, + "frontend_question_id": 169, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 168, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Excel Sheet Column Title", + "question__title_slug": "excel-sheet-column-title", + "question__hide": false, + "total_acs": 192507, + "total_submitted": 643910, + "frontend_question_id": 168, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 167, + "question__article__live": true, + "question__article__slug": "two-sum-ii-input-array-is-sorted", + "question__title": "Two Sum II - Input array is sorted", + "question__title_slug": "two-sum-ii-input-array-is-sorted", + "question__hide": false, + "total_acs": 317086, + "total_submitted": 610194, + "frontend_question_id": 167, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 166, + "question__article__live": true, + "question__article__slug": "fraction-to-recurring-decimal", + "question__title": "Fraction to Recurring Decimal", + "question__title_slug": "fraction-to-recurring-decimal", + "question__hide": false, + "total_acs": 103039, + "total_submitted": 505598, + "frontend_question_id": 166, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 165, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Compare Version Numbers", + "question__title_slug": "compare-version-numbers", + "question__hide": false, + "total_acs": 158591, + "total_submitted": 625982, + "frontend_question_id": 165, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 164, + "question__article__live": true, + "question__article__slug": "maximum-gap", + "question__title": "Maximum Gap", + "question__title_slug": "maximum-gap", + "question__hide": false, + "total_acs": 78292, + "total_submitted": 231516, + "frontend_question_id": 164, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 163, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Missing Ranges", + "question__title_slug": "missing-ranges", + "question__hide": false, + "total_acs": 69734, + "total_submitted": 295387, + "frontend_question_id": 163, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 162, + "question__article__live": true, + "question__article__slug": "find-peak-element", + "question__title": "Find Peak Element", + "question__title_slug": "find-peak-element", + "question__hide": false, + "total_acs": 288271, + "total_submitted": 682546, + "frontend_question_id": 162, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 161, + "question__article__live": true, + "question__article__slug": "one-edit-distance", + "question__title": "One Edit Distance", + "question__title_slug": "one-edit-distance", + "question__hide": false, + "total_acs": 92489, + "total_submitted": 288071, + "frontend_question_id": 161, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 160, + "question__article__live": true, + "question__article__slug": "intersection-of-two-linked-lists", + "question__title": "Intersection of Two Linked Lists", + "question__title_slug": "intersection-of-two-linked-lists", + "question__hide": false, + "total_acs": 371121, + "total_submitted": 1009768, + "frontend_question_id": 160, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 159, + "question__article__live": true, + "question__article__slug": "longest-substring-with-at-most-two-distinct-charac", + "question__title": "Longest Substring with At Most Two Distinct Characters", + "question__title_slug": "longest-substring-with-at-most-two-distinct-characters", + "question__hide": false, + "total_acs": 86222, + "total_submitted": 178562, + "frontend_question_id": 159, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 158, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Read N Characters Given Read4 II - Call multiple times", + "question__title_slug": "read-n-characters-given-read4-ii-call-multiple-times", + "question__hide": false, + "total_acs": 81365, + "total_submitted": 275281, + "frontend_question_id": 158, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 157, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Read N Characters Given Read4", + "question__title_slug": "read-n-characters-given-read4", + "question__hide": false, + "total_acs": 86680, + "total_submitted": 274637, + "frontend_question_id": 157, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 156, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Tree Upside Down", + "question__title_slug": "binary-tree-upside-down", + "question__hide": false, + "total_acs": 54641, + "total_submitted": 102790, + "frontend_question_id": 156, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": true, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 155, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Min Stack", + "question__title_slug": "min-stack", + "question__hide": false, + "total_acs": 379082, + "total_submitted": 950852, + "frontend_question_id": 155, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 154, + "question__article__live": true, + "question__article__slug": "find-minimum-in-rotated-sorted-array-ii", + "question__title": "Find Minimum in Rotated Sorted Array II", + "question__title_slug": "find-minimum-in-rotated-sorted-array-ii", + "question__hide": false, + "total_acs": 151543, + "total_submitted": 378686, + "frontend_question_id": 154, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 153, + "question__article__live": true, + "question__article__slug": "find-minimum-in-rotated-sorted-array", + "question__title": "Find Minimum in Rotated Sorted Array", + "question__title_slug": "find-minimum-in-rotated-sorted-array", + "question__hide": false, + "total_acs": 348535, + "total_submitted": 793686, + "frontend_question_id": 153, + "is_new_question": false + }, + "status": null, + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 152, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Maximum Product Subarray", + "question__title_slug": "maximum-product-subarray", + "question__hide": false, + "total_acs": 263867, + "total_submitted": 866699, + "frontend_question_id": 152, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 151, + "question__article__live": true, + "question__article__slug": "reverse-words-in-a-string", + "question__title": "Reverse Words in a String", + "question__title_slug": "reverse-words-in-a-string", + "question__hide": false, + "total_acs": 333573, + "total_submitted": 1790676, + "frontend_question_id": 151, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 150, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Evaluate Reverse Polish Notation", + "question__title_slug": "evaluate-reverse-polish-notation", + "question__hide": false, + "total_acs": 191909, + "total_submitted": 563063, + "frontend_question_id": 150, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 149, + "question__article__live": true, + "question__article__slug": "max-points-on-a-line", + "question__title": "Max Points on a Line", + "question__title_slug": "max-points-on-a-line", + "question__hide": false, + "total_acs": 136525, + "total_submitted": 835394, + "frontend_question_id": 149, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 148, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sort List", + "question__title_slug": "sort-list", + "question__hide": false, + "total_acs": 219321, + "total_submitted": 571693, + "frontend_question_id": 148, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 147, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Insertion Sort List", + "question__title_slug": "insertion-sort-list", + "question__hide": false, + "total_acs": 165323, + "total_submitted": 423873, + "frontend_question_id": 147, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 146, + "question__article__live": true, + "question__article__slug": "lru-cache", + "question__title": "LRU Cache", + "question__title_slug": "lru-cache", + "question__hide": false, + "total_acs": 395376, + "total_submitted": 1375140, + "frontend_question_id": 146, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 145, + "question__article__live": true, + "question__article__slug": "binary-tree-postorder-transversal", + "question__title": "Binary Tree Postorder Traversal", + "question__title_slug": "binary-tree-postorder-traversal", + "question__hide": false, + "total_acs": 309863, + "total_submitted": 603760, + "frontend_question_id": 145, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 144, + "question__article__live": true, + "question__article__slug": "binary-tree-preorder-transversal", + "question__title": "Binary Tree Preorder Traversal", + "question__title_slug": "binary-tree-preorder-traversal", + "question__hide": false, + "total_acs": 404190, + "total_submitted": 758454, + "frontend_question_id": 144, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 143, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reorder List", + "question__title_slug": "reorder-list", + "question__hide": false, + "total_acs": 184912, + "total_submitted": 554588, + "frontend_question_id": 143, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 142, + "question__article__live": true, + "question__article__slug": "linked-list-cycle-ii", + "question__title": "Linked List Cycle II", + "question__title_slug": "linked-list-cycle-ii", + "question__hide": false, + "total_acs": 257148, + "total_submitted": 748753, + "frontend_question_id": 142, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 141, + "question__article__live": true, + "question__article__slug": "linked-list-cycle", + "question__title": "Linked List Cycle", + "question__title_slug": "linked-list-cycle", + "question__hide": false, + "total_acs": 497088, + "total_submitted": 1278570, + "frontend_question_id": 141, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 140, + "question__article__live": true, + "question__article__slug": "word-break-ii", + "question__title": "Word Break II", + "question__title_slug": "word-break-ii", + "question__hide": false, + "total_acs": 187604, + "total_submitted": 647750, + "frontend_question_id": 140, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 139, + "question__article__live": true, + "question__article__slug": "word-break", + "question__title": "Word Break", + "question__title_slug": "word-break", + "question__hide": false, + "total_acs": 424755, + "total_submitted": 1133315, + "frontend_question_id": 139, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 138, + "question__article__live": true, + "question__article__slug": "copy-list-with-random-pointer", + "question__title": "Copy List with Random Pointer", + "question__title_slug": "copy-list-with-random-pointer", + "question__hide": false, + "total_acs": 315835, + "total_submitted": 1023710, + "frontend_question_id": 138, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 137, + "question__article__live": true, + "question__article__slug": "single-number-ii", + "question__title": "Single Number II", + "question__title_slug": "single-number-ii", + "question__hide": false, + "total_acs": 188165, + "total_submitted": 393276, + "frontend_question_id": 137, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 136, + "question__article__live": true, + "question__article__slug": "single-number", + "question__title": "Single Number", + "question__title_slug": "single-number", + "question__hide": false, + "total_acs": 577004, + "total_submitted": 927995, + "frontend_question_id": 136, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 135, + "question__article__live": true, + "question__article__slug": "candy", + "question__title": "Candy", + "question__title_slug": "candy", + "question__hide": false, + "total_acs": 115157, + "total_submitted": 386194, + "frontend_question_id": 135, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 134, + "question__article__live": true, + "question__article__slug": "gas-station", + "question__title": "Gas Station", + "question__title_slug": "gas-station", + "question__hide": false, + "total_acs": 170587, + "total_submitted": 476720, + "frontend_question_id": 134, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 133, + "question__article__live": true, + "question__article__slug": "clone-graph", + "question__title": "Clone Graph", + "question__title_slug": "clone-graph", + "question__hide": false, + "total_acs": 266682, + "total_submitted": 885920, + "frontend_question_id": 133, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 132, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Palindrome Partitioning II", + "question__title_slug": "palindrome-partitioning-ii", + "question__hide": false, + "total_acs": 115686, + "total_submitted": 402260, + "frontend_question_id": 132, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 131, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Palindrome Partitioning", + "question__title_slug": "palindrome-partitioning", + "question__hide": false, + "total_acs": 191722, + "total_submitted": 438257, + "frontend_question_id": 131, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 130, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Surrounded Regions", + "question__title_slug": "surrounded-regions", + "question__hide": false, + "total_acs": 174103, + "total_submitted": 704779, + "frontend_question_id": 130, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 129, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Sum Root to Leaf Numbers", + "question__title_slug": "sum-root-to-leaf-numbers", + "question__hide": false, + "total_acs": 213009, + "total_submitted": 477203, + "frontend_question_id": 129, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 128, + "question__article__live": true, + "question__article__slug": "longest-consecutive-sequence", + "question__title": "Longest Consecutive Sequence", + "question__title_slug": "longest-consecutive-sequence", + "question__hide": false, + "total_acs": 246673, + "total_submitted": 569750, + "frontend_question_id": 128, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 127, + "question__article__live": true, + "question__article__slug": "word-ladder", + "question__title": "Word Ladder", + "question__title_slug": "word-ladder", + "question__hide": false, + "total_acs": 330629, + "total_submitted": 1241598, + "frontend_question_id": 127, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 126, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Word Ladder II", + "question__title_slug": "word-ladder-ii", + "question__hide": false, + "total_acs": 148977, + "total_submitted": 754991, + "frontend_question_id": 126, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 125, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Palindrome", + "question__title_slug": "valid-palindrome", + "question__hide": false, + "total_acs": 449323, + "total_submitted": 1351731, + "frontend_question_id": 125, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 124, + "question__article__live": true, + "question__article__slug": "binary-tree-maximum-path-sum", + "question__title": "Binary Tree Maximum Path Sum", + "question__title_slug": "binary-tree-maximum-path-sum", + "question__hide": false, + "total_acs": 250370, + "total_submitted": 789395, + "frontend_question_id": 124, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 123, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Best Time to Buy and Sell Stock III", + "question__title_slug": "best-time-to-buy-and-sell-stock-iii", + "question__hide": false, + "total_acs": 177631, + "total_submitted": 501017, + "frontend_question_id": 123, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 122, + "question__article__live": true, + "question__article__slug": "best-time-to-buy-and-sell-stock-ii", + "question__title": "Best Time to Buy and Sell Stock II", + "question__title_slug": "best-time-to-buy-and-sell-stock-ii", + "question__hide": false, + "total_acs": 406687, + "total_submitted": 756611, + "frontend_question_id": 122, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 121, + "question__article__live": true, + "question__article__slug": "best-time-to-buy-and-sell-stock", + "question__title": "Best Time to Buy and Sell Stock", + "question__title_slug": "best-time-to-buy-and-sell-stock", + "question__hide": false, + "total_acs": 652750, + "total_submitted": 1336897, + "frontend_question_id": 121, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 120, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Triangle", + "question__title_slug": "triangle", + "question__hide": false, + "total_acs": 210873, + "total_submitted": 507898, + "frontend_question_id": 120, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 119, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Pascal's Triangle II", + "question__title_slug": "pascals-triangle-ii", + "question__hide": false, + "total_acs": 238124, + "total_submitted": 516625, + "frontend_question_id": 119, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 118, + "question__article__live": true, + "question__article__slug": "pascals-triangle", + "question__title": "Pascal's Triangle", + "question__title_slug": "pascals-triangle", + "question__hide": false, + "total_acs": 310110, + "total_submitted": 632913, + "frontend_question_id": 118, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 117, + "question__article__live": true, + "question__article__slug": "populating-next-right-pointers-in-each-node-ii", + "question__title": "Populating Next Right Pointers in Each Node II", + "question__title_slug": "populating-next-right-pointers-in-each-node-ii", + "question__hide": false, + "total_acs": 213412, + "total_submitted": 587042, + "frontend_question_id": 117, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 116, + "question__article__live": true, + "question__article__slug": "populating-next-right-pointers-in-each-node", + "question__title": "Populating Next Right Pointers in Each Node", + "question__title_slug": "populating-next-right-pointers-in-each-node", + "question__hide": false, + "total_acs": 290035, + "total_submitted": 715065, + "frontend_question_id": 116, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 115, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Distinct Subsequences", + "question__title_slug": "distinct-subsequences", + "question__hide": false, + "total_acs": 118840, + "total_submitted": 327686, + "frontend_question_id": 115, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 114, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Flatten Binary Tree to Linked List", + "question__title_slug": "flatten-binary-tree-to-linked-list", + "question__hide": false, + "total_acs": 282399, + "total_submitted": 623277, + "frontend_question_id": 114, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 113, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Path Sum II", + "question__title_slug": "path-sum-ii", + "question__hide": false, + "total_acs": 275024, + "total_submitted": 635470, + "frontend_question_id": 113, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 112, + "question__article__live": true, + "question__article__slug": "path-sum", + "question__title": "Path Sum", + "question__title_slug": "path-sum", + "question__hide": false, + "total_acs": 379451, + "total_submitted": 965811, + "frontend_question_id": 112, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 111, + "question__article__live": true, + "question__article__slug": "minimum-depth-of-binary-tree", + "question__title": "Minimum Depth of Binary Tree", + "question__title_slug": "minimum-depth-of-binary-tree", + "question__hide": false, + "total_acs": 345913, + "total_submitted": 954647, + "frontend_question_id": 111, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 110, + "question__article__live": true, + "question__article__slug": "balanced-binary-tree", + "question__title": "Balanced Binary Tree", + "question__title_slug": "balanced-binary-tree", + "question__hide": false, + "total_acs": 377867, + "total_submitted": 896233, + "frontend_question_id": 110, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 109, + "question__article__live": true, + "question__article__slug": "convert-sorted-list-to-binary-search-tree", + "question__title": "Convert Sorted List to Binary Search Tree", + "question__title_slug": "convert-sorted-list-to-binary-search-tree", + "question__hide": false, + "total_acs": 205035, + "total_submitted": 468941, + "frontend_question_id": 109, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 108, + "question__article__live": true, + "question__article__slug": "convert-sorted-array-to-bst", + "question__title": "Convert Sorted Array to Binary Search Tree", + "question__title_slug": "convert-sorted-array-to-binary-search-tree", + "question__hide": false, + "total_acs": 321662, + "total_submitted": 597246, + "frontend_question_id": 108, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 107, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Tree Level Order Traversal II", + "question__title_slug": "binary-tree-level-order-traversal-ii", + "question__hide": false, + "total_acs": 263112, + "total_submitted": 535959, + "frontend_question_id": 107, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 106, + "question__article__live": true, + "question__article__slug": "construct-binary-tree-from-inorder-and-postorder-t", + "question__title": "Construct Binary Tree from Inorder and Postorder Traversal", + "question__title_slug": "construct-binary-tree-from-inorder-and-postorder-traversal", + "question__hide": false, + "total_acs": 180405, + "total_submitted": 428748, + "frontend_question_id": 106, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 105, + "question__article__live": true, + "question__article__slug": "construct-binary-tree-from-preorder-and-inorder-tr", + "question__title": "Construct Binary Tree from Preorder and Inorder Traversal", + "question__title_slug": "construct-binary-tree-from-preorder-and-inorder-traversal", + "question__hide": false, + "total_acs": 278767, + "total_submitted": 626772, + "frontend_question_id": 105, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 104, + "question__article__live": true, + "question__article__slug": "maximum-depth-of-binary-tree", + "question__title": "Maximum Depth of Binary Tree", + "question__title_slug": "maximum-depth-of-binary-tree", + "question__hide": false, + "total_acs": 639201, + "total_submitted": 1013120, + "frontend_question_id": 104, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 103, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Binary Tree Zigzag Level Order Traversal", + "question__title_slug": "binary-tree-zigzag-level-order-traversal", + "question__hide": false, + "total_acs": 279445, + "total_submitted": 631101, + "frontend_question_id": 103, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 102, + "question__article__live": true, + "question__article__slug": "binary-tree-level-order-traversal", + "question__title": "Binary Tree Level Order Traversal", + "question__title_slug": "binary-tree-level-order-traversal", + "question__hide": false, + "total_acs": 473615, + "total_submitted": 925947, + "frontend_question_id": 102, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 101, + "question__article__live": true, + "question__article__slug": "symmetric-tree", + "question__title": "Symmetric Tree", + "question__title_slug": "symmetric-tree", + "question__hide": false, + "total_acs": 506230, + "total_submitted": 1123378, + "frontend_question_id": 101, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 100, + "question__article__live": true, + "question__article__slug": "same-tree", + "question__title": "Same Tree", + "question__title_slug": "same-tree", + "question__hide": false, + "total_acs": 451650, + "total_submitted": 880037, + "frontend_question_id": 100, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 99, + "question__article__live": true, + "question__article__slug": "recover-binary-search-tree", + "question__title": "Recover Binary Search Tree", + "question__title_slug": "recover-binary-search-tree", + "question__hide": false, + "total_acs": 136265, + "total_submitted": 372784, + "frontend_question_id": 99, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 98, + "question__article__live": true, + "question__article__slug": "validate-binary-search-tree", + "question__title": "Validate Binary Search Tree", + "question__title_slug": "validate-binary-search-tree", + "question__hide": false, + "total_acs": 526578, + "total_submitted": 1969323, + "frontend_question_id": 98, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 97, + "question__article__live": true, + "question__article__slug": "interleaving-strings", + "question__title": "Interleaving String", + "question__title_slug": "interleaving-string", + "question__hide": false, + "total_acs": 129651, + "total_submitted": 438522, + "frontend_question_id": 97, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 96, + "question__article__live": true, + "question__article__slug": "unique-binary-search-trees", + "question__title": "Unique Binary Search Trees", + "question__title_slug": "unique-binary-search-trees", + "question__hide": false, + "total_acs": 235896, + "total_submitted": 483989, + "frontend_question_id": 96, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 95, + "question__article__live": true, + "question__article__slug": "unique-binary-search-trees-ii", + "question__title": "Unique Binary Search Trees II", + "question__title_slug": "unique-binary-search-trees-ii", + "question__hide": false, + "total_acs": 161183, + "total_submitted": 427502, + "frontend_question_id": 95, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 94, + "question__article__live": true, + "question__article__slug": "binary-tree-inorder-traversal", + "question__title": "Binary Tree Inorder Traversal", + "question__title_slug": "binary-tree-inorder-traversal", + "question__hide": false, + "total_acs": 578014, + "total_submitted": 968391, + "frontend_question_id": 94, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 93, + "question__article__live": true, + "question__article__slug": "restore-ip-addresses", + "question__title": "Restore IP Addresses", + "question__title_slug": "restore-ip-addresses", + "question__hide": false, + "total_acs": 160628, + "total_submitted": 486457, + "frontend_question_id": 93, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 92, + "question__article__live": true, + "question__article__slug": "reverse-linked-list-ii", + "question__title": "Reverse Linked List II", + "question__title_slug": "reverse-linked-list-ii", + "question__hide": false, + "total_acs": 228321, + "total_submitted": 622958, + "frontend_question_id": 92, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 91, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Decode Ways", + "question__title_slug": "decode-ways", + "question__hide": false, + "total_acs": 319673, + "total_submitted": 1372460, + "frontend_question_id": 91, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 90, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Subsets II", + "question__title_slug": "subsets-ii", + "question__hide": false, + "total_acs": 236833, + "total_submitted": 532229, + "frontend_question_id": 90, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 89, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Gray Code", + "question__title_slug": "gray-code", + "question__hide": false, + "total_acs": 148021, + "total_submitted": 312793, + "frontend_question_id": 89, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 88, + "question__article__live": true, + "question__article__slug": "merge-sorted-arrays", + "question__title": "Merge Sorted Array", + "question__title_slug": "merge-sorted-array", + "question__hide": false, + "total_acs": 454938, + "total_submitted": 1212989, + "frontend_question_id": 88, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 87, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Scramble String", + "question__title_slug": "scramble-string", + "question__hide": false, + "total_acs": 99093, + "total_submitted": 304473, + "frontend_question_id": 87, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 86, + "question__article__live": true, + "question__article__slug": "partition-list", + "question__title": "Partition List", + "question__title_slug": "partition-list", + "question__hide": false, + "total_acs": 186783, + "total_submitted": 477695, + "frontend_question_id": 86, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 85, + "question__article__live": true, + "question__article__slug": "maximal-rectangle", + "question__title": "Maximal Rectangle", + "question__title_slug": "maximal-rectangle", + "question__hide": false, + "total_acs": 144738, + "total_submitted": 410033, + "frontend_question_id": 85, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 84, + "question__article__live": true, + "question__article__slug": "largest-rectangle-in-histogram", + "question__title": "Largest Rectangle in Histogram", + "question__title_slug": "largest-rectangle-in-histogram", + "question__hide": false, + "total_acs": 209925, + "total_submitted": 639004, + "frontend_question_id": 84, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 83, + "question__article__live": true, + "question__article__slug": "remove-duplicates-from-sorted-list", + "question__title": "Remove Duplicates from Sorted List", + "question__title_slug": "remove-duplicates-from-sorted-list", + "question__hide": false, + "total_acs": 386373, + "total_submitted": 882013, + "frontend_question_id": 83, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 82, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Remove Duplicates from Sorted List II", + "question__title_slug": "remove-duplicates-from-sorted-list-ii", + "question__hide": false, + "total_acs": 212065, + "total_submitted": 610851, + "frontend_question_id": 82, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 81, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Search in Rotated Sorted Array II", + "question__title_slug": "search-in-rotated-sorted-array-ii", + "question__hide": false, + "total_acs": 200443, + "total_submitted": 610470, + "frontend_question_id": 81, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 80, + "question__article__live": true, + "question__article__slug": "remove-duplicates-from-sorted-array-ii", + "question__title": "Remove Duplicates from Sorted Array II", + "question__title_slug": "remove-duplicates-from-sorted-array-ii", + "question__hide": false, + "total_acs": 229916, + "total_submitted": 547988, + "frontend_question_id": 80, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 79, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Word Search", + "question__title_slug": "word-search", + "question__hide": false, + "total_acs": 361924, + "total_submitted": 1095322, + "frontend_question_id": 79, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 78, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Subsets", + "question__title_slug": "subsets", + "question__hide": false, + "total_acs": 451044, + "total_submitted": 797393, + "frontend_question_id": 78, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 77, + "question__article__live": true, + "question__article__slug": "combinations", + "question__title": "Combinations", + "question__title_slug": "combinations", + "question__hide": false, + "total_acs": 242273, + "total_submitted": 475385, + "frontend_question_id": 77, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 76, + "question__article__live": true, + "question__article__slug": "minimum-window-substring", + "question__title": "Minimum Window Substring", + "question__title_slug": "minimum-window-substring", + "question__hide": false, + "total_acs": 305349, + "total_submitted": 934563, + "frontend_question_id": 76, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 75, + "question__article__live": true, + "question__article__slug": "sort-colors", + "question__title": "Sort Colors", + "question__title_slug": "sort-colors", + "question__hide": false, + "total_acs": 383564, + "total_submitted": 872940, + "frontend_question_id": 75, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 74, + "question__article__live": true, + "question__article__slug": "search-in-2d-matrix", + "question__title": "Search a 2D Matrix", + "question__title_slug": "search-a-2d-matrix", + "question__hide": false, + "total_acs": 267575, + "total_submitted": 752288, + "frontend_question_id": 74, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 73, + "question__article__live": true, + "question__article__slug": "set-matrix-zeroes", + "question__title": "Set Matrix Zeroes", + "question__title_slug": "set-matrix-zeroes", + "question__hide": false, + "total_acs": 254966, + "total_submitted": 615252, + "frontend_question_id": 73, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 72, + "question__article__live": true, + "question__article__slug": "edit-distance", + "question__title": "Edit Distance", + "question__title_slug": "edit-distance", + "question__hide": false, + "total_acs": 210891, + "total_submitted": 522087, + "frontend_question_id": 72, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 71, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Simplify Path", + "question__title_slug": "simplify-path", + "question__hide": false, + "total_acs": 175212, + "total_submitted": 576738, + "frontend_question_id": 71, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 70, + "question__article__live": true, + "question__article__slug": "climbing-stairs", + "question__title": "Climbing Stairs", + "question__title_slug": "climbing-stairs", + "question__hide": false, + "total_acs": 520981, + "total_submitted": 1142543, + "frontend_question_id": 70, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 69, + "question__article__live": true, + "question__article__slug": "sqrtx", + "question__title": "Sqrt(x)", + "question__title_slug": "sqrtx", + "question__hide": false, + "total_acs": 448319, + "total_submitted": 1380114, + "frontend_question_id": 69, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 68, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Text Justification", + "question__title_slug": "text-justification", + "question__hide": false, + "total_acs": 112716, + "total_submitted": 449094, + "frontend_question_id": 68, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 67, + "question__article__live": true, + "question__article__slug": "add-binary", + "question__title": "Add Binary", + "question__title_slug": "add-binary", + "question__hide": false, + "total_acs": 365032, + "total_submitted": 880416, + "frontend_question_id": 67, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 66, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Plus One", + "question__title_slug": "plus-one", + "question__hide": false, + "total_acs": 478255, + "total_submitted": 1144365, + "frontend_question_id": 66, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 65, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Valid Number", + "question__title_slug": "valid-number", + "question__hide": false, + "total_acs": 144305, + "total_submitted": 991063, + "frontend_question_id": 65, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 64, + "question__article__live": true, + "question__article__slug": "minimum-path-sum", + "question__title": "Minimum Path Sum", + "question__title_slug": "minimum-path-sum", + "question__hide": false, + "total_acs": 283596, + "total_submitted": 570409, + "frontend_question_id": 64, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 63, + "question__article__live": true, + "question__article__slug": "unique-paths-ii", + "question__title": "Unique Paths II", + "question__title_slug": "unique-paths-ii", + "question__hide": false, + "total_acs": 241764, + "total_submitted": 715478, + "frontend_question_id": 63, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 62, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Unique Paths", + "question__title_slug": "unique-paths", + "question__hide": false, + "total_acs": 363290, + "total_submitted": 722620, + "frontend_question_id": 62, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 61, + "question__article__live": true, + "question__article__slug": "rotate-list", + "question__title": "Rotate List", + "question__title_slug": "rotate-list", + "question__hide": false, + "total_acs": 226103, + "total_submitted": 796049, + "frontend_question_id": 61, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 60, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Permutation Sequence", + "question__title_slug": "permutation-sequence", + "question__hide": false, + "total_acs": 157415, + "total_submitted": 453912, + "frontend_question_id": 60, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 59, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Spiral Matrix II", + "question__title_slug": "spiral-matrix-ii", + "question__hide": false, + "total_acs": 163593, + "total_submitted": 326277, + "frontend_question_id": 59, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 58, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Length of Last Word", + "question__title_slug": "length-of-last-word", + "question__hide": false, + "total_acs": 316260, + "total_submitted": 977320, + "frontend_question_id": 58, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 57, + "question__article__live": true, + "question__article__slug": "insert-interval", + "question__title": "Insert Interval", + "question__title_slug": "insert-interval", + "question__hide": false, + "total_acs": 207952, + "total_submitted": 646284, + "frontend_question_id": 57, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 56, + "question__article__live": true, + "question__article__slug": "merge-intervals", + "question__title": "Merge Intervals", + "question__title_slug": "merge-intervals", + "question__hide": false, + "total_acs": 456092, + "total_submitted": 1221197, + "frontend_question_id": 56, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 55, + "question__article__live": true, + "question__article__slug": "jump-game", + "question__title": "Jump Game", + "question__title_slug": "jump-game", + "question__hide": false, + "total_acs": 333791, + "total_submitted": 1014801, + "frontend_question_id": 55, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 54, + "question__article__live": true, + "question__article__slug": "spiral-matrix", + "question__title": "Spiral Matrix", + "question__title_slug": "spiral-matrix", + "question__hide": false, + "total_acs": 292069, + "total_submitted": 909358, + "frontend_question_id": 54, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 53, + "question__article__live": true, + "question__article__slug": "maximum-subarray", + "question__title": "Maximum Subarray", + "question__title_slug": "maximum-subarray", + "question__hide": false, + "total_acs": 704684, + "total_submitted": 1560265, + "frontend_question_id": 53, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 52, + "question__article__live": true, + "question__article__slug": "n-queens-ii", + "question__title": "N-Queens II", + "question__title_slug": "n-queens-ii", + "question__hide": false, + "total_acs": 114882, + "total_submitted": 210122, + "frontend_question_id": 52, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 51, + "question__article__live": true, + "question__article__slug": "n-queens", + "question__title": "N-Queens", + "question__title_slug": "n-queens", + "question__hide": false, + "total_acs": 169059, + "total_submitted": 396863, + "frontend_question_id": 51, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 50, + "question__article__live": true, + "question__article__slug": "powx-n", + "question__title": "Pow(x, n)", + "question__title_slug": "powx-n", + "question__hide": false, + "total_acs": 384474, + "total_submitted": 1332397, + "frontend_question_id": 50, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 49, + "question__article__live": true, + "question__article__slug": "group-anagrams", + "question__title": "Group Anagrams", + "question__title_slug": "group-anagrams", + "question__hide": false, + "total_acs": 445104, + "total_submitted": 871060, + "frontend_question_id": 49, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 48, + "question__article__live": true, + "question__article__slug": "rotate-image", + "question__title": "Rotate Image", + "question__title_slug": "rotate-image", + "question__hide": false, + "total_acs": 315972, + "total_submitted": 607557, + "frontend_question_id": 48, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 47, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Permutations II", + "question__title_slug": "permutations-ii", + "question__hide": false, + "total_acs": 292459, + "total_submitted": 676385, + "frontend_question_id": 47, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 46, + "question__article__live": true, + "question__article__slug": "permutations", + "question__title": "Permutations", + "question__title_slug": "permutations", + "question__hide": false, + "total_acs": 474961, + "total_submitted": 807015, + "frontend_question_id": 46, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 45, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Jump Game II", + "question__title_slug": "jump-game-ii", + "question__hide": false, + "total_acs": 209384, + "total_submitted": 714680, + "frontend_question_id": 45, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 44, + "question__article__live": true, + "question__article__slug": "wildcard-matching", + "question__title": "Wildcard Matching", + "question__title_slug": "wildcard-matching", + "question__hide": false, + "total_acs": 208256, + "total_submitted": 877987, + "frontend_question_id": 44, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 43, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Multiply Strings", + "question__title_slug": "multiply-strings", + "question__hide": false, + "total_acs": 242418, + "total_submitted": 754070, + "frontend_question_id": 43, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 42, + "question__article__live": true, + "question__article__slug": "trapping-rain-water", + "question__title": "Trapping Rain Water", + "question__title_slug": "trapping-rain-water", + "question__hide": false, + "total_acs": 391671, + "total_submitted": 853588, + "frontend_question_id": 42, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 41, + "question__article__live": true, + "question__article__slug": "first-missing-positive", + "question__title": "First Missing Positive", + "question__title_slug": "first-missing-positive", + "question__hide": false, + "total_acs": 263927, + "total_submitted": 871745, + "frontend_question_id": 41, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 40, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Combination Sum II", + "question__title_slug": "combination-sum-ii", + "question__hide": false, + "total_acs": 268101, + "total_submitted": 601929, + "frontend_question_id": 40, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 39, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Combination Sum", + "question__title_slug": "combination-sum", + "question__hide": false, + "total_acs": 429417, + "total_submitted": 825438, + "frontend_question_id": 39, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 38, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Count and Say", + "question__title_slug": "count-and-say", + "question__hide": false, + "total_acs": 334887, + "total_submitted": 790475, + "frontend_question_id": 38, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 37, + "question__article__live": true, + "question__article__slug": "sudoku-solver", + "question__title": "Sudoku Solver", + "question__title_slug": "sudoku-solver", + "question__hide": false, + "total_acs": 154407, + "total_submitted": 387897, + "frontend_question_id": 37, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 36, + "question__article__live": true, + "question__article__slug": "valid-sudoku", + "question__title": "Valid Sudoku", + "question__title_slug": "valid-sudoku", + "question__hide": false, + "total_acs": 290435, + "total_submitted": 635010, + "frontend_question_id": 36, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 35, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Search Insert Position", + "question__title_slug": "search-insert-position", + "question__hide": false, + "total_acs": 487472, + "total_submitted": 1179908, + "frontend_question_id": 35, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 34, + "question__article__live": true, + "question__article__slug": "find-first-and-last-position-element-sorted-array", + "question__title": "Find First and Last Position of Element in Sorted Array", + "question__title_slug": "find-first-and-last-position-of-element-in-sorted-array", + "question__hide": false, + "total_acs": 386084, + "total_submitted": 1113507, + "frontend_question_id": 34, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 33, + "question__article__live": true, + "question__article__slug": "search-in-rotated-sorted-array", + "question__title": "Search in Rotated Sorted Array", + "question__title_slug": "search-in-rotated-sorted-array", + "question__hide": false, + "total_acs": 527589, + "total_submitted": 1578372, + "frontend_question_id": 33, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 32, + "question__article__live": true, + "question__article__slug": "longest-valid-parentheses", + "question__title": "Longest Valid Parentheses", + "question__title_slug": "longest-valid-parentheses", + "question__hide": false, + "total_acs": 233040, + "total_submitted": 868261, + "frontend_question_id": 32, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 31, + "question__article__live": true, + "question__article__slug": "next-permutation", + "question__title": "Next Permutation", + "question__title_slug": "next-permutation", + "question__hide": false, + "total_acs": 295895, + "total_submitted": 941478, + "frontend_question_id": 31, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 30, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Substring with Concatenation of All Words", + "question__title_slug": "substring-with-concatenation-of-all-words", + "question__hide": false, + "total_acs": 154397, + "total_submitted": 631342, + "frontend_question_id": 30, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 29, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Divide Two Integers", + "question__title_slug": "divide-two-integers", + "question__hide": false, + "total_acs": 231519, + "total_submitted": 1431850, + "frontend_question_id": 29, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 28, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Implement strStr()", + "question__title_slug": "implement-strstr", + "question__hide": false, + "total_acs": 535185, + "total_submitted": 1604925, + "frontend_question_id": 28, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 27, + "question__article__live": true, + "question__article__slug": "remove-element", + "question__title": "Remove Element", + "question__title_slug": "remove-element", + "question__hide": false, + "total_acs": 498170, + "total_submitted": 1077756, + "frontend_question_id": 27, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 26, + "question__article__live": true, + "question__article__slug": "remove-duplicates-from-sorted-array", + "question__title": "Remove Duplicates from Sorted Array", + "question__title_slug": "remove-duplicates-from-sorted-array", + "question__hide": false, + "total_acs": 752402, + "total_submitted": 1764716, + "frontend_question_id": 26, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 25, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Reverse Nodes in k-Group", + "question__title_slug": "reverse-nodes-in-k-group", + "question__hide": false, + "total_acs": 220674, + "total_submitted": 569314, + "frontend_question_id": 25, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 24, + "question__article__live": true, + "question__article__slug": "swap-nodes-in-pairs", + "question__title": "Swap Nodes in Pairs", + "question__title_slug": "swap-nodes-in-pairs", + "question__hide": false, + "total_acs": 382520, + "total_submitted": 808165, + "frontend_question_id": 24, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 23, + "question__article__live": true, + "question__article__slug": "merge-k-sorted-list", + "question__title": "Merge k Sorted Lists", + "question__title_slug": "merge-k-sorted-lists", + "question__hide": false, + "total_acs": 502440, + "total_submitted": 1350733, + "frontend_question_id": 23, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 22, + "question__article__live": true, + "question__article__slug": "generate-parentheses", + "question__title": "Generate Parentheses", + "question__title_slug": "generate-parentheses", + "question__hide": false, + "total_acs": 430411, + "total_submitted": 736876, + "frontend_question_id": 22, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 21, + "question__article__live": true, + "question__article__slug": "merged-two-sorted-lists", + "question__title": "Merge Two Sorted Lists", + "question__title_slug": "merge-two-sorted-lists", + "question__hide": false, + "total_acs": 766127, + "total_submitted": 1525417, + "frontend_question_id": 21, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 20, + "question__article__live": true, + "question__article__slug": "valid-parentheses", + "question__title": "Valid Parentheses", + "question__title_slug": "valid-parentheses", + "question__hide": false, + "total_acs": 773519, + "total_submitted": 2053147, + "frontend_question_id": 20, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 19, + "question__article__live": true, + "question__article__slug": "remove-nth-node-from-end-of-list", + "question__title": "Remove Nth Node From End of List", + "question__title_slug": "remove-nth-node-from-end-of-list", + "question__hide": false, + "total_acs": 488548, + "total_submitted": 1410600, + "frontend_question_id": 19, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 18, + "question__article__live": null, + "question__article__slug": null, + "question__title": "4Sum", + "question__title_slug": "4sum", + "question__hide": false, + "total_acs": 279501, + "total_submitted": 874059, + "frontend_question_id": 18, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 17, + "question__article__live": true, + "question__article__slug": "letter-combinations-of-a-phone-number", + "question__title": "Letter Combinations of a Phone Number", + "question__title_slug": "letter-combinations-of-a-phone-number", + "question__hide": false, + "total_acs": 485610, + "total_submitted": 1105432, + "frontend_question_id": 17, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 16, + "question__article__live": null, + "question__article__slug": null, + "question__title": "3Sum Closest", + "question__title_slug": "3sum-closest", + "question__hide": false, + "total_acs": 402837, + "total_submitted": 881285, + "frontend_question_id": 16, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 15, + "question__article__live": null, + "question__article__slug": null, + "question__title": "3Sum", + "question__title_slug": "3sum", + "question__hide": false, + "total_acs": 715314, + "total_submitted": 2826225, + "frontend_question_id": 15, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 14, + "question__article__live": true, + "question__article__slug": "longest-common-prefix", + "question__title": "Longest Common Prefix", + "question__title_slug": "longest-common-prefix", + "question__hide": false, + "total_acs": 594052, + "total_submitted": 1725442, + "frontend_question_id": 14, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 13, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Roman to Integer", + "question__title_slug": "roman-to-integer", + "question__hide": false, + "total_acs": 537232, + "total_submitted": 997113, + "frontend_question_id": 13, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 12, + "question__article__live": null, + "question__article__slug": null, + "question__title": "Integer to Roman", + "question__title_slug": "integer-to-roman", + "question__hide": false, + "total_acs": 287227, + "total_submitted": 543588, + "frontend_question_id": 12, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 11, + "question__article__live": true, + "question__article__slug": "container-with-most-water", + "question__title": "Container With Most Water", + "question__title_slug": "container-with-most-water", + "question__hide": false, + "total_acs": 498825, + "total_submitted": 1042025, + "frontend_question_id": 11, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 10, + "question__article__live": true, + "question__article__slug": "regular-expression-matching", + "question__title": "Regular Expression Matching", + "question__title_slug": "regular-expression-matching", + "question__hide": false, + "total_acs": 364908, + "total_submitted": 1405299, + "frontend_question_id": 10, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 9, + "question__article__live": true, + "question__article__slug": "palindrome-number", + "question__title": "Palindrome Number", + "question__title_slug": "palindrome-number", + "question__hide": false, + "total_acs": 742969, + "total_submitted": 1621279, + "frontend_question_id": 9, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 8, + "question__article__live": null, + "question__article__slug": null, + "question__title": "String to Integer (atoi)", + "question__title_slug": "string-to-integer-atoi", + "question__hide": false, + "total_acs": 451380, + "total_submitted": 3032539, + "frontend_question_id": 8, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 7, + "question__article__live": true, + "question__article__slug": "reverse-integer", + "question__title": "Reverse Integer", + "question__title_slug": "reverse-integer", + "question__hide": false, + "total_acs": 881809, + "total_submitted": 3449926, + "frontend_question_id": 7, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 6, + "question__article__live": true, + "question__article__slug": "zigzag-conversion", + "question__title": "ZigZag Conversion", + "question__title_slug": "zigzag-conversion", + "question__hide": false, + "total_acs": 386871, + "total_submitted": 1136528, + "frontend_question_id": 6, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 5, + "question__article__live": true, + "question__article__slug": "longest-palindromic-substring", + "question__title": "Longest Palindromic Substring", + "question__title_slug": "longest-palindromic-substring", + "question__hide": false, + "total_acs": 732982, + "total_submitted": 2581435, + "frontend_question_id": 5, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 4, + "question__article__live": true, + "question__article__slug": "median-of-two-sorted-arrays", + "question__title": "Median of Two Sorted Arrays", + "question__title_slug": "median-of-two-sorted-arrays", + "question__hide": false, + "total_acs": 553483, + "total_submitted": 1985539, + "frontend_question_id": 4, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 3 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 3, + "question__article__live": true, + "question__article__slug": "longest-substring-without-repeating-characters", + "question__title": "Longest Substring Without Repeating Characters", + "question__title_slug": "longest-substring-without-repeating-characters", + "question__hide": false, + "total_acs": 1216294, + "total_submitted": 4162264, + "frontend_question_id": 3, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 2, + "question__article__live": true, + "question__article__slug": "add-two-numbers", + "question__title": "Add Two Numbers", + "question__title_slug": "add-two-numbers", + "question__hide": false, + "total_acs": 1124353, + "total_submitted": 3478766, + "frontend_question_id": 2, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 2 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }, { + "stat": { + "question_id": 1, + "question__article__live": true, + "question__article__slug": "two-sum", + "question__title": "Two Sum", + "question__title_slug": "two-sum", + "question__hide": false, + "total_acs": 2354570, + "total_submitted": 5253643, + "frontend_question_id": 1, + "is_new_question": false + }, + "status": "ac", + "difficulty": { + "level": 1 + }, + "paid_only": false, + "is_favor": false, + "frequency": 0, + "progress": 0 + }], + "frequency_high": 0, + "frequency_mid": 0, + "category_slug": "algorithms" +} +""" diff --git a/Ninja/rename_script.py b/Ninja/rename_script.py new file mode 100644 index 0000000..c2f6d0a --- /dev/null +++ b/Ninja/rename_script.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import json +import glob +import os + +from question_names import LARGE_JSON_STRING + +""" +This is a script that I used to rename the filenames from no index to with index. +""" + +if __name__ == '__main__': + leetcode_data = json.loads(LARGE_JSON_STRING) + questions = leetcode_data['stat_status_pairs'] + name_to_num_dict = {} + for q in questions: + name_to_num_dict[q['stat']['question__title']] = q['stat']['question_id'] + + file_list = glob.glob('./Leetcode/*.py') + cannot_finish = [] + for file in file_list: + filename = file.split('/')[-1].split('.')[0] + question_name = filename.replace('_', ' ') + if question_name in name_to_num_dict: + num = name_to_num_dict[question_name] + new_file_name = "./Leetcode/" + str(num) + '_' + filename + ".py" + # print(new_file_name) + # os.rename(file, new_file_name) + else: + cannot_finish.append(question_name) + + print('*'*100) + print(cannot_finish) From 2c496e3142f71ba28d7b0c360a8f6d9f3f45a4f1 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 22:47:12 -0800 Subject: [PATCH 27/50] Update tool.py with new format --- solutions.md | 10942 +++++++++++++++++++++++++------------------------ tool.py | 9 +- 2 files changed, 5483 insertions(+), 5468 deletions(-) diff --git a/solutions.md b/solutions.md index 5563a30..e9a1ad9 100644 --- a/solutions.md +++ b/solutions.md @@ -1,274 +1,288 @@ -### [1. 15 3Sum](https://oj.leetcode.com/problems/15-3sum/) +### [100. Same Tree](https://oj.leetcode.com/problems/same-tree/) -Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. +Given two binary trees, write a function to check if they are equal or not. -Note: -Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c) -The solution set must not contain duplicate triplets. - For example, given array S = {-1 0 1 2 -1 -4}, +Two binary trees are considered equal if they are structurally identical and the nodes have the same value. - A solution set is: - (-1, 0, 1) - (-1, -1, 2) ```python -class Solution: - # @return a list of lists of length 3, [[val1,val2,val3]] - def threeSum(self, num): - num = sorted(num) - N = len(num) - ret = [] - for i in range(N-2): - if i > 0 and num[i] == num[i-1]: - continue - l = i + 1 - r = N - 1 - while l < r: - if num[i] + num[l] + num[r] < 0: - l += 1 - elif num[i] + num[l] + num[r] > 0: - r -= 1 - else: - ret.append([num[i], num[l], num[r]]) - l += 1 - r -= 1 - while l < r and num[l] == num[l-1]: - l += 1 - while l < r and num[r] == num[r+1]: - r -= 1 - return ret +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None - # Notice: - # 1. This is almost the same to 3 Sum Closest. - # 2. remember to remove duplicate result by doing l += 1 and r -= 1, also the continue on line 22 +class Solution: + # @param p, a tree node + # @param q, a tree node + # @return a boolean + def isSameTree(self, p, q): + if not p and not q: + return True + if not p or not q: + return False + if p.val != q.val: + return False + return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right) ``` ----- -### [2. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) +### [101. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) -Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. +Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). - For example, given array S = {-1 2 1 -4}, and target = 1. +For example, this binary tree is symmetric: - The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). +``` + 1 + / \ + 2 2 + / \ / \ +3 4 4 3 +But the following is not: + 1 + / \ + 2 2 + \ \ + 3 3 +``` +Note: +Bonus points if you could solve it both recursively and iteratively. ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @return an integer - def threeSumClosest(self, num, target): - N = len(num) - num = sorted(num) - ret = sum(num[:3]) - i = 0 - for i in range(N-2): - l = i + 1 - r = N - 1 - while l < r: - threesum = num[i] + num[l] + num[r] - if abs(threesum-target) < abs(ret-target): # Need to check this before changing threesum - ret = threesum - if threesum == target: - return target - elif threesum < target: - l += 1 - else: - r -= 1 - return ret + # @param root, a tree node + # @return a boolean + def isSymmetric(self, root): + return self.isSymmetric_2(root) - # Note: - # Since it's assuming each input only have one result, there's no need to check dup + def isSymmetric_1(self, root): + if root is None: + return True + return self.symmetric_helper(root.left, root.right) + + def symmetric_helper(self, n1, n2): + if not n1 and not n2: + return True + if not n1 or not n2 or n1.val != n2.val: + return False + return self.symmetric_helper(n1.left, n2.right) and self.symmetric_helper(n1.right, n2.left) + + # No need to use two queues here, just one but pop twice would be fine + # Keep in mind which node should be pop first + def isSymmetric_2(self, root): + if root is None: + return True + queue = collections.deque() + queue.append(root.left) + queue.append(root.right) + while len(queue)>0: + t1 = queue.popleft() + t2 = queue.popleft() + if t1 is None and t2 is None: + continue + if t1 is None or t2 is None or t1.val != t2.val: + return False + queue.append(t1.left) + queue.append(t2.right) + queue.append(t1.right) + queue.append(t2.left) + return True ``` ----- -### [3. 4Sum](https://oj.leetcode.com/problems/4sum/) - -Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. +### [102. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) -Note: -Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d) -The solution set must not contain duplicate quadruplets. - For example, given array S = {1 0 -1 0 -2 2}, and target = 0. +Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). - A solution set is: - (-1, 0, 0, 1) - (-2, -1, 1, 2) - (-2, 0, 0, 2) +For example: +Given binary tree {3,9,20,#,#,15,7}, +``` + 3 + / \ + 9 20 + / \ + 15 7 +``` +return its level order traversal as: +[ + [3], + [9,20], + [15,7] +] ```python -class Solution: - # @return a list of lists of length 4, [[val1,val2,val3,val4]] - def fourSum(self, num, target): - return self.fourSum_1(num, target) +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None - # This is kitt's way, using dictionary - def fourSum_1(self, num, target): - N = len(num) - if N < 4: - return [] - num.sort() - res = set() - d = {} - # Convert 4Sum to 2Sum, store every i+j result - for i in range(N): - for j in range(i + 1, N): - if num[i] + num[j] not in d: - d[ num[i] + num[j] ] = [(i,j)] - else: - d[ num[i] + num[j] ].append( (i,j) ) - # Solve 2Sum - for i in range(N): - for j in range(i + 1, N - 2): - T = target - num[i] - num[j] - if T in d: - for k in d[T]: - if k[0] > j: res.add( ( num[i], num[j], num[k[0]], num[k[1]] ) ) - return [ list(i) for i in res ] +class Solution: + # @param root, a tree node + # @return a list of lists of integers + def levelOrder(self, root): + res = [] + if root is None: + return res + queue = [root, ] + while len(queue)>0: + size = len(queue) + level = [] + for i in range(size): + node = queue.pop() + level.append(node.val) + if node.left is not None: + queue.insert(0, node.left) + if node.right is not None: + queue.insert(0, node.right) + res.append(level[:]) + return res - # Won't pass because this is O(n^3) - def fourSum_2(self, num, target): - num.sort() - N = len(num) - ret = [] - for i in range(N-3): - if i > 0 and num[i] == num[i-1]: - continue - for j in range(i+1, N-2): - if j > i+1 and num[j] == num[j-1]: - continue - l = j + 1 - r = N - 1 - while l < r: - four_sum = num[i] + num[j] + num[l] + num[r] - if four_sum < target: - l += 1 - elif four_sum > target: - r -= 1 - else: - ret.append([num[i], num[j], num[l], num[r]]) - l += 1 - r -= 1 - while l < r and num[l] == num[l-1]: - l += 1 - while l < r and num[r] == num[r+1]: - r -= 1 - return ret + # Note + # 1. Try to use double loop to do this + # 2. Other ways are: a. use dummy node(None) b. use two queues ``` ----- -### [4. Add Binary](https://oj.leetcode.com/problems/add-binary/) +### [103. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) -Given two binary strings, return their sum (also a binary string). +Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). -For example, -a = "11" -b = "1" -Return "100". +For example: +Given binary tree {3,9,20,#,#,15,7}, +``` + 3 + / \ + 9 20 + / \ + 15 7 +``` +return its zigzag level order traversal as: +[ + [3], + [20,9], + [15,7] +] ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param a, a string - # @param b, a string - # @return a string - def addBinary(self, a, b): - A = len(a) - B = len(b) + # @param root, a tree node + # @return a list of lists of integers + def zigzagLevelOrder(self, root): + ret = [] + if root is None: + return ret + queue = [root, None] res = [] - carry = 0 - i = 1 - while i <= max(A,B): # using sum at first, then add bit if exist, this is good - sum = carry - if i <= A: - sum += int(a[-i]) - if i <= B: - sum += int(b[-i]) - bit = sum % 2 - carry = sum / 2 - i += 1 - res.insert(0, str(bit)) - if carry > 0: - res.insert(0, '1') - return ''.join(res) - # Nothing would be better than this + zig = False # Because we start from very root, so no reverse at that point + while len(queue) > 0: + node = queue.pop(0) + if node is None: + if zig: + ret.append(res[::-1]) + else: + ret.append(res[:]) + res = [] + if len(queue) == 0: # Break here, otherwise will append another None + break + zig = not zig + queue.append(None) + else: + res.append(node.val) # Remember this, need to do this in node, not node.left/right + if node.left is not None: + queue.append(node.left) + if node.right is not None: + queue.append(node.right) + return ret ``` ----- -### [5. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) +### [104. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) -You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. +Given a binary tree, find its maximum depth. -Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) -Output: 7 -> 0 -> 8 +The maximum depth is the number of nodes along the longest path +from the root node down to the farthest leaf node. ```python -# Definition for singly-linked list. -# class ListNode: +# Definition for a binary tree node +# class TreeNode: # def __init__(self, x): # self.val = x -# self.next = None +# self.left = None +# self.right = None class Solution: - # @return a ListNode - def addTwoNumbers(self, l1, l2): - dummy = ListNode(0) - carry = 0 - cur = dummy - while l1 is not None or l2 is not None or carry > 0: - sum = carry - if l1 is not None: - sum += l1.val - l1 = l1.next - if l2 is not None: - sum += l2.val - l2 = l2.next - cur.next = ListNode(sum % 10) - carry = sum / 10 - cur = cur.next - return dummy.next + # @param root, a tree node + # @return an integer + def maxDepth(self, root): + if root is None: + return 0 + return max( self.maxDepth(root.left), self.maxDepth(root.right) ) + 1 ``` ----- -### [6. Anagrams](https://oj.leetcode.com/problems/anagrams/) +### [105. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) -Given an array of strings, return all groups of strings that are anagrams. +Given preorder and inorder traversal of a tree, construct the binary tree. -Note: All inputs will be in lower-case. +Note: +You may assume that duplicates do not exist in the tree. ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param strs, a list of strings - # @return a list of strings - def anagrams(self, strs): - d = {} - for s in strs: - key = ''.join(sorted(s)) - d.setdefault(key,[]).append(s) - ret = [] - for key in d: - if len(d[key]) > 1: - ret.extend(d[key]) - return ret - # Note: - # 1. Need to use extend here, return those len(d[key]) > 1 - # 2. Need to remember the definition of Anagrams - - Input: ["tea","and","ate","eat","dan"] - Output: ["and","dan"] - Expected: ["and","dan","tea","ate","eat"] - + # @param preorder, a list of integers + # @param inorder, a list of integers + # @return a tree node + def buildTree(self, preorder, inorder): + if len(inorder) == 0: + return None + root = TreeNode(preorder.pop(0)) + index = inorder.index(root.val) + root.left = self.buildTree(preorder, inorder[:index]) + root.right = self.buildTree(preorder, inorder[index+1:]) + return root + # for line 24/25, it's using preorder instead of slicing it. Because when left tree is ready + # all the preorder index are already poped ``` ----- -### [7. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) +### [106. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) -Given a binary tree, determine if it is height-balanced. +Given inorder and postorder traversal of a tree, construct the binary tree. -For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. +Note: +You may assume that duplicates do not exist in the tree. ```python @@ -280,149 +294,217 @@ For this problem, a height-balanced binary tree is defined as a binary tree in w # self.right = None class Solution: - # @param root, a tree node - # @return a boolean - def isBalanced(self, root): - return self.isBalanced_1(root) + # @param inorder, a list of integers + # @param postorder, a list of integers + # @return a tree node + def buildTree(self, inorder, postorder): + if len(inorder) == 0: + return None + root = TreeNode(postorder.pop()) + index = inorder.index(root.val) + root.right = self.buildTree(inorder[index+1:], postorder) + root.left = self.buildTree(inorder[:index], postorder) + return root + # Only difference if pop(0) or pop() + # In this case need to do right first +``` +----- - def isBalanced_1(self, root): - if root is None: - return True - if self.get_height(root) == -1: - return False - return True +### [107. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) - def get_height(self, root): - if root is None: - return 0 - left_height = self.get_height(root.left) - right_height = self.get_height(root.right) - if left_height == -1 or right_height == -1: - return -1 - if abs(left_height - right_height) > 1: - return -1 - return max(left_height, right_height) + 1 +Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). - def isBalanced_2(self, root): - if root is None: - return True - if abs(self.get_max_height(root.left) - self.get_max_height(root.right)) > 1: - return False - return self.isBalanced(root.left) and self.isBalanced(root.right) +For example: +Given binary tree {3,9,20,#,#,15,7}, +``` + 3 + / \ + 9 20 + / \ + 15 7 +``` +return its bottom-up level order traversal as: +[ + [15,7], + [9,20], + [3] +] - def get_max_height(self, root): - if root is None: - return 0 - return max(self.get_max_height(root.left), self.get_max_height(root.right)) + 1 +```python - # First way is a little bit hard to think - # Using -1 as return to sign if height diff > 1 - # First way has better performance +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + +class Solution: + # @param root, a tree node + # @return a list of lists of integers + def levelOrderBottom(self, root): + res = [] + if root is None: + return res + queue = [] + level = [] + queue.append(root) + queue.append(None) + while len(queue)>0: + node = queue.pop(0) + if node is None: + res.append(level[:]) + level = [] + if len(queue)>0: + queue.append(None) + else: + level.append(node.val) + if node.left is not None: + queue.append(node.left) + if node.right is not None: + queue.append(node.right) + return res[::-1] ``` ----- -### [8. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) - -Say you have an array for which the ith element is the price of a given stock on day i. +### [108. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) -If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit. +Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ```python -class Solution: - # @param prices, a list of integer - # @return an integer - def maxProfit(self, prices): - if len(prices) == 0: - return 0 - max_profit = 0 - low_price = prices[0] - for price in prices: - max_profit = max(max_profit, price - low_price) - low_price = min(low_price, price) - return max_profit +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + +class Solution: + # @param num, a list of integers + # @return a tree node + def sortedArrayToBST(self, num): + if len(num) == 0: + return None + return self.sortedArrayToBSTRec(num, 0, len(num)-1) + + def sortedArrayToBSTRec(self, num, start, end): + if start > end: + return None + mid = (start + end) / 2 + node = TreeNode(num[mid]) + node.left = self.sortedArrayToBstRec(num, start, mid-1) + node.right = self.sortedArrayToBstRec(num, mid+1, end) + return node ``` ----- -### [9. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) - -Say you have an array for which the ith element is the price of a given stock on day i. +### [109. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) -Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). +Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None +# +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + class Solution: - # @param prices, a list of integer - # @return an integer - def maxProfit(self, prices): - if len(prices) <= 1: - return 0 - max_profit = 0 - for i in range(1, len(prices)): - if prices[i] - prices[i-1] > 0: - max_profit += prices[i] - prices[i-1] - return max_profit + # @param head, a list node + # @return a tree node + def sortedListToBST(self, head): + cur = head + length = 0 + while cur: + cur = cur.next + length += 1 + self.head = head + return self.sortedRecur(0, length - 1) + + def sortedRecur(self, start, end): + if start > end: + return None + + mid = (start + end) / 2 + left = self.sortedRecur(start, mid - 1) + root = TreeNode(self.head.val) + root.left = left + self.head = self.head.next + root.right = self.sortedRecur(mid + 1, end) + + return root + + # This is creating the tree from leaves to root + # Normal way(Get middle and create each half) takes O(n*logn) + # This way takes O(n) ``` ----- -### [10. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) +### [10. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) -Say you have an array for which the ith element is the price of a given stock on day i. +Implement regular expression matching with support for '.' and '*'. -Design an algorithm to find the maximum profit. You may complete at most two transactions. +'.' Matches any single character. +'*' Matches zero or more of the preceding element. -Note: -You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). +The matching should cover the entire input string (not partial). + +The function prototype should be: +bool isMatch(const char *s, const char *p) + +Some examples: +isMatch("aa","a") → false +isMatch("aa","aa") → true +isMatch("aaa","aa") → false +isMatch("aa", "a*") → true +isMatch("aa", ".*") → true +isMatch("ab", ".*") → true +isMatch("aab", "c*a*b") → true ```python class Solution: - # @param prices, a list of integer - # @return an integer - def maxProfit(self, prices): - N = len(prices) - if N <= 1: - return 0 - dp_1 = [0 for i in range(N)] - dp_2 = [0 for i in range(N)] - min_price = prices[0] - i = 1 - while i < N: - min_price = min(min_price, prices[i]) - dp_1[i] = max(dp_1[i-1], prices[i]-min_price) - i+= 1 + # @return a boolean + def isMatch(self, s, p): + M = len(s) + N = len(p) + dp = [ [False for j in range(N+1)] for i in range(M+1) ] + dp[0][0] = True + pi = 2 # Means pair increase, e.g. p = a*b*c*d*, s ='', should be true + while pi < N + 1 and p[pi-1] == '*': + dp[0][pi] = True + pi += 2 - max_price = prices[-1] - i = N-2 - while i >= 0: - max_price = max(max_price, prices[i]) - dp_2[i] = max(dp_2[i+1], max_price-prices[i]) - i -= 1 - res = 0 - for i in range(N): - res = max(res, dp_1[i] + dp_2[i]) - return res - # Very similart to trapping rain water, from left to right then right to left + for i in range(1, M+1): + for j in range(1, N+1): + if p[j-1] == '.' or s[i-1] == p[j-1]: + dp[i][j] = dp[i-1][j-1] + elif p[j-1] == '*': + dp[i][j] = dp[i][j-2] or \ # * is used as previous*0 e.g. "aaa" = "ab*ac*a" + (dp[i-1][j] and (s[i-1] == p[j-2] or p[j-2] == '.')) # * is used as copy previous e.g. "aa" = "a*" + + return dp[M][N] + + # Notice + # 1. Line 30 initializing + # 2. Line 39 ~ 41 ``` ----- -### [11. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) - -Given a binary tree, return the inorder traversal of its nodes' values. +### [110. Balanced Binary Tree](https://oj.leetcode.com/problems/balanced-binary-tree/) -For example: -Given binary tree {1,#,2,3}, -``` - 1 - \ - 2 - / - 3 -``` -return [1,3,2]. +Given a binary tree, determine if it is height-balanced. -Note: Recursive solution is trivial, could you do it iteratively? +For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. ```python @@ -435,57 +517,51 @@ Note: Recursive solution is trivial, could you do it iteratively? class Solution: # @param root, a tree node - # @return a list of integers - def inorderTraversal(self, root): - return self.inorderTraversal_1(root) + # @return a boolean + def isBalanced(self, root): + return self.isBalanced_1(root) - def inorderTraversal_1(self, root): - stack = [] - current = root - res = [] - while current is not None or len(stack) > 0: - if current is not None: - stack.append(current) - current = current.left - elif len(stack) > 0: - current = stack.pop() - res.append(current.val) - current = current.right - return res + def isBalanced_1(self, root): + if root is None: + return True + if self.get_height(root) == -1: + return False + return True - def inorderTraversal_2(self, root): - res = [] - self.inorderTraversal_rec(root, res) - return res + def get_height(self, root): + if root is None: + return 0 + left_height = self.get_height(root.left) + right_height = self.get_height(root.right) + if left_height == -1 or right_height == -1: + return -1 + if abs(left_height - right_height) > 1: + return -1 + return max(left_height, right_height) + 1 - def inorderTraversal_rec(self, root, res): + def isBalanced_2(self, root): if root is None: - return - self.inorderTraversal_rec(root.left, res) - res.append(root.val) - self.inorderTraversal_rec(root.right, res) + return True + if abs(self.get_max_height(root.left) - self.get_max_height(root.right)) > 1: + return False + return self.isBalanced(root.left) and self.isBalanced(root.right) + + def get_max_height(self, root): + if root is None: + return 0 + return max(self.get_max_height(root.left), self.get_max_height(root.right)) + 1 + + # First way is a little bit hard to think + # Using -1 as return to sign if height diff > 1 + # First way has better performance ``` ----- -### [12. Binary Tree Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-level-order-traversal/) +### [111. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) -Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). +Given a binary tree, find its minimum depth. -For example: -Given binary tree {3,9,20,#,#,15,7}, -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` -return its level order traversal as: -[ - [3], - [9,20], - [15,7] -] +The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. ```python @@ -498,50 +574,37 @@ return its level order traversal as: class Solution: # @param root, a tree node - # @return a list of lists of integers - def levelOrder(self, root): - res = [] - if root is None: - return res - queue = [root, ] - while len(queue)>0: - size = len(queue) - level = [] - for i in range(size): - node = queue.pop() - level.append(node.val) - if node.left is not None: - queue.insert(0, node.left) - if node.right is not None: - queue.insert(0, node.right) - res.append(level[:]) - return res + # @return an integer + def minDepth(self, root): + if not root: + return 0 + return self.minDepth_rec(root) - # Note - # 1. Try to use double loop to do this - # 2. Other ways are: a. use dummy node(None) b. use two queues + def minDepth_rec(self, root): + if not root: + return 9223372036854775807 + if root.left is None and root.right is None: + return 1 + return min(self.minDepth_rec(root.left), self.minDepth_rec(root.right)) + 1 ``` ----- -### [13. Binary Tree Level Order Traversal II](https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/) +### [112. Path Sum](https://oj.leetcode.com/problems/path-sum/) -Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). +Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: -Given binary tree {3,9,20,#,#,15,7}, +Given the below binary tree and sum = 22, ``` - 3 - / \ - 9 20 - / \ - 15 7 + 5 + / \ + 4 8 + / / \ + 11 13 4 + / \ \ + 7 2 1 ``` -return its bottom-up level order traversal as: -[ - [15,7], - [9,20], - [3] -] +return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22. ```python @@ -554,47 +617,40 @@ return its bottom-up level order traversal as: class Solution: # @param root, a tree node - # @return a list of lists of integers - def levelOrderBottom(self, root): - res = [] + # @param sum, an integer + # @return a boolean + def hasPathSum(self, root, sum): if root is None: - return res - queue = [] - level = [] - queue.append(root) - queue.append(None) - while len(queue)>0: - node = queue.pop(0) - if node is None: - res.append(level[:]) - level = [] - if len(queue)>0: - queue.append(None) - else: - level.append(node.val) - if node.left is not None: - queue.append(node.left) - if node.right is not None: - queue.append(node.right) - return res[::-1] + return False + if root.left is None and root.right is None: # Found a leaf + if sum == root.val: + return True + return self.hasPathSum(root.left, sum-root.val) or self.hasPathSum(root.right, sum-root.val) + + # Need to note, a leaf is a node has no left chind and no right child ``` ----- -### [14. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) - -Given a binary tree, find the maximum path sum. +### [113. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) -The path may start and end at any node in the tree. +Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: -Given the below binary tree, - +Given the below binary tree and sum = 22, ``` - 1 - / \ - 2 3 + 5 + / \ + 4 8 + / / \ + 11 13 4 + / \ / \ + 7 2 5 1 ``` -Return 6. +return +[ + [5,4,11,2], + [5,8,4,5] +] ```python @@ -607,44 +663,83 @@ Return 6. class Solution: # @param root, a tree node - # @return an integer - def maxPathSum(self, root): - if root is None: - return 0 - self.max_sum = -9223372036854775808 - self.maxPathSum_helper(root, self.max_sum) - return self.max_sum + # @param sum, an integer + # @return a list of lists of integers + def pathSum(self, root, sum): + ret = [] + self.pathSum_helper(root, sum, [], ret) + return ret - def maxPathSum_helper(self, root, max_sum): + def pathSum_helper(self, root, sum, res, ret): if root is None: - return 0 + return + if root.left is None and root.right is None: + if sum == root.val: + res.append(root.val) + ret.append(res[:]) + res.pop() + return + res.append(root.val) + self.pathSum_helper(root.left, sum - root.val, res, ret) + self.pathSum_helper(root.right, sum - root.val, res, ret) + res.pop() - left = self.maxPathSum_helper(root.left, max_sum) - right = self.maxPathSum_helper(root.right, max_sum) - root_max = max(root.val, left + root.val, right + root.val) - self.max_sum = max(self.max_sum, root_max, left + right + root.val) +This way will have long run time + def pathSum(self, root, sum): + if root is None: + return [] + ret = [] + self.pathSum_helper(root, sum, [root.val], ret) + return ret + + def pathSum_helper(self, root, sum, res, ret): + if root.left is None and root.right is None: # Found a leaf + if sum == root.val: + ret.append(res[:]) + return + if root.left is not None: + res.append(root.left) + self.pathSum_helper(root.left, sum, res, ret) + res.pop() + if root.right is not None: + res.append(root.right) + self.pathSum_helper(root.right, sum, res, ret) + res.pop() - return root_max ``` ----- -### [15. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) +### [114. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) -Given a binary tree, return the postorder traversal of its nodes' values. +Given a binary tree, flatten it to a linked list in-place. + +For example, +Given -For example: -Given binary tree {1,#,2,3}, ``` + 1 + / \ + 2 5 + / \ \ + 3 4 6 +The flattened tree should look like: 1 \ 2 - / - 3 + \ + 3 + \ + 4 + \ + 5 + \ + 6 ``` -return [3,2,1]. +click to show hints. -Note: Recursive solution is trivial, could you do it iteratively? +Hints: +If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal. ```python @@ -657,74 +752,158 @@ Note: Recursive solution is trivial, could you do it iteratively? class Solution: # @param root, a tree node - # @return a list of integers - def postorderTraversal(self, root): - return self.postorderTraversal_1(root) + # @return nothing, do it in place + last_node = None + def flatten(self, root): + if not root: + return + if self.last_node: + self.last_node.left = None + self.last_node.right = root + self.last_node = root + right = root.right # Because root.right has changed + self.flatten(root.left) + self.flatten(right) + # The above way is preferred + # Notice line 48 need to store the state of right - # I prefer this way - def postorderTraversal_1(self, root): + def flatten(self, root): if root is None: - return [] - stack = [root] - output = [] - while len(stack)>0: - node = stack.pop() - output.append(node.val) - if node.left is not None: - stack.append(node.left) - if node.right is not None: - stack.append(node.right) - return output[::-1] + return None + self.flatten_helper(root) - # I don't like this way - def postorderTraversal_2(self, root): - stack = [] - current = root - res = [] - last = None - while current is not None or len(stack)>0: - if current is not None: - stack.append(current) - current = current.left - else: - peak = stack[-1] - if peak.right is not None and last != peak.right: - current = peak.right - else: - last = stack.pop() - res.append(last.val) - return res + def flatten_helper(self, root): + if root.left is None and root.right is None: + return root + rhead = None # This declare is nessary + if root.right is not None: + rhead = self.flatten_helper(root.right) + lend = root # Need this here + if root.left is not None: + lhead = self.flatten_helper(root.left) + root.right = lhead + lhead.left = None + root.left = None + while lend.right is not None: # Get the lend from root + lend = lend.right - def postorderTraversal_3(self, root): - res = [] - self.postorderTraversal_rec(root, res) - return res + if rhead is not None: + lend.right = rhead + return root - def postorderTraversal_rec(self, root, res): - if root is None: - return - self.postorderTraversal_rec(root.left, res) - self.postorderTraversal_rec(root.right, res) - res.append(root.val) + # Non-recursion way + def flatten(self, root): + while root: + if root.left: + pre = root.left + while pre.right: + pre = pre.right + pre.right = root.right + root.right = root.left + root.left = None + root = root.right + + # Another diao zha way + # This is the reverse way of above + last = None + def flatten(self, root): + if root != None: + self.flatten(root.right) + self.flatten(root.left) + root.right = self.last + root.left = None + self.last = root ``` ----- -### [16. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) +### [115. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) -Given a binary tree, return the preorder traversal of its nodes' values. +Given a string S and a string T, count the number of distinct subsequences of T in S. -For example: -Given binary tree {1,#,2,3}, -``` - 1 - \ - 2 - / - 3 +A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not). + +Here is an example: +S = "rabbbit", T = "rabbit" + +Return 3. + +Note: +The answer is three rabbit by removing the first, second, third 'b' + +```python + +class Solution: + # @return an integer + def numDistinct(self, S, T): + M = len(T) + N = len(S) + dp = [ [0 for j in range(N+1)] for i in range(M+1)] + for i in range(M+1): + dp[i][0] = 0 + for j in range(N+1): + dp[0][j] = 1 + for i in range(1, M+1): + for j in range(1, N+1): + if S[j-1] == T[i-1]: + dp[i][j] = dp[i][j-1] + dp[i-1][j-1] + else: + dp[i][j] = dp[i][j-1] + return dp[M][N] + # !!!!分清M,i和N,j分别对应T和S哪个 + # Note: + # dp[i][j]表示S的前i个字符配上T的前j个字符的DS + # [i][0] = 0, dp[0][j] = 1 + # dp[i][j] = dp[i][j-1] + dp[i-1][j-1] # if T[i-1] == S[j-1] + # = dp[i][j-1] # if T[i-1] != S[j-1] + # dp[M][N] + # Need to draw this pic when solving this problem + # 大概意思就是, 因为算的是S的子串和T匹配的方法, 所以一旦S[:j-1]和T[:i]有x种匹配方法时 + # S[:j]必定也至少和T[:i]有x种匹配方法,但尤其当S[j-1]==T[i-1]的时候,需要再加上S[:j-1]和T[:i-1]的匹配方法数 + # r a b b b i t + # 1 1 1 1 1 1 1 1 + # r 0 1 1 1 1 1 1 1 + # a 0 0 1 1 1 1 1 1 + # b 0 0 0 1 2 3 3 3 + # b 0 0 0 0 1 3 3 3 + # i 0 0 0 0 0 0 3 3 + # t 0 0 0 0 0 0 0 3 + # No matter T[i-1] ?= S[j-1], dp[i][j] = dp[i][j-1] + # But if T[i-1] == S[j-1], we can add another one which is dp[i-1][j-1] ``` -return [1,2,3]. +----- -Note: Recursive solution is trivial, could you do it iteratively? +### [116. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) + +Given a binary tree + + struct TreeLinkNode { + TreeLinkNode *left; + TreeLinkNode *right; + TreeLinkNode *next; + } +Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. + +Initially, all next pointers are set to NULL. + +Note: + +You may only use constant extra space. +You may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children). +For example, +Given the following perfect binary tree, +``` + 1 + / \ + 2 3 + / \ / \ + 4 5 6 7 +After calling your function, the tree should look like: + 1 -> NULL + / \ + 2 -> 3 -> NULL + / \ / \ + 4->5->6->7 -> NULL +``` ```python @@ -734,60 +913,49 @@ Note: Recursive solution is trivial, could you do it iteratively? # self.val = x # self.left = None # self.right = None +# self.next = None class Solution: # @param root, a tree node - # @return a list of integers - def preorderTraversal(self, root): - return self.preorderTraversal_1(root) - - def preorderTraversal_1(self, root): - stack = [] - current = root - res = [] - while current is not None or len(stack)>0: - if current is not None: - res.append(current.val) - stack.append(current) - current = current.left - elif len(stack)>0: - current = stack.pop() - current = current.right - return res - - def preorderTraversal_2(self, root): - res = [] - self.preorderTraversal_rec(root, res) - return res - - def preorderTraversal_rec(self, root, res): - if root is None: + # @return nothing + def connect(self, root): + if root is None or root.left is None: return - res.append(root.val) - self.preorderTraversal_rec(root.left, res) - self.preorderTraversal_rec(root.right, res) + root.left.next = root.right + if root.right is not None and root.next is not None: + root.right.next = root.next.left + self.connect(root.left) + self.connect(root.right) + + # Or maybe use a level order traversal + # Removed one line ``` ----- -### [17. Binary Tree Zigzag Level Order Traversal](https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) +### [117. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) -Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). +Follow up for problem "Populating Next Right Pointers in Each Node". -For example: -Given binary tree {3,9,20,#,#,15,7}, +What if the given tree could be any binary tree? Would your previous solution still work? + +Note: + +You may only use constant extra space. +For example, +Given the following binary tree, ``` - 3 - / \ - 9 20 - / \ - 15 7 + 1 + / \ + 2 3 + / \ \ + 4 5 7 +After calling your function, the tree should look like: + 1 -> NULL + / \ + 2 -> 3 -> NULL + / \ \ + 4-> 5 -> 7 -> NULL ``` -return its zigzag level order traversal as: -[ - [3], - [20,9], - [15,7] -] ```python @@ -797,402 +965,318 @@ return its zigzag level order traversal as: # self.val = x # self.left = None # self.right = None +# self.next = None class Solution: # @param root, a tree node - # @return a list of lists of integers - def zigzagLevelOrder(self, root): - ret = [] - if root is None: - return ret - queue = [root, None] - res = [] - zig = False # Because we start from very root, so no reverse at that point - while len(queue) > 0: - node = queue.pop(0) - if node is None: - if zig: - ret.append(res[::-1]) - else: - ret.append(res[:]) - res = [] - if len(queue) == 0: # Break here, otherwise will append another None - break - zig = not zig - queue.append(None) - else: - res.append(node.val) # Remember this, need to do this in node, not node.left/right - if node.left is not None: - queue.append(node.left) - if node.right is not None: - queue.append(node.right) - return ret -``` ------ + # @return nothing + def connect(self, root): + if not root or (not root.left and not root.right): + return + if root.left and root.right: + root.left.next = root.right -### [18. Candy](https://oj.leetcode.com/problems/candy/) + next_node = self.find_next(root.next) + if root.right: + root.right.next = next_node + else: + root.left.next = next_node -There are N children standing in a line. Each child is assigned a rating value. + self.connect(root.right) # Do right first then left + self.connect(root.left) -You are giving candies to these children subjected to the following requirements: + def find_next(self, root): + if not root: + return None + if not root.left and not root.right: + return self.find_next(root.next) + if root.left: + return root.left + else: + return root.right + # Notice: + # 1. Note that line 47 need to do right first then left + # 2. The reason that I doesn't need to process I first is it doesn't need to process + # nodes of root.next.next... +``` +----- -Each child must have at least one candy. -Children with a higher rating get more candies than their neighbors. -What is the minimum candies you must give? +### [118. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) -```python +Given numRows, generate the first numRows of Pascal's triangle. -class Solution: - # @param ratings, a list of integer - # @return an integer - def candy(self, ratings): - N = len(ratings) - candy = [1 for i in range(N)] - for i in range(1, N): - if ratings[i] > ratings[i-1]: - candy[i] = candy[i-1] + 1 - for i in range(N-1)[::-1]: - if ratings[i] > ratings[i+1] and candy[i] <= candy[i+1]: - candy[i] = candy[i+1] + 1 - return sum(candy) - - # Note: - # Need to be careful for line 21 the second and -``` ------ - -### [19. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) - -You are climbing a stair case. It takes n steps to reach to the top. +For example, given numRows = 5, +Return -Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? +[ + [1], + [1,1], + [1,2,1], + [1,3,3,1], + [1,4,6,4,1] +] ```python class Solution: - # @param n, an integer - # @return an integer - def climbStairs(self, n): - return self.climbStairs_2(n) - - def climbStairs_1(self, n): - if n <= 2: - return n - return self.climbStairs(n-1) + self.climbStairs(n-2) - - def climbStairs_2(self, n): - if n <= 1: - return n - dp = [ 0 for i in range(n)] - dp[0] = 1 - dp[1] = 2 - for i in range(2, n): - dp[i] = dp[i-1] + dp[i-2] - return dp[n-1] - - # Note: - # 1. dp[i] means from 0 to i-1 stair, how many ways to go - # 2. dp[0] = 1, dp[1] = 2 - # 3. dp[i] = d[i-1] + dp[i-2] - # 4. dp[N-1] + # @return a list of lists of integers + def generate(numRows): + return self.generate_1(numRows) - def climbStairs_3(self, n): - if n <= 2: - return n - fn_1 = 1 - fn_2 = 2 - for i in range(3, n+1): - fn = fn_1 + fn_2 - fn_1 = fn - fn_2 = fn_1 - return fn + def generate_1(self, numRows): + res = [] + for j in range(numRows): + current = [1] + for i in range(1, j): + current.append(res[-1][i]+res[-1][i-1]) + if j>=1: + current.append(1) + res.append(current[:]) + return res - # Note: - # DP way is the best, and no need to check if n <= 2 or not. + def generate_2(self, numRows): + if numRows ==0: + return [] + if numRows == 1: + return [[1]] + if numRows == 2: + return [[1],[1,1]] + res = [[1], [1,1]] + prev = [1,1] + for j in range(numRows-1): + current = [1] + for i in range(1,len(prev)): + current.append(prev[i]+prev[i-1]) + current.append(1) + res.append(current[:]) + prev = current + return res ``` ----- -### [20. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) - -Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. - - -OJ's undirected graph serialization: -Nodes are labeled uniquely. - -We use # as a separator for each node, and , as a separator for node label and each neighbor of the node. -As an example, consider the serialized graph {0,1,2#1,2#2,2}. +### [119. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) -The graph has a total of three nodes, and therefore contains three parts as separated by #. +Given an index k, return the kth row of the Pascal's triangle. -First node is labeled as 0. Connect node 0 to both nodes 1 and 2. -Second node is labeled as 1. Connect node 1 to node 2. -Third node is labeled as 2. Connect node 2 to node 2 (itself), thus forming a self-cycle. -Visually, the graph looks like the following: +For example, given k = 3, +Return [1,3,3,1]. -``` - 1 - / \ - / \ - 0 --- 2 - / \ - \_/ +Note: +Could you optimize your algorithm to use only O(k) extra space? -``` ```python -# Definition for a undirected graph node -# class UndirectedGraphNode: -# def __init__(self, x): -# self.label = x -# self.neighbors = [] - class Solution: - # @param node, a undirected graph node - # @return a undirected graph node - def cloneGraph(self, node): - if node is None: - return None - # Use oldNode as the oldGraph, newNode as the newGraph. Use tuple (oldNode, newNode) to store relation - newNodeHead = UndirectedGraphNode(node.label) - queue = collections.deque() - queue.append((node,newNodeHead)) - map_dict = {} - while len(queue) > 0: - (oldNode,newNode) = queue.popleft() - if oldNode in map_dict: - continue - map_dict[oldNode] = 'Visited' - newNode.neighbors = [] - for oldNeighbor in oldNode.neighbors: - newNeighbor = UndirectedGraphNode(oldNeighbor.label) - queue.append((oldNeighbor, newNeighbor)) - newNode.neighbors.append(newNeighbor) - return newNodeHead + # @return a list of integers + def getRow(self, rowIndex): + return self.getRow_2(rowIndex) - # Another way to this is like Nine Chapter, no need to do like level order BFS - # Finally add all neighbors + def getRow_1(self, rowIndex): + ret = [1] + if rowIndex == 0: + return ret + while rowIndex > 0: + if len(ret) > 1: + for i in range(1, len(ret)): + ret[i-1] = ret[i] + ret[i-1] + ret.insert(0, 1) + rowIndex -= 1 + return ret + + def getRow_2(self, rowIndex): + ret = [1 for i in range(rowIndex+1)] + for i in range(rowIndex+1): + for j in range(i-1, 0, -1): + ret[j] += ret[j-1] + return ret ``` ----- -### [21. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) - -Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. +### [11. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) -The same repeated number may be chosen from C unlimited number of times. +Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. -Note: -All numbers (including target) will be positive integers. -Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). -The solution set must not contain duplicate combinations. -For example, given candidate set 2,3,6,7 and target 7, -A solution set is: -[7] -[2, 2, 3] +Note: You may not slant the container. ```python class Solution: - # @param candidates, a list of integers - # @param target, integer - # @return a list of lists of integers - def combinationSum(self, candidates, target): - ret = [] - self.combinationSum_helper(sorted(candidates), target, [], ret) # Look into the question, need sorted - return ret - - def combinationSum_helper(self, candidates, target, res, ret): - if target == 0: - ret.append(res[:]) - return - for i, num in enumerate(candidates): - if target - num < 0: - continue - res.append(num) - self.combinationSum_helper(candidates[i:], target - num, res, ret) - res.pop() + # @return an integer + def maxArea(self, height): + l = 0 + r = len(height) - 1 + max_water = 0 + while l < r: + max_water = max(max_water, (r-l) * min(height[l], height[r])) + if height[l] <= height[r]: + l += 1 + else: + r -= 1 + return max_water - # Continue when target < num + # Two pointer problem ``` ----- -### [22. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) +### [120. Triangle](https://oj.leetcode.com/problems/triangle/) -Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. +Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. -Each number in C may only be used once in the combination. +For example, given the following triangle +[ + [2], + [3,4], + [6,5,7], + [4,1,8,3] +] +The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: -All numbers (including target) will be positive integers. -Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). -The solution set must not contain duplicate combinations. -For example, given candidate set 10,1,2,7,6,1,5 and target 8, -A solution set is: -[1, 7] -[1, 2, 5] -[2, 6] -[1, 1, 6] +Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle. ```python class Solution: - # @param candidates, a list of integers - # @param target, integer - # @return a list of lists of integers - def combinationSum2(self, candidates, target): - ret = [] - self.combinationSum_helper(sorted(candidates), target, [], ret) # Look into the question, need sorted - return ret - - def combinationSum_helper(self, candidates, target, res, ret): - if target == 0: - ret.append(res[:]) - return - for i, num in enumerate(candidates): - if target < num or (i > 0 and candidates[i] == candidates[i-1]): - continue - res.append(num) - self.combinationSum_helper(candidates[i+1:], target - num, res, ret) - res.pop() + # @param triangle, a list of lists of integers + # @return an integer + def minimumTotal(self, triangle): + M = len(triangle) + N = len(triangle[-1]) + dp = [ [ 0 for j in range(N)] for i in range(M)] + for i in range(M)[::-1]: + for j in range(len(triangle[i])): + if i == M-1: + dp[i][j] = triangle[i][j] + else: + dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j] + return dp[0][0] + # Notes: + # This is not the best solution. But easier to understand + # 1. status: ```dp[x][y]```表示从bottom走到top每个坐标的最短路径 + # 2. function: dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j] + # 3. initialize: dp[-1][j] = triangle[-1][j] + # 4. answer: dp[0][0] - # Note some diffs with I: - # 1. line 32 check dup - # 2. line 35 [i+1:] + #This is older way, but still pretty good + def minimumTotal_2(self, triangle): + n = len(triangle) - 1 + dp = triangle[n] + n -= 1 + while n >= 0: + for i in range(n+1): + dp[i] = triangle[n][i] + min(dp[i], dp[i+1]) + n -= 1 + return dp[0] + + # This look too simple + # Understand of this: + # 1. From bottom to top + # 2. transfer func: dp[i] = triangle[n][i] + min(dp[i], dp[i+1]) + # top level dp[i] = current triangle value + min(bottom level reachable dps) ``` ----- -### [23. Combinations](https://oj.leetcode.com/problems/combinations/) - -Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. +### [121. Best Time to Buy and Sell Stock](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/) -For example, -If n = 4 and k = 2, a solution is: +Say you have an array for which the ith element is the price of a given stock on day i. -[ - [2,4], - [3,4], - [2,3], - [1,2], - [1,3], - [1,4], -] +If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit. ```python class Solution: - # @return a list of lists of integers - def combine(self, n, k): - ret =[] - self.combine_helper(1, n, k, [], ret) - return ret - - def combine_helper(self, cur, n, k, res, ret): - if len(res) == k: - ret.append(res[:]) - return - for i in range(cur, n+1): - res.append(i) - self.combine_helper(i+1, n, k, res, ret) - res.pop() - # Need to notice the i+1 + # @param prices, a list of integer + # @return an integer + def maxProfit(self, prices): + if len(prices) == 0: + return 0 + max_profit = 0 + low_price = prices[0] + for price in prices: + max_profit = max(max_profit, price - low_price) + low_price = min(low_price, price) + return max_profit ``` ----- -### [24. Construct Binary Tree from Inorder and Postorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/) +### [122. Best Time to Buy and Sell Stock II](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) -Given inorder and postorder traversal of a tree, construct the binary tree. +Say you have an array for which the ith element is the price of a given stock on day i. -Note: -You may assume that duplicates do not exist in the tree. +Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - class Solution: - # @param inorder, a list of integers - # @param postorder, a list of integers - # @return a tree node - def buildTree(self, inorder, postorder): - if len(inorder) == 0: - return None - root = TreeNode(postorder.pop()) - index = inorder.index(root.val) - root.right = self.buildTree(inorder[index+1:], postorder) - root.left = self.buildTree(inorder[:index], postorder) - return root - # Only difference if pop(0) or pop() - # In this case need to do right first + # @param prices, a list of integer + # @return an integer + def maxProfit(self, prices): + if len(prices) <= 1: + return 0 + max_profit = 0 + for i in range(1, len(prices)): + if prices[i] - prices[i-1] > 0: + max_profit += prices[i] - prices[i-1] + return max_profit ``` ----- -### [25. Construct Binary Tree from Preorder and Inorder Traversal](https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) +### [123. Best Time to Buy and Sell Stock III](https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) -Given preorder and inorder traversal of a tree, construct the binary tree. +Say you have an array for which the ith element is the price of a given stock on day i. + +Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: -You may assume that duplicates do not exist in the tree. +You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again). ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - class Solution: - # @param preorder, a list of integers - # @param inorder, a list of integers - # @return a tree node - def buildTree(self, preorder, inorder): - if len(inorder) == 0: - return None - root = TreeNode(preorder.pop(0)) - index = inorder.index(root.val) - root.left = self.buildTree(preorder, inorder[:index]) - root.right = self.buildTree(preorder, inorder[index+1:]) - return root - # for line 24/25, it's using preorder instead of slicing it. Because when left tree is ready - # all the preorder index are already poped + # @param prices, a list of integer + # @return an integer + def maxProfit(self, prices): + N = len(prices) + if N <= 1: + return 0 + dp_1 = [0 for i in range(N)] + dp_2 = [0 for i in range(N)] + min_price = prices[0] + i = 1 + while i < N: + min_price = min(min_price, prices[i]) + dp_1[i] = max(dp_1[i-1], prices[i]-min_price) + i+= 1 + + max_price = prices[-1] + i = N-2 + while i >= 0: + max_price = max(max_price, prices[i]) + dp_2[i] = max(dp_2[i+1], max_price-prices[i]) + i -= 1 + res = 0 + for i in range(N): + res = max(res, dp_1[i] + dp_2[i]) + return res + # Very similart to trapping rain water, from left to right then right to left ``` ----- -### [26. Container With Most Water](https://oj.leetcode.com/problems/container-with-most-water/) +### [124. Binary Tree Maximum Path Sum](https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/) -Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. - -Note: You may not slant the container. +Given a binary tree, find the maximum path sum. -```python +The path may start and end at any node in the tree. -class Solution: - # @return an integer - def maxArea(self, height): - l = 0 - r = len(height) - 1 - max_water = 0 - while l < r: - max_water = max(max_water, (r-l) * min(height[l], height[r])) - if height[l] <= height[r]: - l += 1 - else: - r -= 1 - return max_water +For example: +Given the below binary tree, - # Two pointer problem ``` ------ - -### [27. Convert Sorted Array to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) - -Given an array where elements are sorted in ascending order, convert it to a height balanced BST. + 1 + / \ + 2 3 +``` +Return 6. ```python @@ -1204,559 +1288,582 @@ Given an array where elements are sorted in ascending order, convert it to a hei # self.right = None class Solution: - # @param num, a list of integers - # @return a tree node - def sortedArrayToBST(self, num): - if len(num) == 0: - return None - return self.sortedArrayToBSTRec(num, 0, len(num)-1) + # @param root, a tree node + # @return an integer + def maxPathSum(self, root): + if root is None: + return 0 + self.max_sum = -9223372036854775808 + self.maxPathSum_helper(root, self.max_sum) + return self.max_sum - def sortedArrayToBSTRec(self, num, start, end): - if start > end: - return None - mid = (start + end) / 2 - node = TreeNode(num[mid]) - node.left = self.sortedArrayToBstRec(num, start, mid-1) - node.right = self.sortedArrayToBstRec(num, mid+1, end) - return node + def maxPathSum_helper(self, root, max_sum): + if root is None: + return 0 + + left = self.maxPathSum_helper(root.left, max_sum) + right = self.maxPathSum_helper(root.right, max_sum) + + root_max = max(root.val, left + root.val, right + root.val) + self.max_sum = max(self.max_sum, root_max, left + right + root.val) + + return root_max ``` ----- -### [28. Convert Sorted List to Binary Search Tree](https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) +### [125. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) -Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. +Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. -```python +For example, +"A man, a plan, a canal: Panama" is a palindrome. +"race a car" is not a palindrome. -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None -# -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None +Note: +Have you consider that the string might be empty? This is a good question to ask during an interview. + +For the purpose of this problem, we define empty string as valid palindrome. + +```python class Solution: - # @param head, a list node - # @return a tree node - def sortedListToBST(self, head): - cur = head - length = 0 - while cur: - cur = cur.next - length += 1 - self.head = head - return self.sortedRecur(0, length - 1) + # @param s, a string + # @return a boolean + def isPalindrome(self, s): + start = 0 + end = len(s) - 1 + while start < end: + while start < end and not s[start].isalnum(): + start += 1 + while start < end and not s[end].isalnum(): + end -= 1 + if s[start].lower() != s[end].lower(): + return False + start += 1 + end -= 1 + return True + # 1. isalnum() + # 2. lower() + # 3. no need to check len at the begining +``` +----- - def sortedRecur(self, start, end): - if start > end: - return None +### [126. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) - mid = (start + end) / 2 - left = self.sortedRecur(start, mid - 1) - root = TreeNode(self.head.val) - root.left = left - self.head = self.head.next - root.right = self.sortedRecur(mid + 1, end) +Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: - return root +Only one letter can be changed at a time +Each intermediate word must exist in the dictionary +For example, - # This is creating the tree from leaves to root - # Normal way(Get middle and create each half) takes O(n*logn) - # This way takes O(n) +Given: +start = "hit" +end = "cog" +dict = ["hot","dot","dog","lot","log"] +Return + [ + ["hit","hot","dot","dog","cog"], + ["hit","hot","lot","log","cog"] + ] +Note: +All words have the same length. +All words contain only lowercase alphabetic characters. + +```python + +class Solution: + # @param start, a string + # @param end, a string + # @param dict, a set of string + # @return a list of lists of string + def findLadders(self, start, end, dict): + trace_back = { word: [] for word in dict} + prev_level = set([start]) + found = False + while len(prev_level) > 0 and not found: + cur_level = set([]) + size = len(prev_level) + for word in prev_level: + dict.remove(word) + for word in prev_level: + if word == end: + found = True + for i in range(len(word)): + for char in 'abcdefghijklmnopqrstuvwxyz': + new_word = word[:i] + char + word[i+1:] + if new_word in dict: + trace_back[new_word].append(word) + cur_level.add(new_word) + prev_level = cur_level + paths = [] + if found: + self.find_traceback(end, trace_back, [], paths) + return paths + + def find_traceback(self, word, trace, cur_path, paths): + if len(trace[word]) == 0: + paths.append([word] + cur_path) + return + for prev_word in trace[word]: + self.find_traceback(prev_word, trace, [word] + cur_path, paths) + + # Note: + # 1. while loop is doing a BFS + # 2. find_traceback is doing a DFS from the end traceback to start ``` ----- -### [29. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) +### [127. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) -A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. +Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: -Return a deep copy of the list. +Only one letter can be changed at a time +Each intermediate word must exist in the dictionary +For example, -```python +Given: +start = "hit" +end = "cog" +dict = ["hot","dot","dog","lot","log"] +As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", +return its length 5. -# Definition for singly-linked list with a random pointer. -# class RandomListNode: -# def __init__(self, x): -# self.label = x -# self.next = None -# self.random = None +Note: +Return 0 if there is no such transformation sequence. +All words have the same length. +All words contain only lowercase alphabetic characters. +```python class Solution: - # @param head, a RandomListNode - # @return a RandomListNode - def copyRandomList(self, head): - if head is None: - return None - cur = head - while cur is not None: - newNode = RandomListNode(cur.label) - newNode.next = cur.next - cur.next = newNode - cur = newNode.next - cur = head - while cur is not None: - newNode = cur.next - if cur.random is not None: # random pointer may not exist - newNode.random = cur.random.next - cur = newNode.next - cur = head - newNodehead = head.next - while cur is not None: - newNode = cur.next - cur.next = newNode.next - if newNode.next is not None: - newNode.next = newNode.next.next - cur = cur.next - return newNodehead + # @param start, a string + # @param end, a string + # @param dict, a set of string + # @return an integer + def ladderLength(self, start, end, dict): + queue = collections.deque([start]) + N = len(start) + length = 1 + while len(queue) > 0: + size = len(queue) + for i in range(size): + word = queue.popleft() + if word == end: + return length + for i in range(N): + for char in 'abcdefghijklmnopqrstuvwxyz': + new_word = word[:i] + char + word[i+1:] + if new_word in dict: + queue.append(new_word) + dict.remove(new_word) + length += 1 + return 0 ``` ----- -### [30. Count and Say](https://oj.leetcode.com/problems/count-and-say/) +### [128. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) -The count-and-say sequence is the sequence of integers beginning as follows: -1, 11, 21, 1211, 111221, ... +Given an unsorted array of integers, find the length of the longest consecutive elements sequence. -1 is read off as "one 1" or 11. -11 is read off as "two 1s" or 21. -21 is read off as "one 2, then one 1" or 1211. -Given an integer n, generate the nth sequence. +For example, +Given [100, 4, 200, 1, 3, 2], +The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. -Note: The sequence of integers will be represented as a string. +Your algorithm should run in O(n) complexity. ```python class Solution: - # @return a string - def countAndSay(self, n): - prev = '1' - for i in range(1, n): - counter = 1 - cur = [prev[0]] - for char in prev[1:]: - if char == cur[-1]: - counter += 1 - else: - cur.insert(-1, str(counter)) - cur.append(char) - counter = 1 - cur.insert(-1, str(counter)) - prev = ''.join(cur) - return prev + # @param num, a list of integer + # @return an integer + def longestConsecutive(self, num): + num_dict = {} + for i in num: + if i not in num_dict: + num_dict[i] = True + ret = 1 + for i in num: + if i not in num_dict: + continue + length = 1 + j = i + while j + 1 in num_dict: + length += 1 + num_dict.pop(j+1, None) + j += 1 + j = i + while j - 1 in num_dict: + length += 1 + num_dict.pop(j-1, None) + j -= 1 + ret = max(ret, length) + num_dict.pop(i, None) + return ret + # Other methods are not O(n) solution ``` ----- -### [31. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) +### [129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) -A message containing letters from A-Z is being encoded to numbers using the following mapping: +Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. -'A' -> 1 -'B' -> 2 -... -'Z' -> 26 -Given an encoded message containing digits, determine the total number of ways to decode it. +An example is the root-to-leaf path 1->2->3 which represents the number 123. + +Find the total sum of all root-to-leaf numbers. For example, -Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12). -The number of ways decoding "12" is 2. +``` + 1 + / \ + 2 3 +``` +The root-to-leaf path 1->2 represents the number 12. +The root-to-leaf path 1->3 represents the number 13. + +Return the sum = 12 + 13 = 25. ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param s, a string + # @param root, a tree node # @return an integer - def numDecodings(self, s): - N = len(s) - if N == 0 or s[0] == '0': + def sumNumbers(self, root): + return self.sumNumbers_2(root) + + def sumNumbers_1(self, root): + if root is None: return 0 - dp = [0 for i in range(N+1)] - dp[0] = 1 - dp[1] = 1 - for i in range(2, N+1): - if s[i-1] == '0' and s[i-2] not in ['1', '2']: - return 0 - if s[i-1] != '0': - dp[i] += dp[i-1] - if 10 <= int(s[i-2: i]) <= 26: - dp[i] += dp[i-2] - return dp[N] + ret = [0] + self.sumNumbers_helper(root, 0, ret) + return ret[0] - # Note: - # 1. State: dp[i] means from char 0 to char i-1 how many decode ways - # 2. Init: dp[0] = 1; dp[1] = 1 - # 3. Function: - # dp[i] = if s[i-1] == 0 and s[i-2] not in ['1', '2'] : return 0 - # if s[i-1] != 0 : += dp[i-1] - # if 10 <= int(s[i-2:i]) <= 26 : += dp[i-2] - # 4. Result: dp[N] + def sumNumbers_helper(self, root, res, ret): + res = res * 10 + root.val + if root.left is None and root.right is None: # Found a leaf node + ret[0] += res + return + if root.left is not None: + self.sumNumbers_helper(root.left, res, ret) + if root.right is not None: + self.sumNumbers_helper(root.right, res, ret) - # i. dp size is len(s)+1 - # ii. 10 <= x <= 26 - # iii. use if += instead of if dp = xx else dp = xx + # Miracle to do this in one submit + # Now think about a way to do this without using list[0] - # Another idea - def numDecodings_2(self, s): - if s == '' or s[0] == '0': return 0 - dp = [1, 1] - length = len(s) - for i in xrange(2, length + 1): - if 10 <= int(s[i-2:i]) <= 26 and '1' <= s[i-1] <= '9': - dp.append(dp[i-1] + dp[i-2]) - elif 10 <= int(s[i-2:i]) <= 26: # s[i-1] == '0' - dp.append(dp[i-2]) - elif '1' <= s[i-1] <= '9': - dp.append(dp[i-1]) - else: # s[i] == '0' - return 0 - return dp[length] + # Second way but this will reduce the check of root.left is None or root.right is None + def sumNumbers_2(self, root): + ret = [0] + self.sumNumbers_2_helper(root, 0, ret) + return ret[0] + + def sumNumbers_2_helper(self, root, res, ret): + if root is None: + return + res = root.val + res * 10 + if root.left is None and root.right is None: + ret[0] += res + return + self.sumNumbers_2_helper(root.left, res, ret) + self.sumNumbers_2_helper(root.right, res, ret) ``` ----- -### [32. Distinct Subsequences](https://oj.leetcode.com/problems/distinct-subsequences/) - -Given a string S and a string T, count the number of distinct subsequences of T in S. - -A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not). - -Here is an example: -S = "rabbbit", T = "rabbit" +### [12. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) -Return 3. +Given an integer, convert it to a roman numeral. -Note: -The answer is three rabbit by removing the first, second, third 'b' +Input is guaranteed to be within the range from 1 to 3999. ```python class Solution: - # @return an integer - def numDistinct(self, S, T): - M = len(T) - N = len(S) - dp = [ [0 for j in range(N+1)] for i in range(M+1)] - for i in range(M+1): - dp[i][0] = 0 - for j in range(N+1): - dp[0][j] = 1 - for i in range(1, M+1): - for j in range(1, N+1): - if S[j-1] == T[i-1]: - dp[i][j] = dp[i][j-1] + dp[i-1][j-1] - else: - dp[i][j] = dp[i][j-1] - return dp[M][N] - # !!!!分清M,i和N,j分别对应T和S哪个 - # Note: - # dp[i][j]表示S的前i个字符配上T的前j个字符的DS - # [i][0] = 0, dp[0][j] = 1 - # dp[i][j] = dp[i][j-1] + dp[i-1][j-1] # if T[i-1] == S[j-1] - # = dp[i][j-1] # if T[i-1] != S[j-1] - # dp[M][N] - # Need to draw this pic when solving this problem - # 大概意思就是, 因为算的是S的子串和T匹配的方法, 所以一旦S[:j-1]和T[:i]有x种匹配方法时 - # S[:j]必定也至少和T[:i]有x种匹配方法,但尤其当S[j-1]==T[i-1]的时候,需要再加上S[:j-1]和T[:i-1]的匹配方法数 - # r a b b b i t - # 1 1 1 1 1 1 1 1 - # r 0 1 1 1 1 1 1 1 - # a 0 0 1 1 1 1 1 1 - # b 0 0 0 1 2 3 3 3 - # b 0 0 0 0 1 3 3 3 - # i 0 0 0 0 0 0 3 3 - # t 0 0 0 0 0 0 0 3 - # No matter T[i-1] ?= S[j-1], dp[i][j] = dp[i][j-1] - # But if T[i-1] == S[j-1], we can add another one which is dp[i-1][j-1] + # @return a string + def intToRoman(self, num): + digits = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD' ), + (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), + (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')] + result = "" + for digit in digits: + while num >= digit[0]: + result += digit[1] + num -= digit[0] + if num == 0: + break + return result ``` ----- -### [33. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) +### [130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) -Divide two integers without using multiplication, division and mod operator. +Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. + +A region is captured by flipping all 'O's into 'X's in that surrounded region. + +For example, +``` +X X X X +X O O X +X X O X +X O X X +``` +After running your function, the board should be: +``` +X X X X +X X X X +X X X X +X O X X +``` ```python class Solution: - # @return an integer - def divide(self, dividend, divisor): - if (dividend < 0) != (divisor < 0): - sign = -1 - else: - sign = 1 + # @param board, a 2D array + # Capture all regions by modifying the input board in-place. + # Do not return any value. + def solve(self, board): + if len(board) == 0 or len(board[0]) == 0: # This is sooooo keng + return board + M = len(board) + N = len(board[0]) + for i in range(M): + for j in range(N): + if i == 0 or i == M-1 or j == 0 or j == N-1: + self.bfs(board, i, j) + for i in range(M): + for j in range(N): + if board[i][j] == 'V': + board[i][j] = 'O' + elif board[i][j] == 'O': + board[i][j] = 'X' - dividend = abs(dividend) - divisor = abs(divisor) - res = 0 - while dividend >= divisor: - shift = 0 - while dividend >= divisor << shift: - shift += 1 - #print 'res = %d, shift = %d, adding = %d, dividend = %d' % (res, shift, 1<<(shift-1), dividend) - res += 1 << (shift - 1) # This is shift-1, because the top loop quit - dividend -= divisor << (shift - 1) # when dividend < divisor << shift, so we don't want to shift more - return res * sign + def bfs(self, board, row, col): + if (board[row][col] != 'O'): + return + q = [] + q.append((row, col)) + while len(q) > 0: + i, j = q.pop(0) + if i < 0 or i >= len(board) or j < 0 or j >= len(board[0]): + continue + if board[i][j] != 'O': + continue + board[i][j] = 'V' + q.append((i-1, j)) + q.append((i+1, j)) + q.append((i, j-1)) + q.append((i, j+1)) - # How to think: - # Any number can be computed in binary way, like 8 = 2^3 * 1 + 2^2 * 0 + 2^1 * 0 + 2^0 * 0 - # In this case, we calculate this num = a * (2^n * an + ... + 2^1 * a1 + 2^0 * a0) - # So we calculate an first, them decrease num with a * 2^an, and sum(2^i * ai) + # DFS will cause stack overflow + def dfs(self, board, row, col): + if row < 0 or row >= len(board) or col < 0 or col >= len(board[0]): + return + if board[row][col] != 'O': + return + board[row][col] = 'V' + self.dfs(board, row+1, col) + self.dfs(board, row-1, col) + self.dfs(board, row, col+1) + self.dfs(board, row, col-1) + + # Note: + # 1. For matrix/board problems, need to check if matrix/board == [], otherwise len(matrix[0]) will fail + # 2. DFS may cause stack overflow ``` ----- -### [34. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) +### [131. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) -Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) +Given a string s, partition s such that every substring of the partition is a palindrome. -You have the following 3 operations permitted on a word: +Return all possible palindrome partitioning of s. -a) Insert a character -b) Delete a character -c) Replace a character +For example, given s = "aab", +Return +``` + [ + ["aa","b"], + ["a","a","b"] + ] +``` ```python class Solution: - # @return an integer - def minDistance(self, word1, word2): - M = len(word1) - N = len(word2) - dp = [ [ 0 for j in range(N+1)] for i in range(M+1)] - for i in range(M+1): - for j in range(N+1): - if i == 0: - dp[0][j] = j - elif j == 0: - dp[i][0] = i - elif word1[i-1] == word2[j-1]: - dp[i][j] = dp[i-1][j-1] - else: - dp[i][j] = min( dp[i][j-1], dp[i-1][j], dp[i-1][j-1]) + 1 - return dp[M][N] - # Note: - # 1. dp[i][j] is Edit Distance of first i-1 chars in word1 with first j-1 chars in word2 - # 2. dp[0][j] = j, dp[i][0] = i - # 3. dp[i][j] = dp[i-1][j-1] # if word[i-1] == word[j-1] - # = min( dp[i][j-1], dp[i-1][j], dp[i-1][j-1]) + 1 # if word[i-1] != word[j-1] + # @param s, a string + # @return a list of lists of string + def partition(self, s): + ret = [] + self.partition_helper(s, [], ret) + return ret - # Note: - # 1. This dp is a bit diff, the length of dp is A+1, B+1 - # 2. Others are the same, remember how to initiate the dp matrix - # 3. When comparing the i, it compares with word[i-1] and word[j-1] - # This is not hard to think, since we start loop from 1 - # 4. Initial value of DP: add N chars for word1 + def partition_helper(self, s, res, ret): + N = len(s) + if N == 0 : + ret.append(res[:]) + return + for i in range(1, N+1): # This N+1 is important + if self.is_palindrome(s[:i]): + res.append(s[:i]) + self.partition_helper(s[i:], res, ret) + res.pop() - # Transfer function: - # Target somestr1c -> somestr2d - # 1. Assume somestr1 -> somestr2 dp[i][j] - # 2. somestr1 -> somestr2d dp[i-1][j] - # 3. somestr1c -> somestr2 dp[i][j-1] - # 4. i. replace c with d: somestr1 -> somestr2 + 1 : dp[i-1][j-1] + 1 - # ii. append d to c : somestr1c -> somestr2 + 1 : dp[i][j-1] + 1 - # iii. delete c : somestr1 -> somestr2d + 1 : dp[i-1][j] + 1 + def is_palindrome(self, s): + l = 0 + r = len(s) - 1 + while l < r: + if s[l] != s[r]: + return False + l += 1 + r -= 1 + return True + # This function can use return s == s[::-1] to replace. ``` ----- -### [35. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) +### [132. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) -Evaluate the value of an arithmetic expression in Reverse Polish Notation. +Given a string s, partition s such that every substring of the partition is a palindrome. -Valid operators are +, -, *, /. Each operand may be an integer or another expression. +Return the minimum cuts needed for a palindrome partitioning of s. -Some examples: - ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 - ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6 +For example, given s = "aab", +Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut. ```python - +import sys class Solution: - # @param tokens, a list of string + # @param s, a string # @return an integer - def evalRPN(self, tokens): - stack = [] - for token in tokens: - if token in ['+', '-', '*', '/']: - b = stack.pop() - a = stack.pop() - stack.append(self.calculate(a, b, token)) - else: - stack.append(int(token)) - return stack.pop() + def minCut(self, s): + is_palin = self.get_is_palindrome(s) + N = len(s) + dp = [ N-1 for i in range(N+1)] + dp[0] = 0 + for i in range(1, N+1): + dp[i] = 9223372036854775807 + for j in range(i)[::-1]: + if is_palin[j][i-1]: + dp[i] = min(dp[i], dp[j]+1) + return dp[N] - 1 - def calculate(self, num_1, num_2, operator): - oper_dict = { '+' : lambda x, y: x + y, - '-' : lambda x, y: x - y, - '*' : lambda x, y: x * y, - '/' : lambda x, y: int( x * 1.0 / y), - } - return oper_dict[operator](num_1, num_2) + def get_is_palindrome(self, s): + N = len(s) + is_palin = [ [ False for j in range(N)] for i in range(N) ] + for i in range(N): + is_palin[i][i] = True - # Notice: - # Need to be very careful about line 29, need to convert float and result is in int + for i in range(N-1): + is_palin[i][i+1] = s[i] == s[i+1] + + length = 2 + while length < N: + start = 0 + while start + length < N: + is_palin[start][start+length] = is_palin[start+1][start+length-1] and s[start] == s[start+length] + start += 1 + length += 1 + return is_palin + + + This func is no longer used + def is_palin(s): + return s == s[::-1] + + # 1. dp means from 0 ... i the min cut times of palin + # 2. dp[0] = 0 + # 3. dp[i] = min(dp[i], dp[j]+1) for j = i-1 ... 0 if isPalin(s[j:i]) + # 4. dp[N] - 1 + + # get_is_palindrome is used to reduce the cost for line 21 + # it's returning dp[N] - 1, very tricky + # Beacause in definition, we define as min cut times of palin + # But actually, we just want the min cut + # abbacdc + # dp[3] = 0 but actually dp[3] = 1. So dp[N] = 1 + 1 = 2 but should be 1 + # We need to reduce a delete here ``` ----- -### [36. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) +### [133. Clone Graph](https://oj.leetcode.com/problems/clone-graph/) -Given an unsorted integer array, find the first missing positive integer. +Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. -For example, -Given [1,2,0] return 3, -and [3,4,-1,1] return 2. -Your algorithm should run in O(n) time and uses constant space. +OJ's undirected graph serialization: +Nodes are labeled uniquely. -```python +We use # as a separator for each node, and , as a separator for node label and each neighbor of the node. +As an example, consider the serialized graph {0,1,2#1,2#2,2}. -class Solution: - # @param A, a list of integers - # @return an integer - def firstMissingPositive(self, A): - N = len(A) - i = 0 - while i < N: - if A[i] <= 0 or A[i] == i + 1 or A[i] > N: - i += 1 - else: - x = A[i] - if A[i] == A[x-1]: - i += 1 - continue - A[i], A[x-1] = A[x-1], A[i] +The graph has a total of three nodes, and therefore contains three parts as separated by #. - for i in range(N): - if A[i] != i + 1: - return i + 1 +First node is labeled as 0. Connect node 0 to both nodes 1 and 2. +Second node is labeled as 1. Connect node 1 to node 2. +Third node is labeled as 2. Connect node 2 to node 2 (itself), thus forming a self-cycle. +Visually, the graph looks like the following: - return N + 1 +``` + 1 + / \ + / \ + 0 --- 2 + / \ + \_/ - # Note details - # 1. Good way to do this is name A[i] = x - # 2. line 22 need to check if it's already equal, like [1,1] will cause dead loop - # 3. line 29, return i+1 not A[i] - # 4. line 31 return N + 1 +``` +```python + +# Definition for a undirected graph node +# class UndirectedGraphNode: +# def __init__(self, x): +# self.label = x +# self.neighbors = [] + +class Solution: + # @param node, a undirected graph node + # @return a undirected graph node + def cloneGraph(self, node): + if node is None: + return None + # Use oldNode as the oldGraph, newNode as the newGraph. Use tuple (oldNode, newNode) to store relation + newNodeHead = UndirectedGraphNode(node.label) + queue = collections.deque() + queue.append((node,newNodeHead)) + map_dict = {} + while len(queue) > 0: + (oldNode,newNode) = queue.popleft() + if oldNode in map_dict: + continue + map_dict[oldNode] = 'Visited' + newNode.neighbors = [] + for oldNeighbor in oldNode.neighbors: + newNeighbor = UndirectedGraphNode(oldNeighbor.label) + queue.append((oldNeighbor, newNeighbor)) + newNode.neighbors.append(newNeighbor) + return newNodeHead + + # Another way to this is like Nine Chapter, no need to do like level order BFS + # Finally add all neighbors ``` ----- -### [37. Flatten Binary Tree to Linked List](https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/) +### [134. Gas Station](https://oj.leetcode.com/problems/gas-station/) -Given a binary tree, flatten it to a linked list in-place. +There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. -For example, -Given +You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. -``` - 1 - / \ - 2 5 - / \ \ - 3 4 6 -The flattened tree should look like: - 1 - \ - 2 - \ - 3 - \ - 4 - \ - 5 - \ - 6 -``` -click to show hints. +Return the starting gas station's index if you can travel around the circuit once, otherwise return -1. -Hints: -If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal. - -```python - -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - -class Solution: - # @param root, a tree node - # @return nothing, do it in place - last_node = None - def flatten(self, root): - if not root: - return - if self.last_node: - self.last_node.left = None - self.last_node.right = root - self.last_node = root - right = root.right # Because root.right has changed - self.flatten(root.left) - self.flatten(right) - # The above way is preferred - # Notice line 48 need to store the state of right - - def flatten(self, root): - if root is None: - return None - self.flatten_helper(root) - - def flatten_helper(self, root): - if root.left is None and root.right is None: - return root - rhead = None # This declare is nessary - if root.right is not None: - rhead = self.flatten_helper(root.right) - lend = root # Need this here - if root.left is not None: - lhead = self.flatten_helper(root.left) - root.right = lhead - lhead.left = None - root.left = None - while lend.right is not None: # Get the lend from root - lend = lend.right - - if rhead is not None: - lend.right = rhead - return root - - # Non-recursion way - def flatten(self, root): - while root: - if root.left: - pre = root.left - while pre.right: - pre = pre.right - pre.right = root.right - root.right = root.left - root.left = None - root = root.right - - # Another diao zha way - # This is the reverse way of above - last = None - def flatten(self, root): - if root != None: - self.flatten(root.right) - self.flatten(root.left) - root.right = self.last - root.left = None - self.last = root -``` ------ - -### [38. Gas Station](https://oj.leetcode.com/problems/gas-station/) - -There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. - -You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. - -Return the starting gas station's index if you can travel around the circuit once, otherwise return -1. - -Note: -The solution is guaranteed to be unique. +Note: +The solution is guaranteed to be unique. ```python @@ -1784,736 +1891,800 @@ class Solution: ``` ----- -### [39. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) +### [135. Candy](https://oj.leetcode.com/problems/candy/) -Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. +There are N children standing in a line. Each child is assigned a rating value. -For example, given n = 3, a solution set is: +You are giving candies to these children subjected to the following requirements: -"((()))", "(()())", "(())()", "()(())", "()()()" +Each child must have at least one candy. +Children with a higher rating get more candies than their neighbors. +What is the minimum candies you must give? ```python class Solution: - # @param an integer - # @return a list of string - def generateParenthesis(self, n): - ret = [] - self.generateParenthesis_helper(n, n, '', ret) - return ret + # @param ratings, a list of integer + # @return an integer + def candy(self, ratings): + N = len(ratings) + candy = [1 for i in range(N)] + for i in range(1, N): + if ratings[i] > ratings[i-1]: + candy[i] = candy[i-1] + 1 + for i in range(N-1)[::-1]: + if ratings[i] > ratings[i+1] and candy[i] <= candy[i+1]: + candy[i] = candy[i+1] + 1 + return sum(candy) - def generateParenthesis_helper(self, left, right, res, ret): - if left == 0 and right ==0: - ret.append(res[:]) - return - if left > 0: - self.generateParenthesis_helper(left-1, right, res+'(', ret) - if right > left: - self.generateParenthesis_helper(left, right-1, res+')', ret) + # Note: + # Need to be careful for line 21 the second and ``` ----- -### [40. Gray Code](https://oj.leetcode.com/problems/gray-code/) - -The gray code is a binary numeral system where two successive values differ in only one bit. - -Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. +### [136. Single Number](https://oj.leetcode.com/problems/single-number/) -For example, given n = 2, return [0,1,3,2]. Its gray code sequence is: +Given an array of integers, every element appears twice except for one. Find that single one. -00 - 0 -01 - 1 -11 - 3 -10 - 2 Note: -For a given n, a gray code sequence is not uniquely defined. - -For example, [0,2,3,1] is also a valid gray code sequence according to the above definition. - -For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that. +Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? ```python -# Tip: you can use bin(x) to check the binary form of a num - class Solution: - # @return a list of integers - def gray_code(self, n): - if n == 0: - return [0] - return [int(code, 2) for code in self.graycode_helper(n)] - - def graycode_helper(self, n): - if n == 1: - return ['0', '1'] - prev_code = self.graycode_helper(n-1) - cur_code = [] - for code in prev_code: - cur_code.append('0' + code) - for code in prev_code[::-1]: - cur_code.append('1' + code) - return cur_code - - # Using bit - def grayCode(self, n): - ret = [] - i = 0 - while i < 2**n: - ret.append(i>>1^i) - i+=1 - return ret - -# Using generator - - def grayCodeGen(self, n, reverse=False): - if n == 1: - if reverse: - yield "1" - yield "0" - else: - yield "0" - yield "1" - else: - if reverse: - # all the "1"s start first - gcprev = self.grayCodeGen(n-1, False) - for code in gcprev: - yield "1" + code - gcprev = self.grayCodeGen(n-1, True) - for code in gcprev: - yield "0" + code - else: - # all the "0" start first - gcprev = self.grayCodeGen(n-1, False) - for code in gcprev: - yield "0" + code - gcprev = self.grayCodeGen(n-1, True) - for code in gcprev: - yield "1" + code - + # @param A, a list of integer + # @return an integer + def singleNumber(self, A): + for num in A[1:]: + A[0] ^= num + return A[0] ``` ----- -### [41. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) +### [137. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) -Implement strStr(). +Given an array of integers, every element appears three times except for one. Find that single one. -Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. +Note: +Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? ```python class Solution: - # @param haystack, a string - # @param needle, a string - # @return a string or None - def strStr(self, haystack, needle): - H = len(haystack) - N = len(needle) - if N == 0: - return haystack - i = 0 - while i < H - N + 1: - if haystack[i] == needle[0]: - start = None # Use None here - j = 1 - while j < N and haystack[i+j] == needle[j]: - if start == None and haystack[i+j] == needle[0]: # Find first dup occurance - start = i + j - j += 1 - if j == N: - return haystack[i:] - if start is not None: - i = start - else: - i = i + j - else: - i += 1 - return None + # @param A, a list of integer + # @return an integer + def singleNumber(self, A): + res = 0 + bits = [0 for i in range(32)] + for i in range(32): + for num in A: + bits[i] += (num >> i & 1) + bits[i] %= 3 + if bits[31] % 3 == 0: # Positive + for i in range(31): + if bits[i] == 1: + res += 1 << i + else: # Negative + for i in range(31): + if bits[i] == 0: + res += 1 << i + res = -(res + 1) + return res + + A = [-2,-2,1,1,-3,1,-3,-3,-4,-2] + A = [1,2,3,1,2,3,1,2,3,-4] + print singleNumber('shit', A) + # Note: - # line 32, don't forget the i += 1 + # Python is a little different with doing this + # In java, int is 32 bits, so we can just play with it + # But in python, need to check if number is positive or negative + # So need to do line 18 to 26 check + # Otherwise should looks like somthing + + def singleNumber(self, A): + res = 0 + bit = [0 for i in range(32)] + for i in range(32): + for num in A: + bit[i] += num >> i & 1 + bit[i] %= 3 + res += bit[i] << i + return res, bit + # A = [1,2,3,1,2,3,1,2,3,-4] + # print int(singleNumber('shit', A)[1]) + # int(''.join(['0' if i==1 else '1' for i in a])[::-1], 2) + 1 真他妈爽 + # This one works fine in python if all num > 0 ``` ----- -### [42. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) +### [138. Copy List with Random Pointer](https://oj.leetcode.com/problems/copy-list-with-random-pointer/) -Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). +A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. -You may assume that the intervals were initially sorted according to their start times. - -Example 1: -Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. - -Example 2: -Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16]. - -This is because the new interval [4,9] overlaps with [3,5],[6,7],[8,10]. +Return a deep copy of the list. ```python -# Definition for an interval. -# class Interval: -# def __init__(self, s=0, e=0): -# self.start = s -# self.end = e +# Definition for singly-linked list with a random pointer. +# class RandomListNode: +# def __init__(self, x): +# self.label = x +# self.next = None +# self.random = None class Solution: - # @param intervals, a list of Intervals - # @param newInterval, a Interval - # @return a list of Interval - def insert(self, intervals, newInterval): - res = [] - inserted = False - for inter in intervals: - if newInterval.end < inter.start: - if not inserted: - res.append(newInterval) - inserted = True - res.append(inter) - elif inter.end < newInterval.start: - res.append(inter) - else: - newInterval.start = min(newInterval.start, inter.start) - newInterval.end = max(newInterval.end, inter.end) - - if not inserted: - res.append(newInterval) - return res - # Note - # 分三种情况讨论 - # 1. 插入区间在当前区间左边 - 如果没插入就插入, 添加当前区间 - # 2. 插入区间在当前区间右边 - 插入当前区间 - # 3. 剩余的mix情况 - 合并两个区间 + # @param head, a RandomListNode + # @return a RandomListNode + def copyRandomList(self, head): + if head is None: + return None + cur = head + while cur is not None: + newNode = RandomListNode(cur.label) + newNode.next = cur.next + cur.next = newNode + cur = newNode.next + cur = head + while cur is not None: + newNode = cur.next + if cur.random is not None: # random pointer may not exist + newNode.random = cur.random.next + cur = newNode.next + cur = head + newNodehead = head.next + while cur is not None: + newNode = cur.next + cur.next = newNode.next + if newNode.next is not None: + newNode.next = newNode.next.next + cur = cur.next + return newNodehead ``` ----- -### [43. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) +### [139. Word Break](https://oj.leetcode.com/problems/word-break/) -Sort a linked list using insertion sort. +Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. -```python +For example, given +s = "leetcode", +dict = ["leet", "code"]. -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None +Return true because "leetcode" can be segmented as "leet code". + +```python class Solution: - # @param head, a ListNode - # @return a ListNode - def insertionSortList(self, head): - dummy = ListNode(-9223372036854775807-1) - dummy.next = head - cur = dummy - while cur.next is not None: - if cur.val < cur.next.val: - cur = cur.next - else: - insert = cur.next - cur.next = insert.next - start = dummy - while start.val < insert.val: - prev = start - start = start.next - prev.next = insert - insert.next = start - return dummy.next + # @param s, a string + # @param dict, a set of string + # @return a boolean + def wordBreak(self, s, dict): + return self.wordBreak_1(s, dict) - # Write everything in one func MAY increase the speed of processing - # Made a mistake here, pasted the code to Sort List and coulnd't pass... - # 1. The insertion sort shown in wiki, will check from back to front. It's the same to check from front-back + def wordBreak_1(self, s, dict): + N = len(s) + dp = [False for i in range(N+1)] + dp[0] = True + for i in range(1, N+1): + for j in range(i): + if dp[j] and s[j:i] in dict: + dp[i] = True + break + return dp[N] + # Note: + # 1. dp[i] means from first i-1 chars can be break + # 2. dp[0] = True + # 3. dp[i] = for j in (i-1, ... 0) if dp[j] and s[j:i] in dict + # 4. dp[N] !!! Very important here it's N not N-1 ``` ----- -### [44. Integer to Roman](https://oj.leetcode.com/problems/integer-to-roman/) +### [13. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) -Given an integer, convert it to a roman numeral. +Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. ```python class Solution: - # @return a string - def intToRoman(self, num): - digits = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD' ), - (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), - (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')] - result = "" - for digit in digits: - while num >= digit[0]: - result += digit[1] - num -= digit[0] - if num == 0: - break - return result + # @return an integer + def romanToInt(self, s): + roman_map = { 'I': 1, + 'V': 5, + 'X': 10, + 'L': 50, + 'C': 100, + 'D': 500, + 'M': 1000, + } + ret = 0 + prev = s[0] + for char in s: + if roman_map[char] <= roman_map[prev]: + ret += roman_map[char] + else: + ret += roman_map[char] - 2 * roman_map[prev] + prev = char + return ret ``` ----- -### [45. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) +### [140. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) -Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. +Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. -For example, -Given: -s1 = "aabcc", -s2 = "dbbca", +Return all such possible sentences. -When s3 = "aadbbcbcac", return true. -When s3 = "aadbbbaccc", return false. +For example, given +s = "catsanddog", +dict = ["cat", "cats", "and", "sand", "dog"]. + +A solution is ["cats and dog", "cat sand dog"]. ```python class Solution: - # @return a boolean - def isInterleave(self, s1, s2, s3): - return self.isInterleave_1(s1, s2, s3) - - def isInterleave_1(self, s1, s2, s3): - M = len(s1) - N = len(s2) - K = len(s3) - if M + N != K: - return False - dp = [ [ False for j in range(N+1)] for i in range(M+1) ] - for i in range(M+1): - for j in range(N+1): - if i == 0 and j == 0: - dp[i][j] = True - elif i > 0 and dp[i-1][j] and s1[i-1] == s3[i-1+j]: - dp[i][j] = True - elif j > 0 and dp[i][j-1] and s2[j-1] == s3[i+j-1]: - dp[i][j] = True - else: - dp[i][j] = False - return dp[M][N] - - # Note: - # 1. dp[i][j] means whether s1[:i] and s2[:j] is interleave with s3[:i+j] - # 2. dp[0...M][0...N] = False - # 3. dp[i][j] = True # if dp[i-1][j] == True and s1[i-1] == s3[i-1+j] or - # dp[i][j-1] == True and s2[j-1] == s3[i+j-1] - # = False # else - # 4. dp[M][N] - - # Will TLE - def isInterleave_2(self, s1, s2, s3): - return self.isInterleave_re(s1, 0, s2, 0, s3, 0) + # @param s, a string + # @param dict, a set of string + # @return a list of strings + def wordBreak(self, s, dict): + ret = [] + dp = [True for i in range(len(s))] + self.wordBreak_helper(0, s, dict, [], ret, dp) + return ret - def isInterleave_re(self, s1, i1, s2, i2, s3, i3): - if i1 >= len(s1) and i2 >= len(s2) and i3 >= len(s3): - return True - if i3 >= len(s3): - return False - if i1 >= len(s1): - return s2[i2:] == s3[i3:] - if i2 >= len(s2): - return s1[i1:] == s3[i3:] + def wordBreak_helper(self, start, s, dict, res, ret, dp): + if start == len(s): + ret.append(' '.join(res)) + return + for i in range(start+1, len(s)+1): + if s[start:i] in dict and dp[i-1]: + res.append(s[start:i]) + beforeChange = len(ret) + self.wordBreak_helper(i, s, dict, res, ret, dp) + if beforeChange == len(ret): + dp[i-1] = False + res.pop() - return (s1[i1] == s3[i3] and self.isInterleave_re(s1, i1+1, s2, i2, s3, i3+1)) or (s2[i2] == s3[i3] and self.isInterleave_re(s1, i1, s2, i2+1, s3, i3+1)) ``` ------ - -### [46. Jump Game](https://oj.leetcode.com/problems/jump-game/) - -Given an array of non-negative integers, you are initially positioned at the first index of the array. - -Each element in the array represents your maximum jump length at that position. - -Determine if you are able to reach the last index. -For example: -A = [2,3,1,1,4], return true. - -A = [3,2,1,0,4], return false. +这两种方法本质上没有区别 +* 前者是如果运行dfs之后结果没有变化,说明没有搜到,后面也不用搜了 +* 后者是预处理dp然后用在recursion之中 ```python -class Solution: - # @param A, a list of integers - # @return a boolean - def canJump(self, A): - return self.canJump_1(A) + def wordBreak(self, s, dict): + ret = [] + dp = self.word_break_dp(s, dict) + self.dfs_word_break(len(s)+1, s, dict, [], ret, dp) + return ret - # Real DP way, but TLE. This is a O(n^2)'s solution - def canJump_3(self, A): - if A[0] == 0: - return False - N = len(A) - dp = [False for i in range(N)] + def word_break_dp(self, s, dict): + N = len(s) + dp = [False for i in range(N+1)] dp[0] = True - for i in range(1, N): - for j in range(i)[::-1]: - if dp[j] and j + A[j] >= i: + for i in range(N): + for j in range(i): + if dp[j] and s[j:i]: dp[i] = True break - return dp[N-1] - # Note: - # 1. dp[i] means whether we can jump to i - # 2. dp[0] = True - # 3. dp[i] = True if from i-1 ... 0 if we can jump to i - # 4. dp[N-1] + return dp - # Constant DP - def canJump_1(self, A): - pre_max = A[0] - for i in range(1, len(A)): - max_jump = max(pre_max-1, A[i-1]-1) - if max_jump < 0: # Note this is < 0 but not <= 0 - return False - pre_max = max_jump - return True + def dfs_word_break(self, end, s, dict, res, ret, dp): + if end == 0: + ret.append(' '.join(res)) + return + for i in range(end): + if dp[i] and s[i:end] in dict: + res.insert(0, s[i:end]) # Note this is insert(0) + self.dfs_word_break(i, s, dict, res, ret, dp) + res.pop(0) # So this is pop(0) - # Another DP - def canJump_2(self, A): - dp = [0 for i in range(len(A))] - dp[0] = A[0] - for i in range(1, len(A)): - dp[i] = max(dp[i-1]-1, A[i-1]-1) - if dp[i] < 0: - return False - return True - # Note: - # 1. dp[i] means at i, we can jump to where - # 2. dp[0] = A[0] - # 3. dp[i] = max(A[i-1]-1, dp[i-1]-1), if dp[i] < 0: then return False - # return True if we can finish the loop + # dict = ["cat", "cats", "and", "sand", "dog"] + # s = "catsanddog" + # print wordBreak(s, dict) ``` ----- -### [47. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) - -Given an array of non-negative integers, you are initially positioned at the first index of the array. - -Each element in the array represents your maximum jump length at that position. - -Your goal is to reach the last index in the minimum number of jumps. +### [141. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) -For example: -Given array A = [2,3,1,1,4] +Given a linked list, determine if it has a cycle in it. -The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.) +Follow up: +Can you solve it without using extra space? ```python -class Solution: - # @param A, a list of integers - # @return an integer - def jump(self, A): - N = len(A) - dp = [N for i in range(N)] - dp[0] = 0 - for i in range(N): - for j in range(i)[::-1]: - if A[j] + j >= i: - dp[i] = min(dp[i], dp[j]+1) - return dp[N-1] - # Note: - # 1. dp means jump to i, the min jump steps - # 2. dp[0] = 0 - # 3. dp[i] = min(dp[i],dp[j]+1) if A[j] + j >= i +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None - def jump(self, A): - n = len(A) - if n == 1: - return 0 - res = 0 - start = 0 - while start < n-1: - res += 1 - if start + A[start] >= n-1: - return res - max_step = start - for i in range(start+1, start+A[start]+1): - if i + A[i] >= max_step + A[max_step]: # Here doesn't have to be >= - max_step = i - start = max_step +class Solution: + # @param head, a ListNode + # @return a boolean + def hasCycle(self, head): + slow = head + fast = head + while fast is not None and fast.next is not None: + slow = slow.next + fast = fast.next.next + if fast == slow: + return True + return False ``` ----- -### [48. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) +### [142. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) -Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. +Given a linked list, return the node where the cycle begins. If there is no cycle, return null. -get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. -set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item. +Follow up: +Can you solve it without using extra space? ```python -class LRUCache: - - # @param capacity, an integer - def __init__(self, capacity): - self.capacity = capacity - self.cache = collections.OrderedDict() - - # @return an integer - def get(self, key): - if key in self.cache: - value = self.cache[key] - del self.cache[key] - self.cache[key] = value - return value - return -1 - - # @param key, an integer - # @param value, an integer - # @return nothing - def set(self, key, value): - if key not in self.cache and len(self.cache) >= self.capacity: - self.cache.popitem(last=False) - elif key in self.cache: - del self.cache[key] - self.cache[key] = value - - # Keep a note here, always delete the item. Cause update the key won't update the order - - # @param capacity, an integer - def __init__(self, capacity): - self.capacity = capacity - self.cache = {} - self.queue = [] - - # @return an integer - def get(self, key): - if key in self.cache: - self.queue.remove(key) - self.queue.append(key) - return self.cache[key] - return -1 - - # @param key, an integer - # @param value, an integer - # @return nothing - def set(self, key, value): - if key in self.cache: - self.queue.remove(key) - elif len(self.cache) >= self.capacity: - remove = self.queue.pop(0) - self.cache.pop(remove) +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None - self.queue.append(key) - self.cache[key] = value +class Solution: + # @param head, a ListNode + # @return a list node + def detectCycle(self, head): + if head is None or head.next is None: + return None + slow = head.next + fast = head.next.next + while slow!=fast: + if fast is None or fast.next is None: + return None + slow = slow.next + fast = fast.next.next + fast = head + while slow!=fast: + slow = slow.next + fast = fast.next + return slow - # Checked online, so changed to use python's ordered dictionary - # So obsoleted queue - # Also, there was some understanding mistake - # When get a key, it won't delete the key, but just reorder it to highier rank - # Just like a cache. Don't think it as a dict + # Remember to set slow = head.next and fast = head.next.next before entering the loop ``` ----- -### [49. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) - -Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. - - -Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. +### [143. Reorder List](https://oj.leetcode.com/problems/reorder-list/) +Given a singly linked list L: L0→L1→…→Ln-1→Ln, +reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… -The largest rectangle is shown in the shaded area, which has area = 10 unit. +You must do this in-place without altering the nodes' values. For example, -Given height = [2,1,5,6,2,3], -return 10. +Given {1,2,3,4}, reorder it to {1,4,2,3}. ```python -class Solution: - # @param height, a list of integer - # @return an integer - def largestRectangleArea(self, height): - height.append(0) # append 0 to the end, used to find the last - N = len(height) - stack = [] - max_area = 0 - i = 0 - while i < N: - if len(stack) == 0 or height[i] >= height[stack[-1]]: - stack.append(i) - i += 1 - else: - index = stack.pop() # h = height[index] - if len(stack) == 0: - width = i # left bound = 0, right bound i-1, w = (i-1) - (0) + 1 = i - else: - width = i - stack[-1] - 1 # left bound = stack[-1] + 1, right bound = i-1, w = (i-1) - (stack[-1] + 1) + 1 = i - stack[-1] - 1 - max_area = max(max_area, width * height[index]) - return max_area -``` ------ - -### [50. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None -Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. - -If the last word does not exist, return 0. - -Note: A word is defined as a character sequence consists of non-space characters only. - -For example, -Given s = "Hello World", -return 5. +class Solution: + # @param head, a ListNode + # @return nothing + def reorderList(self, head): + if not head or not head.next: + return head + mid = self.find_mid(head) + next_node = mid.next + mid.next = None + second_half = self.reverse(next_node) -```python + self.merge(head, second_half) + return head -class Solution: - # @param s, a string - # @return an integer - def lengthOfLastWord(self, s): - return self.lengthOfLastWord_3(s) + def find_mid(self, head): + slow = head + fast = head.next + while fast and fast.next: + fast = fast.next.next + slow = slow.next + return slow - def lengthOfLastWord_1(self, s): - if len(s.strip()) == 0: # Need to check if len(s) is 0 - return 0 - return len(s.strip().split()[-1]) # Python way + def reverse(self, head): + dummy = ListNode(0) + dummy.next = head + while head.next: + move = head.next + head.next = move.next + move.next = dummy.next + dummy.next = move + return dummy.next - def lengthOfLastWord_2(self, s): # My way - n = len(s) - 1 - while n >= 0 and s[n] == ' ': - n -= 1 + def merge(self, l1, l2): + dummy = ListNode(0) + cur = dummy i = 0 - while n >= 0 and s[n] != ' ': - n -= 1 + while l1 and l2: + if i % 2 == 0: + cur.next = l1 + l1 = l1.next + else: + cur.next = l2 + l2 = l2.next + cur = cur.next i += 1 - return i - - def lengthOfLastWord_3(self, s): # Annie way - n = len(s) - 1 - res = 0 - while n >= 0: - if s[n] != ' ': - res += 1 - elif res > 0: - break - n -= 1 - return res + if l1: + cur.next = l1 + if l2: + cur.next = l2 ``` ----- -### [51. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) - -Given a digit string, return all possible letter combinations that the number could represent. - -A mapping of digit to letters (just like on the telephone buttons) is given below. +### [144. Binary Tree Preorder Traversal](https://oj.leetcode.com/problems/binary-tree-preorder-traversal/) +Given a binary tree, return the preorder traversal of its nodes' values. +For example: +Given binary tree {1,#,2,3}, +``` + 1 + \ + 2 + / + 3 +``` +return [1,2,3]. -Input:Digit string "23" -Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. -Note: -Although the above answer is in lexicographical order, your answer could be in any order you want. +Note: Recursive solution is trivial, could you do it iteratively? ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @return a list of strings, [s1, s2] - def letterCombinations(self, digits): - self.digit_map = { '2': 'abc', - '3': 'def', - '4': 'ghi', - '5': 'jkl', - '6': 'mno', - '7': 'pqrs', - '8': 'tuv', - '9': 'wxyz' - } - return self.letterCombinations_2(digits) + # @param root, a tree node + # @return a list of integers + def preorderTraversal(self, root): + return self.preorderTraversal_1(root) - def letterCombinations_1(self, digits): - ret = [''] - for digit in digits: - res = [] - for comb in ret: - for digit_char in self.digit_map[digit]: - res.append(comb+digit_char) - ret = res - return ret + def preorderTraversal_1(self, root): + stack = [] + current = root + res = [] + while current is not None or len(stack)>0: + if current is not None: + res.append(current.val) + stack.append(current) + current = current.left + elif len(stack)>0: + current = stack.pop() + current = current.right + return res - # Recursion way to do this - def letterCombinations_2(self, digits): - ret = [] - self.letterCombinations_rec(0, digits, '', ret) - return ret + def preorderTraversal_2(self, root): + res = [] + self.preorderTraversal_rec(root, res) + return res - def letterCombinations_rec(self, i, digits, res, ret): - if i == len(digits): - ret.append(res[:]) + def preorderTraversal_rec(self, root, res): + if root is None: return - for char in self.digit_map[digits[i]]: - self.letterCombinations_rec(i+1, digits, res + char, ret) + res.append(root.val) + self.preorderTraversal_rec(root.left, res) + self.preorderTraversal_rec(root.right, res) ``` ----- -### [52. Linked List Cycle](https://oj.leetcode.com/problems/linked-list-cycle/) +### [145. Binary Tree Postorder Traversal](https://oj.leetcode.com/problems/binary-tree-postorder-traversal/) -Given a linked list, determine if it has a cycle in it. +Given a binary tree, return the postorder traversal of its nodes' values. -Follow up: -Can you solve it without using extra space? +For example: +Given binary tree {1,#,2,3}, +``` + 1 + \ + 2 + / + 3 +``` +return [3,2,1]. + +Note: Recursive solution is trivial, could you do it iteratively? ```python -# Definition for singly-linked list. -# class ListNode: +# Definition for a binary tree node +# class TreeNode: # def __init__(self, x): # self.val = x -# self.next = None +# self.left = None +# self.right = None class Solution: - # @param head, a ListNode - # @return a boolean - def hasCycle(self, head): - slow = head - fast = head - while fast is not None and fast.next is not None: - slow = slow.next - fast = fast.next.next - if fast == slow: - return True - return False + # @param root, a tree node + # @return a list of integers + def postorderTraversal(self, root): + return self.postorderTraversal_1(root) + + # I prefer this way + def postorderTraversal_1(self, root): + if root is None: + return [] + stack = [root] + output = [] + while len(stack)>0: + node = stack.pop() + output.append(node.val) + if node.left is not None: + stack.append(node.left) + if node.right is not None: + stack.append(node.right) + return output[::-1] + + # I don't like this way + def postorderTraversal_2(self, root): + stack = [] + current = root + res = [] + last = None + while current is not None or len(stack)>0: + if current is not None: + stack.append(current) + current = current.left + else: + peak = stack[-1] + if peak.right is not None and last != peak.right: + current = peak.right + else: + last = stack.pop() + res.append(last.val) + return res + + def postorderTraversal_3(self, root): + res = [] + self.postorderTraversal_rec(root, res) + return res + + def postorderTraversal_rec(self, root, res): + if root is None: + return + self.postorderTraversal_rec(root.left, res) + self.postorderTraversal_rec(root.right, res) + res.append(root.val) ``` ----- -### [53. Linked List Cycle II](https://oj.leetcode.com/problems/linked-list-cycle-ii/) +### [146. LRU Cache](https://oj.leetcode.com/problems/lru-cache/) -Given a linked list, return the node where the cycle begins. If there is no cycle, return null. +Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. -Follow up: -Can you solve it without using extra space? +get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. +set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item. ```python -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): +class LRUCache: + + # @param capacity, an integer + def __init__(self, capacity): + self.capacity = capacity + self.cache = collections.OrderedDict() + + # @return an integer + def get(self, key): + if key in self.cache: + value = self.cache[key] + del self.cache[key] + self.cache[key] = value + return value + return -1 + + # @param key, an integer + # @param value, an integer + # @return nothing + def set(self, key, value): + if key not in self.cache and len(self.cache) >= self.capacity: + self.cache.popitem(last=False) + elif key in self.cache: + del self.cache[key] + self.cache[key] = value + + # Keep a note here, always delete the item. Cause update the key won't update the order + + # @param capacity, an integer + def __init__(self, capacity): + self.capacity = capacity + self.cache = {} + self.queue = [] + + # @return an integer + def get(self, key): + if key in self.cache: + self.queue.remove(key) + self.queue.append(key) + return self.cache[key] + return -1 + + # @param key, an integer + # @param value, an integer + # @return nothing + def set(self, key, value): + if key in self.cache: + self.queue.remove(key) + elif len(self.cache) >= self.capacity: + remove = self.queue.pop(0) + self.cache.pop(remove) + + self.queue.append(key) + self.cache[key] = value + + # Checked online, so changed to use python's ordered dictionary + # So obsoleted queue + # Also, there was some understanding mistake + # When get a key, it won't delete the key, but just reorder it to highier rank + # Just like a cache. Don't think it as a dict +``` +----- + +### [147. Insertion Sort List](https://oj.leetcode.com/problems/insertion-sort-list/) + +Sort a linked list using insertion sort. + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode - # @return a list node - def detectCycle(self, head): - if head is None or head.next is None: - return None - slow = head.next - fast = head.next.next - while slow!=fast: - if fast is None or fast.next is None: - return None + # @return a ListNode + def insertionSortList(self, head): + dummy = ListNode(-9223372036854775807-1) + dummy.next = head + cur = dummy + while cur.next is not None: + if cur.val < cur.next.val: + cur = cur.next + else: + insert = cur.next + cur.next = insert.next + start = dummy + while start.val < insert.val: + prev = start + start = start.next + prev.next = insert + insert.next = start + return dummy.next + + # Write everything in one func MAY increase the speed of processing + # Made a mistake here, pasted the code to Sort List and coulnd't pass... + # 1. The insertion sort shown in wiki, will check from back to front. It's the same to check from front-back +``` +----- + +### [148. Sort List](https://oj.leetcode.com/problems/sort-list/) + +Sort a linked list in O(n log n) time using constant space complexity. + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + # @param head, a ListNode + # @return a ListNode + def sortList(self, head): + if not head or not head.next: + return head + mid = self.find_mid(head) + next_node = mid.next + mid.next = None + first_half = self.sortList(head) + second_half = self.sortList(next_node) + return self.merge_list(first_half, second_half) + + def merge_list(self, l1, l2): + dummy = ListNode(0) + cur = dummy + while l1 and l2: + if l1.val < l2.val: + cur.next = l1 + l1 = l1.next + else: + cur.next = l2 + l2 = l2.next + cur = cur.next + if l1: + cur.next = l1 + if l2: + cur.next = l2 + return dummy.next + + def find_mid(self, head): + if not head or not head.next: + return head + slow = head + fast = head.next + while fast and fast.next: slow = slow.next fast = fast.next.next - fast = head - while slow!=fast: - slow = slow.next - fast = fast.next return slow - # Remember to set slow = head.next and fast = head.next.next before entering the loop + # Way to think about this: + # 1. Split the list into first half and second half + # 2. Recursion sort the two half + # 3. Merge those two +``` +----- + +### [149. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) + +Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. + +```python + +# Definition for a point +# class Point: +# def __init__(self, a=0, b=0): +# self.x = a +# self.y = b + +class Solution: + # @param points, a list of Points + # @return an integer + def maxPoints(self, points): + N = len(points) + if N <= 2: + return N + max_points = 2 + for i in range(N-1): + p1 = points[i] + same = 1 + verti = 0 + slot = {} + max_slot = 0 + for j in range(i+1, N): + p2 = points[j] + if p1.x == p2.x and p1.y == p2.y: + same += 1 + elif p1.x == p2.x: + verti += 1 + else: + k = (p1.y - p2.y)*1.0 / (p1.x - p2.x) # This 1.0 is so important + if k not in slot: + slot[k] = 0 + slot[k] += 1 + max_slot = max(max_slot, slot[k]) + max_points = max(max_points, same + verti, same + max_slot) + return max_points + # Note: + # 1. Double loop, O(n^2) + # 2. Need to consider same nodes, vertical nodes. final is max(cur_max, same + verti, same + slots) + # 3. So many things need to be initialized ``` ----- -### [54. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) +### [14. Longest Common Prefix](https://oj.leetcode.com/problems/longest-common-prefix/) Write a function to find the longest common prefix string amongst an array of strings. @@ -2534,508 +2705,468 @@ class Solution: ``` ----- -### [55. Longest Consecutive Sequence](https://oj.leetcode.com/problems/longest-consecutive-sequence/) +### [150. Evaluate Reverse Polish Notation](https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/) -Given an unsorted array of integers, find the length of the longest consecutive elements sequence. +Evaluate the value of an arithmetic expression in Reverse Polish Notation. -For example, -Given [100, 4, 200, 1, 3, 2], -The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. +Valid operators are +, -, *, /. Each operand may be an integer or another expression. -Your algorithm should run in O(n) complexity. +Some examples: + ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 + ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6 ```python class Solution: - # @param num, a list of integer + # @param tokens, a list of string # @return an integer - def longestConsecutive(self, num): - num_dict = {} - for i in num: - if i not in num_dict: - num_dict[i] = True - ret = 1 - for i in num: - if i not in num_dict: - continue - length = 1 - j = i - while j + 1 in num_dict: - length += 1 - num_dict.pop(j+1, None) - j += 1 - j = i - while j - 1 in num_dict: - length += 1 - num_dict.pop(j-1, None) - j -= 1 - ret = max(ret, length) - num_dict.pop(i, None) - return ret - # Other methods are not O(n) solution -``` ------ - -### [56. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) + def evalRPN(self, tokens): + stack = [] + for token in tokens: + if token in ['+', '-', '*', '/']: + b = stack.pop() + a = stack.pop() + stack.append(self.calculate(a, b, token)) + else: + stack.append(int(token)) + return stack.pop() -Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. + def calculate(self, num_1, num_2, operator): + oper_dict = { '+' : lambda x, y: x + y, + '-' : lambda x, y: x - y, + '*' : lambda x, y: x * y, + '/' : lambda x, y: int( x * 1.0 / y), + } + return oper_dict[operator](num_1, num_2) -```python + # Notice: + # Need to be very careful about line 29, need to convert float and result is in int +``` +----- + +### [151. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) + +Given an input string, reverse the string word by word. +For example, +Given s = 'the sky is blue', +return 'blue is sky the'. + +Clarification: +What constitutes a word? +A sequence of non-space characters constitutes a word. +Could the input string contain leading or trailing spaces? +Yes. However, your reversed string should not contain leading or trailing spaces. +How about multiple spaces between two words? +Reduce them to a single space in the reversed string. + + +```python class Solution: + # @param s, a string # @return a string - def longestPalindrome(self, s): - N = len(s) - dp = [ [ False for j in range(N)] for i in range(N) ] - for i in range(N): - dp[i][i] = True - - for i in range(N-1): - dp[i][i+1] = s[i] == s[i+1] + def reverseWords(self, s): + return self.reverseWords_2(s) - length = 2 - max_length = 1 + def reverseWords_1(self, str): + return ' '.join(str.split()[::-1]) - while length < N: - start = 0 - while start + length < N: - if dp[start+1][start+length-1] and s[start] == s[start+length]: - dp[start][start+length] = True - max_length = max(max_length, length) - start += 1 - length += 1 - return max_length + def reverseWords_2(self, str): + res = '' + word = '' + for char in str: + if char != ' ': + word += char + elif len(word) > 0: + if res != '': + res = ' ' + res + res = word + res + word = '' - # Notice - # 1. dp[i][j] means if s[i:j] is a palindrome - # 2. dp[i][i] = True - # dp[i][i+1] = True if s[i] == s[i+1] - # 3. dp[start][start+length] = True if s[start] == s[star+length] and dp[start+1][start+length-1] - # 4. Update length - # This dp way is O(n^2) will get TLE - - Other Ways - def longestPalindrome(self, s): - arr = ['$', '#'] - for i in range(len(s)): - arr.append(s[i]) - arr.append('#') - p = [0] * len(arr) - mx, pos, ansp = 0, 0, 0 - for i in range(1, len(arr)): - p[i] = min(mx - i, p[2 * pos - i]) if mx > i else 1 - while p[i] + i < len(arr) and arr[i + p[i]] == arr[i - p[i]]: - p[i] += 1 - if p[i] + i > mx: - mx, pos = p[i] + i, i - if p[i] > p[ansp]: - ansp = i - st = (ansp - p[ansp] + 1) / 2 - return s[st:st + p[ansp] - 1] - + if len(word) > 0: + if res != '': + res = ' ' + res + res = word + res + return res ``` ----- -### [57. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) +### [152. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) -Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1. +Find the contiguous subarray within an array (containing at least one number) which has the largest product. + +For example, given the array [2,3,-2,4], +the contiguous subarray [2,3] has the largest product = 6. ```python class Solution: + # @param A, a list of integers # @return an integer - def lengthOfLongestSubstring(self, s): - start = 0 - max_len = 0 - d = {} - for i, char in enumerate(s): - if char in d: - start = max(start,d[char] + 1) - d[char] = i - max_len = max(max_len, i-start+1) - return max_len - - # I did this totally by myself. Previous solution was wrong. + def maxProduct(self, A): + min_product = A[0] + max_product = A[0] + largest_product = A[0] - - This is not incorrect, but waste too much time - def lengthOfLongestSubstring(self, s): - N = len(s) - if N <= 1: - return N - d = {} - max_len = 0 - cur = 0 - i = 0 - while i < N: - if s[i] not in d: - d[s[i]] = i - cur += 1 - max_len = max(max_len, cur) - i += 1 + for num in A[1:]: + if num > 0: + max_product = max(num, num * max_product) + min_product = min(num, num * min_product) else: - i = d[s[i]] + 1 - d = {} - cur = 0 - return max_len - + tmp = min_product + min_product = min(num, num * max_product) + max_product = max(num, num * tmp) + largest_product = max(largest_product, max_product) + + return largest_product + + # Notice: + # 1. Need to remember the idea to flip the result, and keep a note the min and max + # 2. Be careful on line 21, + # 3. Check the condition, it's a list of integer, so I was thinking too much ``` ----- -### [58. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) +### [15. 3Sum](https://oj.leetcode.com/problems/3sum/) -Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. +Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. -For "(()", the longest valid parentheses substring is "()", which has length = 2. +Note: +Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c) +The solution set must not contain duplicate triplets. + For example, given array S = {-1 0 1 2 -1 -4}, -Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4. + A solution set is: + (-1, 0, 1) + (-1, -1, 2) ```python class Solution: - # @param s, a string - # @return an integer - def longestValidParentheses(self, s): - N = len(s) - if N <= 1: - return 0 - ret = 0 - stack = [] - last = 0 - for i, char in enumerate(s): - if char == '(': - stack.append(i) - else: - if len(stack) == 0: - last = i + 1 + # @return a list of lists of length 3, [[val1,val2,val3]] + def threeSum(self, num): + num = sorted(num) + N = len(num) + ret = [] + for i in range(N-2): + if i > 0 and num[i] == num[i-1]: + continue + l = i + 1 + r = N - 1 + while l < r: + if num[i] + num[l] + num[r] < 0: + l += 1 + elif num[i] + num[l] + num[r] > 0: + r -= 1 else: - index = stack.pop() - if len(stack) == 0: - ret = max(ret, i - last + 1) - else: - ret = max(ret, i - stack[-1]) + ret.append([num[i], num[l], num[r]]) + l += 1 + r -= 1 + while l < r and num[l] == num[l-1]: + l += 1 + while l < r and num[r] == num[r+1]: + r -= 1 return ret + + # Notice: + # 1. This is almost the same to 3 Sum Closest. + # 2. remember to remove duplicate result by doing l += 1 and r -= 1, also the continue on line 22 ``` ----- -### [59. Max Points on a Line](https://oj.leetcode.com/problems/max-points-on-a-line/) +### [16. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) -Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. +Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. -```python + For example, given array S = {-1 2 1 -4}, and target = 1. -# Definition for a point -# class Point: -# def __init__(self, a=0, b=0): -# self.x = a -# self.y = b + The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). + +```python class Solution: - # @param points, a list of Points # @return an integer - def maxPoints(self, points): - N = len(points) - if N <= 2: - return N - max_points = 2 - for i in range(N-1): - p1 = points[i] - same = 1 - verti = 0 - slot = {} - max_slot = 0 - for j in range(i+1, N): - p2 = points[j] - if p1.x == p2.x and p1.y == p2.y: - same += 1 - elif p1.x == p2.x: - verti += 1 - else: - k = (p1.y - p2.y)*1.0 / (p1.x - p2.x) # This 1.0 is so important - if k not in slot: - slot[k] = 0 - slot[k] += 1 - max_slot = max(max_slot, slot[k]) - max_points = max(max_points, same + verti, same + max_slot) - return max_points - # Note: - # 1. Double loop, O(n^2) - # 2. Need to consider same nodes, vertical nodes. final is max(cur_max, same + verti, same + slots) - # 3. So many things need to be initialized -``` ------ + def threeSumClosest(self, num, target): + N = len(num) + num = sorted(num) + ret = sum(num[:3]) + i = 0 + for i in range(N-2): + l = i + 1 + r = N - 1 + while l < r: + threesum = num[i] + num[l] + num[r] + if abs(threesum-target) < abs(ret-target): # Need to check this before changing threesum + ret = threesum + if threesum == target: + return target + elif threesum < target: + l += 1 + else: + r -= 1 + return ret -### [60. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) + # Note: + # Since it's assuming each input only have one result, there's no need to check dup +``` +----- -Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. +### [17. Letter Combinations of a Phone Number](https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/) + +Given a digit string, return all possible letter combinations that the number could represent. + +A mapping of digit to letters (just like on the telephone buttons) is given below. + + + +Input:Digit string "23" +Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. +Note: +Although the above answer is in lexicographical order, your answer could be in any order you want. ```python class Solution: - # @param matrix, a list of lists of 1 length string - # @return an integer - def maximalRectangle(self, matrix): - if len(matrix) == 0 or len(matrix[0]) == 0: - return 0 - row = len(matrix) - col = len(matrix[0]) - h = [ 0 for i in range(col+1) ] - max_area = 0 - for i in range(row): - for j in range(col): - if matrix[i][j] == '0': - h[j] = 0 - else: - h[j] += 1 - max_area = max(max_area, self.largestRectangleArea(h)) - return max_area + # @return a list of strings, [s1, s2] + def letterCombinations(self, digits): + self.digit_map = { '2': 'abc', + '3': 'def', + '4': 'ghi', + '5': 'jkl', + '6': 'mno', + '7': 'pqrs', + '8': 'tuv', + '9': 'wxyz' + } + return self.letterCombinations_2(digits) - def largestRectangleArea(self, h): - stack = [] - max_area = 0 - i = 0 - while i < len(h): - if len(stack) == 0 or h[i] >= h[stack[-1]]: - stack.append(i) - i += 1 - else: - height = h[stack.pop()] - if len(stack) == 0: - width = i - else: - width = i - stack[-1] - 1 - max_area = max(max_area, width * height) - return max_area + def letterCombinations_1(self, digits): + ret = [''] + for digit in digits: + res = [] + for comb in ret: + for digit_char in self.digit_map[digit]: + res.append(comb+digit_char) + ret = res + return ret + + # Recursion way to do this + def letterCombinations_2(self, digits): + ret = [] + self.letterCombinations_rec(0, digits, '', ret) + return ret + + def letterCombinations_rec(self, i, digits, res, ret): + if i == len(digits): + ret.append(res[:]) + return + for char in self.digit_map[digits[i]]: + self.letterCombinations_rec(i+1, digits, res + char, ret) ``` ----- -### [61. Maximum Depth of Binary Tree](https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/) +### [18. 4Sum](https://oj.leetcode.com/problems/4sum/) -Given a binary tree, find its maximum depth. +Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. -The maximum depth is the number of nodes along the longest path -from the root node down to the farthest leaf node. +Note: +Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d) +The solution set must not contain duplicate quadruplets. + For example, given array S = {1 0 -1 0 -2 2}, and target = 0. -```python + A solution set is: + (-1, 0, 0, 1) + (-2, -1, 1, 2) + (-2, 0, 0, 2) -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None +```python class Solution: - # @param root, a tree node - # @return an integer - def maxDepth(self, root): - if root is None: - return 0 - return max( self.maxDepth(root.left), self.maxDepth(root.right) ) + 1 + # @return a list of lists of length 4, [[val1,val2,val3,val4]] + def fourSum(self, num, target): + return self.fourSum_1(num, target) + + # This is kitt's way, using dictionary + def fourSum_1(self, num, target): + N = len(num) + if N < 4: + return [] + num.sort() + res = set() + d = {} + # Convert 4Sum to 2Sum, store every i+j result + for i in range(N): + for j in range(i + 1, N): + if num[i] + num[j] not in d: + d[ num[i] + num[j] ] = [(i,j)] + else: + d[ num[i] + num[j] ].append( (i,j) ) + # Solve 2Sum + for i in range(N): + for j in range(i + 1, N - 2): + T = target - num[i] - num[j] + if T in d: + for k in d[T]: + if k[0] > j: res.add( ( num[i], num[j], num[k[0]], num[k[1]] ) ) + return [ list(i) for i in res ] + + # Won't pass because this is O(n^3) + def fourSum_2(self, num, target): + num.sort() + N = len(num) + ret = [] + for i in range(N-3): + if i > 0 and num[i] == num[i-1]: + continue + for j in range(i+1, N-2): + if j > i+1 and num[j] == num[j-1]: + continue + l = j + 1 + r = N - 1 + while l < r: + four_sum = num[i] + num[j] + num[l] + num[r] + if four_sum < target: + l += 1 + elif four_sum > target: + r -= 1 + else: + ret.append([num[i], num[j], num[l], num[r]]) + l += 1 + r -= 1 + while l < r and num[l] == num[l-1]: + l += 1 + while l < r and num[r] == num[r+1]: + r -= 1 + return ret ``` ----- -### [62. Maximum Product Subarray](https://oj.leetcode.com/problems/maximum-product-subarray/) +### [19. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) -Find the contiguous subarray within an array (containing at least one number) which has the largest product. +Given a linked list, remove the nth node from the end of list and return its head. -For example, given the array [2,3,-2,4], -the contiguous subarray [2,3] has the largest product = 6. +For example, -```python + Given linked list: 1->2->3->4->5, and n = 2. -class Solution: - # @param A, a list of integers - # @return an integer - def maxProduct(self, A): - min_product = A[0] - max_product = A[0] - largest_product = A[0] + After removing the second node from the end, the linked list becomes 1->2->3->5. +Note: +Given n will always be valid. +Try to do this in one pass. - for num in A[1:]: - if num > 0: - max_product = max(num, num * max_product) - min_product = min(num, num * min_product) - else: - tmp = min_product - min_product = min(num, num * max_product) - max_product = max(num, num * tmp) - largest_product = max(largest_product, max_product) +```python - return largest_product +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None - # Notice: - # 1. Need to remember the idea to flip the result, and keep a note the min and max - # 2. Be careful on line 21, - # 3. Check the condition, it's a list of integer, so I was thinking too much +class Solution: + # @return a ListNode + def removeNthFromEnd(self, head, n): + fast = head + dummy = ListNode(0) + dummy.next = head + while n > 0: + fast = fast.next + n -= 1 + slow = dummy + while fast is not None: + fast = fast.next + slow = slow.next + slow.next = slow.next.next + return dummy.next ``` ----- -### [63. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) +### [1. Two Sum](https://oj.leetcode.com/problems/two-sum/) -Find the contiguous subarray within an array (containing at least one number) which has the largest sum. +Given an array of integers, find two numbers such that they add up to a specific target number. -For example, given the array [−2,1,−3,4,−1,2,1,−5,4], -the contiguous subarray [4,−1,2,1] has the largest sum = 6. +The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. -click to show more practice. +You may assume that each input would have exactly one solution. -More practice: -If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. +Input: numbers={2, 7, 11, 15}, target=9 +Output: index1=1, index2=2 ```python class Solution: - # @param A, a list of integers - # @return an integer - def maxSubArray(self, A): - return self.maxSubArray_2(A) + # @return a tuple, (index1, index2) + def twoSum(self, num, target): + return self.twoSum_3(num, target) - def maxSubArray_1(self, A): - max_sum = A[0] - cur_sum = 0 - for num in A: - cur_sum += num - max_sum = max(max_sum, cur_sum) - if cur_sum < 0: - cur_sum = 0 - return max_sum - - def maxSubArray_2(self, A): - res = A[0] - dp = A[0] - for num in A[1:]: - dp = max(num, dp+num) - res = max(res, dp) - return res - # Note - # 1. dp[i] means maximum subarray ends with A[i] - # 2. dp[0] = A[0] - # 3. dp[i] = max(A[i], A[i] + dp[i-1]) 意思就是如果end with A[i-1]的dp是负的话我们就不取,otherwise就取 - # 4. dp[N-1] - # Because we don't need to store dp[i], so simplify to dp -``` ------ - -### [64. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) - -There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). - -```python - -class Solution: - # @return a float - def findMedianSortedArrays(self, A, B): - length = len(A) + len(B) - if length % 2 == 0: - return ( self.findKth(A, 0, B, 0, length / 2) + self.findKth(A, 0, B, 0, length / 2 + 1) ) / 2.0 - else: - return self.findKth(A, 0, B, 0, length / 2 + 1) - - def findKth(self, A, A_start, B, B_start, k): - if A_start >= len(A): - return B[B_start + k - 1] - if B_start >= len(B): - return A[A_start + k - 1] - - if k == 1: - return min(A[A_start], B[B_start]) - - if A_start + k/2 -1 < len(A): - A_key = A[A_start + k/2 -1] - else: - A_key = 9223372036854775807 + # O(n^2) + def twoSum_1(self, num, target): + N = len(num) + for i in range(N-1): + for j in range(i+1, N): + if target == num[i] + num[j]: + return (num[i], num[j]) - if B_start + k/2 -1 < len(B): - B_key = B[B_start + k/2 -1] - else: - B_key = 9223372036854775807 + # O(n) + def twoSum_2(self, num, target): + num_map = {} + for i, n in enumerate(num): + if target - n not in num_map: + num_map[n] = i + else: + return (num_map[target-n] + 1, i + 1) # Don't know why leetcode call the index [0] as 1 - if A_key < B_key: - return self.findKth(A, A_start + k / 2, B, B_start, k - k/2) - else: - return self.findKth(A, A_start, B, B_start + k / 2, k - k/2) + # O(nlgn) This is the best way, used in X Sum + def twoSum_3(self, num, target): + d = {} # This is used because we need to sort the array + for i, n in enumerate(num): + d.setdefault(n, []).append(i+1) + num = sorted(num) + l = 0 + r = len(num) - 1 + while l < r: + if num[l] + num[r] == target: + if num[l] == num[r]: + return (d[num[l]][0], d[num[r]][1]) + else: + return sorted((d[num[l]][0], d[num[r]][0])) + elif num[l] + num[r] < target: + l += 1 + else: + r -= 1 - # So manny details: - # 1. last line is k - k/2 - # 2. Line 10, divided by 2.0 to make it float - # 3. don't forget to -1 or +1 on some index + # Note: + # 1. Keep in mind we need to use a dict to store the original position. ``` ----- -### [65. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) +### [20. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) -Given a collection of intervals, merge all overlapping intervals. +Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. -For example, -Given [1,3],[2,6],[8,10],[15,18], -return [1,6],[8,10],[15,18]. +The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. ```python -# Definition for an interval. -# class Interval: -# def __init__(self, s=0, e=0): -# self.start = s -# self.end = e - class Solution: - # @param intervals, a list of Interval - # @return a list of Interval - def merge(self, intervals): - N = len(intervals) - if N <= 1: - return intervals - intervals.sort(key=lambda x: x.start) - ret = [] - prev = intervals[0] - for inter in intervals[1:]: - if inter.start <= prev.end: # Can merge - prev.end = max(prev.end, inter.end) - else: - ret.append(prev) - prev = inter - ret.append(prev) - return ret -``` ------ - -### [66. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) - -Given two sorted integer arrays A and B, merge B into A as one sorted array. - -Note: -You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m and n respectively. - -```python + # @return a boolean + def isValid(self, s): + bracket_dict = { '[' : ']', + '{' : '}', + '(' : ')', + } + stack = [] + for bracket in s: + if bracket in bracket_dict.keys(): + stack.append(bracket) + elif len(stack) == 0 or bracket !=bracket_dict[stack.pop()]: + return False + return len(stack) == 0 -class Solution: - # @param A a list of integers - # @param m an integer, length of A - # @param B a list of integers - # @param n an integer, length of B - # @return nothing - def merge(self, A, m, B, n): - i = m - 1 - j = n - 1 - x = m + n - 1 - while i>=0 and j>=0: - if A[i] > B[j]: - A[x] = A[i] - i -= 1 - else: - A[x] = B[j] - j -= 1 - x -= 1 - while j>=0: - A[x] = B[j] - x -= 1 - j -= 1 - # Focus on detail!!! + # Note return len(stack) == 0 not True! ``` ----- -### [67. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) +### [21. Merge Two Sorted Lists](https://oj.leetcode.com/problems/merge-two-sorted-lists/) Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. @@ -3070,7 +3201,36 @@ class Solution: ``` ----- -### [68. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) +### [22. Generate Parentheses](https://oj.leetcode.com/problems/generate-parentheses/) + +Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. + +For example, given n = 3, a solution set is: + +"((()))", "(()())", "(())()", "()(())", "()()()" + +```python + +class Solution: + # @param an integer + # @return a list of string + def generateParenthesis(self, n): + ret = [] + self.generateParenthesis_helper(n, n, '', ret) + return ret + + def generateParenthesis_helper(self, left, right, res, ret): + if left == 0 and right ==0: + ret.append(res[:]) + return + if left > 0: + self.generateParenthesis_helper(left-1, right, res+'(', ret) + if right > left: + self.generateParenthesis_helper(left, right-1, res+')', ret) +``` +----- + +### [23. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. @@ -3104,302 +3264,340 @@ class Solution: ``` ----- -### [69. Minimum Depth of Binary Tree](https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/) +### [24. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) -Given a binary tree, find its minimum depth. +Given a linked list, swap every two adjacent nodes and return its head. -The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. +For example, +Given 1->2->3->4, you should return the list as 2->1->4->3. + +Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. ```python -# Definition for a binary tree node -# class TreeNode: +# Definition for singly-linked list. +# class ListNode: # def __init__(self, x): # self.val = x -# self.left = None -# self.right = None +# self.next = None class Solution: - # @param root, a tree node - # @return an integer - def minDepth(self, root): - if not root: - return 0 - return self.minDepth_rec(root) - - def minDepth_rec(self, root): - if not root: - return 9223372036854775807 - if root.left is None and root.right is None: - return 1 - return min(self.minDepth_rec(root.left), self.minDepth_rec(root.right)) + 1 -``` ------ + # @param a ListNode + # @return a ListNode + def swapPairs(self, head): + return self.swapPairs_3 -### [70. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) + def swapPairs_1(self, head): + dummy = ListNode(0) + dummy.next = head + prev = dummy + while head and head.next: + prev.next = head.next + head.next = head.next.next + prev.next.next = head + prev = head + head = head.next + return dummy.next -Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. + def swapPairs_2(self, head): + if head.next is None or head.next.next is None: + return + move = head.next.next + head.next.next = move.next + move.next = head.next.next + head.next = move + self.swapPairs_2(move.next) -Note: You can only move either down or right at any point in time. + def swapPairs_3(self, head): + if head is None or head.next is None: + return head + first = head + second = head.next + first.next = second.next + second.next = first + first.next = self.swapPairs_3(first.next) + return second +``` +----- -```python +### [25. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) -class Solution: - # @param grid, a list of lists of integers - # @return an integer - def minPathSum(self, grid): - M = len(grid) - N = len(grid[0]) - dp = [ [0 for j in range(N)] for i in range(M)] - for i in range(M): - for j in range(N): - if i == 0 and j == 0: - dp[i][j] = grid[i][j] - elif i == 0: - dp[i][j] = dp[i][j-1] + grid[i][j] - elif j == 0: - dp[i][j] = dp[i-1][j] + grid[i][j] - else: - dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] - return dp[M-1][N-1] +Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. - # Note: - # 1. dp[i][j] means from (0, 0) to (i, j) the min path sum - # 2. init: dp[i][0] = dp[i-1][0]+grid[i][j], dp[0][j] += dp[0][j-1]+grid[i][j] - # 3. func: dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] - # 4. ret: dp[m-1][n-1] +If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. -All Previous work. No need to worry - def minPathSum_1(self, grid): - M = len(grid) - N = len(grid[0]) - dp = [[ 0 for j in range(N)] for i in range(M)] - dp[0][0] = grid[0][0] - for i in range(1, M): - dp[i][0] = dp[i-1][0] + grid[i][0] - for j in range(1, N): - dp[0][j] = dp[0][j-1] + grid[0][j] - for i in range(1, M): - for j in range(1, N): - dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] - return dp[M-1][N-1] +You may not alter the values in the nodes, only nodes itself may be changed. - # Another time: - # dp[m][n] dp[i][j] - # M is the rows - # N is the cols - # [[for j in range(N)] for i in range(M)] - # M = len(grid) - # N = len(grid[0]) +Only constant memory is allowed. +For example, +Given this linked list: 1->2->3->4->5 - Given the dynamic programming formula f[i][j]=min(f[i-1][j],f[i][j-1])+grid[i][j]: +For k = 2, you should return: 2->1->4->3->5 - Assume that you are populating the table row by row, the current value (f[i][j]) will be used immediately in the calculation of f[i][j+1], so there is no need to store all the previous column values. +For k = 3, you should return: 3->2->1->4->5 - Therefore, you can do it in linear space complexity. +```python - def minPathSum_2(self, grid): - M = len(grid) - N = len(grid[0]) - dp = [ 0 for j in range(N)] - dp[0] = grid[0][0] - for j in range(1, N): - dp[j] = dp[j-1] + grid[0][j] - for i in range(1, M): - dp[0] += grid[i][0] - for j in range(1, N): - dp[j] = min(dp[j], dp[j-1]) + grid[i][j] +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None - return dp[N-1] +class Solution: + # @param head, a ListNode + # @param k, an integer + # @return a ListNode + def reverseKGroup(self, head, k): + if k <= 1: + return head + dummy = ListNode(0) + dummy.next = head - # This is a bit tricky. Read the above how to simplify this - # The key is we are doing this for j ... so we can just j-1 + total_nodes = 0 + cur = head + while cur is not None: + cur = cur.next + total_nodes += 1 + n = total_nodes / k + prev = dummy + while n > 0: + i = 1 + cur = prev.next + while i < k: + move = cur.next + cur.next = move.next + move.next = prev.next + prev.next = move + i += 1 + prev = cur + n -= 1 + return dummy.next ``` ----- -### [71. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) +### [26. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) -Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). +Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. -For example, -S = "ADOBECODEBANC" -T = "ABC" -Minimum window is "BANC". +Do not allocate extra space for another array, you must do this in place with constant memory. -Note: -If there is no such window in S that covers all characters in T, return the emtpy string "". +For example, +Given input array A = [1,1,2], -If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S. +Your function should return length = 2, and A is now [1,2]. ```python class Solution: - # @return a string - def minWindow(self, S, T): - N = len(S) - M = len(T) - wanted = {} - found = {} - for char in T: - wanted[char] = wanted.get(char, 0) + 1 - found[char] = 0 - l = 0 - res = '' - counter = 0 - for r in range(N): - if S[r] not in wanted: - continue - - found[S[r]] += 1 - if found[S[r]] <= wanted[S[r]]: - counter += 1 + # @param a list of integers + # @return an integer + def removeDuplicates(self, A): + return self.removeDuplicates_2(A) - if counter == M: - while l < r: - if S[l] not in wanted: - l += 1 - continue - if found[S[l]] > wanted[S[l]]: - found[S[l]] -= 1 - l += 1 - continue - break - if not res or len(res) > r - l + 1: - res = S[l:r+1] - return res + def removeDuplicates_1(self, A): + i = 0 + for j in range(len(A)): + if i == 0 or A[j] != A[j-1]: + A[i] = A[j] + i += 1 + return i - # Note - # 1. Prepare for wo dict - # 2. Skip chars that we don't care, increase right bound - # 3. If current window contains all the chars we want(counter == M), stop and resize left bound - # 4. Skip chars that we don't care. If extra chars in found > wanted, skip them - # 5. break here - # 6. Calculate the current size + def removeDuplicates_2(self, A): + if len(A) <= 1: + return len(A) + i = 0 + for j in range(1, len(A)): + if A[i] != A[j]: + A[i+1] = A[j] + i += 1 + return i+1 + # Second way is my way ``` ----- -### [72. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) +### [27. Remove Element](https://oj.leetcode.com/problems/remove-element/) -Given two numbers represented as strings, return multiplication of the numbers as a string. +Given an array and a value, remove all instances of that value in place and return the new length. -Note: The numbers can be arbitrarily large and are non-negative. +The order of elements can be changed. It doesn't matter what you leave beyond the new length. ```python class Solution: - # @param num1, a string - # @param num2, a string - # @return a string - def multiply(self, num1, num2): - res = 0 - for i, bit_i in enumerate(num1[::-1]): - num_i = int(bit_i) * (10**i) - for j, bit_j in enumerate(num2[::-1]): - num_j = int(bit_j) * (10**j) - res += num_i * num_j - return str(res) + # @param A a list of integers + # @param elem an integer, value need to be removed + # @return an integer + def removeElement(self, A, elem): + i = 0 + for j, num in enumerate(A): + if num != elem: + A[i] = A[j] + i += 1 + return i + + # Two pointer problem ``` ----- -### [73. N-Queens](https://oj.leetcode.com/problems/n-queens/) +### [28. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) -The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. - -Given an integer n, return all distinct solutions to the n-queens puzzle. - -Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively. - -For example, -There exist two distinct solutions to the 4-queens puzzle: -[ - [".Q..", // Solution 1 - "...Q", - "Q...", - "..Q."], +Implement strStr(). - ["..Q.", // Solution 2 - "Q...", - "...Q", - ".Q.."] -] +Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. ```python class Solution: - # @return a list of lists of string - def solveNQueens(self, n): - ret = [] - res = ['.' * n for i in range(n)] - self.solveNQueens_helper(n, res, ret, 0) - return ret - - def solveNQueens_helper(self, n, res, ret, queens): - if queens == n: - ret.append(res[:]) - return - for i in range(n): - new_row = '.'*n - res[queens] = new_row[:i] + 'Q' + new_row[i+1:] - if self.is_valid(res, queens, i): - self.solveNQueens_helper(n, res, ret, queens+1) - res[queens] = new_row - - def is_valid(self, board, row, col): - for i in range(row): - for j in range(len(board[0])): - if board[i][j] == 'Q' and (j == col or abs(row-i) == abs(col-j)): - return False - return True - + # @param haystack, a string + # @param needle, a string + # @return a string or None + def strStr(self, haystack, needle): + H = len(haystack) + N = len(needle) + if N == 0: + return haystack + i = 0 + while i < H - N + 1: + if haystack[i] == needle[0]: + start = None # Use None here + j = 1 + while j < N and haystack[i+j] == needle[j]: + if start == None and haystack[i+j] == needle[0]: # Find first dup occurance + start = i + j + j += 1 + if j == N: + return haystack[i:] + if start is not None: + i = start + else: + i = i + j + else: + i += 1 + return None # Note: - # 1. Remember this it's row-i == col-j - # 2. The other way to do is use res.append() then pop() - # 3. In this case, is_valid, we can do str.find('Q') or [char for char in line].index('Q') to get index + # line 32, don't forget the i += 1 ``` ----- -### [74. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) - -Follow up for N-Queens problem. +### [29. Divide Two Integers](https://oj.leetcode.com/problems/divide-two-integers/) -Now, instead outputting board configurations, return the total number of distinct solutions. +Divide two integers without using multiplication, division and mod operator. ```python class Solution: # @return an integer - def totalNQueens(self, n): - self.ret = 0 - self.totalNQueens_helper(n, []) - return self.ret + def divide(self, dividend, divisor): + if (dividend < 0) != (divisor < 0): + sign = -1 + else: + sign = 1 - def totalNQueens_helper(self, n, res): - if len(res) == n: - self.ret += 1 # ret.append(res[:]) - return - for i in range(n): - res.append(i) - if self.is_valid(res): - self.totalNQueens_helper(n, res) - res.pop() + dividend = abs(dividend) + divisor = abs(divisor) + res = 0 + while dividend >= divisor: + shift = 0 + while dividend >= divisor << shift: + shift += 1 + #print 'res = %d, shift = %d, adding = %d, dividend = %d' % (res, shift, 1<<(shift-1), dividend) + res += 1 << (shift - 1) # This is shift-1, because the top loop quit + dividend -= divisor << (shift - 1) # when dividend < divisor << shift, so we don't want to shift more + return res * sign - def is_valid(self, board): - l = len(board) - 1 - for i in range(len(board)-1): - if board[i] == board[l] or abs(board[i]-board[l]) == abs(i-l): - return False - return True + # How to think: + # Any number can be computed in binary way, like 8 = 2^3 * 1 + 2^2 * 0 + 2^1 * 0 + 2^0 * 0 + # In this case, we calculate this num = a * (2^n * an + ... + 2^1 * a1 + 2^0 * a0) + # So we calculate an first, them decrease num with a * 2^an, and sum(2^i * ai) +``` +----- - # First remember this is diff to a normal cheesboard, - # placing a n*n chess board - # input 1, expect 1 but not 8 - # Keep in mind the way to use self.ret as global +### [2. Add Two Numbers](https://oj.leetcode.com/problems/add-two-numbers/) + +You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. + +Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) +Output: 7 -> 0 -> 8 + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + # @return a ListNode + def addTwoNumbers(self, l1, l2): + dummy = ListNode(0) + carry = 0 + cur = dummy + while l1 is not None or l2 is not None or carry > 0: + sum = carry + if l1 is not None: + sum += l1.val + l1 = l1.next + if l2 is not None: + sum += l2.val + l2 = l2.next + cur.next = ListNode(sum % 10) + carry = sum / 10 + cur = cur.next + return dummy.next +``` +----- + +### [30. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) + +You are given a string, S, and a list of words, L, that are all of the same length. +Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters. + +For example, given: +S: "barfoothefoobarman" +L: ["foo", "bar"] + +You should return the indices: [0,9]. +(order does not matter). + +```python + +class Solution: + # @param S, a string + # @param L, a list of string + # @return a list of integer + def findSubstring(self, S, L): + len_word = len(L[0]) + len_L = len(L) + len_S = len(S) + ret = [] + for i in range(len_S - len_word * len_L + 1): + list_S = [ S[j:j+len_word] for j in range(i, i + len_L*len_word, len_word)] + found = True + for word in L: + if word in list_S: + list_S.remove(word) + else: + found = False + break + if found: + ret.append(i) + return ret + + # Note + # 1. The idea is to slice S to S[i: i+len_L*len_word: len_word] and compare S's substring list with L + # Can improve it with i. replacing the list to dict increase search. ii. KMP + # 2. This is good enough. Can use KMP but it's too complicated. + # See http://c4fun.cn/blog/2014/03/20/leetcode-solution-02/#Substring_with_Concatenation_of_All_Words + # for KMP solution + # 3. Notice line 23, wrapping everything in the range is fast than calculate them in list comprehension ``` ----- -### [75. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) +### [31. Next Permutation](https://oj.leetcode.com/problems/next-permutation/) Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. @@ -3445,2228 +3643,1901 @@ class Solution: ``` ----- -### [76. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) - -Determine whether an integer is a palindrome. Do this without extra space. - -click to show spoilers. - -Some hints: -Could negative integers be palindromes? (ie, -1) No! +### [32. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) -If you are thinking of converting the integer to string, note the restriction of using extra space. +Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. -You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that the reversed integer might overflow. How would you handle such case? +For "(()", the longest valid parentheses substring is "()", which has length = 2. -There is a more generic way of solving this problem. +Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4. ```python class Solution: - # @return a boolean - def isPalindrome(self, x): - if x < 0: - return False - div = 10 - while x > div: - div *= 10 - div /= 10 - while x > 0: - if x / div != x % 10: - return False - x = (x % div) / 10 - div /= 100 - return True + # @param s, a string + # @return an integer + def longestValidParentheses(self, s): + N = len(s) + if N <= 1: + return 0 + ret = 0 + stack = [] + last = 0 + for i, char in enumerate(s): + if char == '(': + stack.append(i) + else: + if len(stack) == 0: + last = i + 1 + else: + index = stack.pop() + if len(stack) == 0: + ret = max(ret, i - last + 1) + else: + ret = max(ret, i - stack[-1]) + return ret ``` ----- -### [77. Palindrome Partitioning](https://oj.leetcode.com/problems/palindrome-partitioning/) +### [33. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) -Given a string s, partition s such that every substring of the partition is a palindrome. +Suppose a sorted array is rotated at some pivot unknown to you beforehand. -Return all possible palindrome partitioning of s. +(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). -For example, given s = "aab", -Return -``` - [ - ["aa","b"], - ["a","a","b"] - ] -``` +You are given a target value to search. If found in the array return its index, otherwise return -1. + +You may assume no duplicate exists in the array. ```python class Solution: - # @param s, a string - # @return a list of lists of string - def partition(self, s): - ret = [] - self.partition_helper(s, [], ret) - return ret - - def partition_helper(self, s, res, ret): - N = len(s) - if N == 0 : - ret.append(res[:]) - return - for i in range(1, N+1): # This N+1 is important - if self.is_palindrome(s[:i]): - res.append(s[:i]) - self.partition_helper(s[i:], res, ret) - res.pop() + # @param A, a list of integers + # @param target, an integer to be searched + # @return an integer + def search(self, A, target): + return self.search_1(A, target) - def is_palindrome(self, s): - l = 0 - r = len(s) - 1 - while l < r: - if s[l] != s[r]: - return False - l += 1 - r -= 1 - return True - # This function can use return s == s[::-1] to replace. + def search_1(self, A, target): + start = 0 + end = len(A) - 1 + while start + 1 < end: + mid = (start + end) / 2 + if target == A[mid]: + return mid + if A[start] < A[mid]: # First half sorted + if A[start] <= target < A[mid]: # In first half + end = mid + else: # In second half + start = mid + else: # Second half sorted + if A[mid] < target <= A[end]: # In second half + start = mid + else: + end = mid + if A[start] == target: + return start + if A[end] == target: + return end + return -1 + + # Switching to NC way, use start+1 < end instead + + def search_rec(self, A, target): + return self.search_helper(A, target, 0, len(A) - 1) + + def search_helper(self, A, target, start, end): + if start > end: + return -1 + mid = (start + end) / 2 + if A[mid] == target: + return mid + elif A[mid] > A[end]: # First half sorted + if A[start] <= target and target < A[mid]: + return self.search_helper(A, target, start, mid - 1) + else: + return self.search_helper(A, target, mid + 1, end) + else: # Second half sorted + if A[mid] < target and target <= A[end]: + return self.search_helper(A, target, mid + 1, end) + else: + return self.search_helper(A, target, start, mid - 1) ``` ----- -### [78. Palindrome Partitioning II](https://oj.leetcode.com/problems/palindrome-partitioning-ii/) +### [34. Find First and Last Position of Element in Sorted Array](https://oj.leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/) -Given a string s, partition s such that every substring of the partition is a palindrome. +Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. -Return the minimum cuts needed for a palindrome partitioning of s. +Your algorithm's runtime complexity must be in the order of O(log n). -For example, given s = "aab", -Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut. +If the target is not found in the array, return [-1, -1]. + +Example 1: + +Input: nums = [5,7,7,8,8,10], target = 8 +Output: [3,4] +Example 2: + +Input: nums = [5,7,7,8,8,10], target = 6 +Output: [-1,-1] ```python -import sys + class Solution: - # @param s, a string - # @return an integer - def minCut(self, s): - is_palin = self.get_is_palindrome(s) - N = len(s) - dp = [ N-1 for i in range(N+1)] - dp[0] = 0 - for i in range(1, N+1): - dp[i] = 9223372036854775807 - for j in range(i)[::-1]: - if is_palin[j][i-1]: - dp[i] = min(dp[i], dp[j]+1) - return dp[N] - 1 + # @param A, a list of integers + # @param target, an integer to be searched + # @return a list of length 2, [index1, index2] + def searchRange(self, A, target): + start = 0 + end = len(A) - 1 + bound = [-1, -1] - def get_is_palindrome(self, s): - N = len(s) - is_palin = [ [ False for j in range(N)] for i in range(N) ] - for i in range(N): - is_palin[i][i] = True + # Check for left bound + while start + 1 < end: + mid = (start + end) / 2 + if A[mid] == target: + end = mid + elif A[mid] < target: + start = mid + else: + end = mid - for i in range(N-1): - is_palin[i][i+1] = s[i] == s[i+1] + if A[start] == target: + bound[0] = start + elif A[end] == target: + bound[0] = end + else: + return bound - length = 2 - while length < N: - start = 0 - while start + length < N: - is_palin[start][start+length] = is_palin[start+1][start+length-1] and s[start] == s[start+length] - start += 1 - length += 1 - return is_palin + # Check right bound + start = 0 + end = len(A) - 1 + while start + 1 < end: + mid = (start + end) / 2 + if A[mid] == target: + start = mid + elif A[mid] < target: + start = mid + else: + end = mid - - This func is no longer used - def is_palin(s): - return s == s[::-1] - - # 1. dp means from 0 ... i the min cut times of palin - # 2. dp[0] = 0 - # 3. dp[i] = min(dp[i], dp[j]+1) for j = i-1 ... 0 if isPalin(s[j:i]) - # 4. dp[N] - 1 + if A[end] == target: + bound[1] = end + elif A[start] == target: + bound[1] = start - # get_is_palindrome is used to reduce the cost for line 21 - # it's returning dp[N] - 1, very tricky - # Beacause in definition, we define as min cut times of palin - # But actually, we just want the min cut - # abbacdc - # dp[3] = 0 but actually dp[3] = 1. So dp[N] = 1 + 1 = 2 but should be 1 - # We need to reduce a delete here + return bound ``` ----- -### [79. Partition List](https://oj.leetcode.com/problems/partition-list/) +### [35. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) -Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. +Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. -You should preserve the original relative order of the nodes in each of the two partitions. +You may assume no duplicates in the array. -For example, -Given 1->4->3->2->5->2 and x = 3, -return 1->2->2->4->3->5. +Here are few examples. +[1,3,5,6], 5 → 2 +[1,3,5,6], 2 → 1 +[1,3,5,6], 7 → 4 +[1,3,5,6], 0 → 0 ```python -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - class Solution: - # @param head, a ListNode - # @param x, an integer - # @return a ListNode - def partition(self, head, x): - before_dummy = ListNode(0) - after_dummy = ListNode(0) - before_cur = before_dummy - after_cur = after_dummy - while head is not None: - if head.val < x: - before_cur.next = head - before_cur = before_cur.next - head = head.next - before_cur.next = None + # @param A, a list of integers + # @param target, an integer to be inserted + # @return integer + def searchInsert(self, A, target): + start = 0 + end = len(A) - 1 + while start <= end: + mid = (start + end) / 2 + if A[mid] == target: + return mid + elif A[mid] < target: # need to search second half + start = mid + 1 else: - after_cur.next = head - after_cur = after_cur.next - head = head.next - after_cur.next = None - if before_dummy.next is not None: - before_cur.next = after_dummy.next - return before_dummy.next - else: - return after_dummy.next - # Set None can be done for only last + end = mid - 1 + return start + + # Too easy way, not the way wanted + def searchInsert_2(self, A, target): + for i, num in enumerate(A): + if target <= num: + return i + return len(A) ``` ----- -### [80. Pascals Triangle](https://oj.leetcode.com/problems/pascals-triangle/) +### [36. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) -Given numRows, generate the first numRows of Pascal's triangle. +Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. -For example, given numRows = 5, -Return +The Sudoku board could be partially filled, where empty cells are filled with the character '.'. -[ - [1], - [1,1], - [1,2,1], - [1,3,3,1], - [1,4,6,4,1] -] + +A partially filled sudoku which is valid. + +Note: +A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated. ```python class Solution: - # @return a list of lists of integers - def generate(numRows): - return self.generate_1(numRows) - - def generate_1(self, numRows): - res = [] - for j in range(numRows): - current = [1] - for i in range(1, j): - current.append(res[-1][i]+res[-1][i-1]) - if j>=1: - current.append(1) - res.append(current[:]) - return res + # @param board, a 9x9 2D array + # @return a boolean + def isValidSudoku(self, board): + for i in range(9): + row = [] + col = [] + for j in range(9): + if board[i][j] != '.' and board[i][j] not in row: + row.append(board[i][j]) + elif board[i][j] in row: + return False + if board[j][i] != '.' and board[j][i] not in col: + col.append(board[j][i]) + elif board[j][i] in col: + return False - def generate_2(self, numRows): - if numRows ==0: - return [] - if numRows == 1: - return [[1]] - if numRows == 2: - return [[1],[1,1]] - res = [[1], [1,1]] - prev = [1,1] - for j in range(numRows-1): - current = [1] - for i in range(1,len(prev)): - current.append(prev[i]+prev[i-1]) - current.append(1) - res.append(current[:]) - prev = current - return res + for i in range(0,9,3): + for j in range(0,9,3): + square = [] + for x in range(3): + for y in range(3): + if board[i+x][j+y] != '.' and board[i+x][j+y] not in square: + square.append(board[i+x][j+y]) + elif board[i+x][j+y] in square: + return False + return True ``` ----- -### [81. Pascals Triangle II](https://oj.leetcode.com/problems/pascals-triangle-ii/) +### [37. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) -Given an index k, return the kth row of the Pascal's triangle. +Write a program to solve a Sudoku puzzle by filling the empty cells. -For example, given k = 3, -Return [1,3,3,1]. +Empty cells are indicated by the character '.'. -Note: -Could you optimize your algorithm to use only O(k) extra space? +You may assume that there will be only one unique solution. ```python class Solution: - # @return a list of integers - def getRow(self, rowIndex): - return self.getRow_2(rowIndex) + # @param board, a 9x9 2D array + # Solve the Sudoku by modifying the input board in-place. + # Do not return any value. + def solveSudoku(self, board): + self.solve(board, 0, 0) - def getRow_1(self, rowIndex): - ret = [1] - if rowIndex == 0: - return ret - while rowIndex > 0: - if len(ret) > 1: - for i in range(1, len(ret)): - ret[i-1] = ret[i] + ret[i-1] - ret.insert(0, 1) - rowIndex -= 1 - return ret + def solve(self, board, i, j): + i, j = self.getEmpty(board, i, j) + if i == 9: # Set end point + return True # These return valuse are very important + fill = self.getPossibleInput(board, i, j) + for f in fill: + board[i] = board[i][:j] + [f] + board[i][j+1:] # Python string is imutable, but this is weird + if self.solve(board, i, j): # in leetcode, don't know what is their input + return True + board[i] = board[i][:j] + ['.'] + board[i][j+1:] + return False - def getRow_2(self, rowIndex): - ret = [1 for i in range(rowIndex+1)] - for i in range(rowIndex+1): - for j in range(i-1, 0, -1): - ret[j] += ret[j-1] - return ret + def getEmpty(self, board, i, j): + while i < 9 and j < 9 and board[i][j] != '.': + i += (j+1) / 9 # This is so qiao miao + j = (j+1) % 9 + return (i, j) + + def getPossibleInput(self, board, x, y): + fill = [str(i+1) for i in range(9)] # Note the type here + for i in range(9): + if board[x][i] in fill: + fill.remove(board[x][i]) + if board[i][y] in fill: + fill.remove(board[i][y]) + start_x = x / 3 * 3 + start_y = y / 3 * 3 + for i in range(3): + for j in range(3): + if board[start_x+i][start_y+j] in fill: + fill.remove(board[start_x+i][start_y+j]) + return fill ``` ----- -### [82. Path Sum](https://oj.leetcode.com/problems/path-sum/) +### [38. Count and Say](https://oj.leetcode.com/problems/count-and-say/) -Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. +The count-and-say sequence is the sequence of integers beginning as follows: +1, 11, 21, 1211, 111221, ... -For example: -Given the below binary tree and sum = 22, -``` - 5 - / \ - 4 8 - / / \ - 11 13 4 - / \ \ - 7 2 1 -``` -return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22. +1 is read off as "one 1" or 11. +11 is read off as "two 1s" or 21. +21 is read off as "one 2, then one 1" or 1211. +Given an integer n, generate the nth sequence. -```python +Note: The sequence of integers will be represented as a string. -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None +```python class Solution: - # @param root, a tree node - # @param sum, an integer - # @return a boolean - def hasPathSum(self, root, sum): - if root is None: - return False - if root.left is None and root.right is None: # Found a leaf - if sum == root.val: - return True - return self.hasPathSum(root.left, sum-root.val) or self.hasPathSum(root.right, sum-root.val) - - # Need to note, a leaf is a node has no left chind and no right child + # @return a string + def countAndSay(self, n): + prev = '1' + for i in range(1, n): + counter = 1 + cur = [prev[0]] + for char in prev[1:]: + if char == cur[-1]: + counter += 1 + else: + cur.insert(-1, str(counter)) + cur.append(char) + counter = 1 + cur.insert(-1, str(counter)) + prev = ''.join(cur) + return prev ``` ----- -### [83. Path Sum II](https://oj.leetcode.com/problems/path-sum-ii/) +### [39. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) -Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. +Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. -For example: -Given the below binary tree and sum = 22, -``` - 5 - / \ - 4 8 - / / \ - 11 13 4 - / \ / \ - 7 2 5 1 -``` -return -[ - [5,4,11,2], - [5,8,4,5] -] +The same repeated number may be chosen from C unlimited number of times. -```python +Note: +All numbers (including target) will be positive integers. +Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). +The solution set must not contain duplicate combinations. +For example, given candidate set 2,3,6,7 and target 7, +A solution set is: +[7] +[2, 2, 3] -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None +```python class Solution: - # @param root, a tree node - # @param sum, an integer + # @param candidates, a list of integers + # @param target, integer # @return a list of lists of integers - def pathSum(self, root, sum): + def combinationSum(self, candidates, target): ret = [] - self.pathSum_helper(root, sum, [], ret) + self.combinationSum_helper(sorted(candidates), target, [], ret) # Look into the question, need sorted return ret - def pathSum_helper(self, root, sum, res, ret): - if root is None: - return - if root.left is None and root.right is None: - if sum == root.val: - res.append(root.val) - ret.append(res[:]) - res.pop() + def combinationSum_helper(self, candidates, target, res, ret): + if target == 0: + ret.append(res[:]) return - res.append(root.val) - self.pathSum_helper(root.left, sum - root.val, res, ret) - self.pathSum_helper(root.right, sum - root.val, res, ret) - res.pop() - - -This way will have long run time - def pathSum(self, root, sum): - if root is None: - return [] - ret = [] - self.pathSum_helper(root, sum, [root.val], ret) - return ret - - def pathSum_helper(self, root, sum, res, ret): - if root.left is None and root.right is None: # Found a leaf - if sum == root.val: - ret.append(res[:]) - return - if root.left is not None: - res.append(root.left) - self.pathSum_helper(root.left, sum, res, ret) - res.pop() - if root.right is not None: - res.append(root.right) - self.pathSum_helper(root.right, sum, res, ret) + for i, num in enumerate(candidates): + if target - num < 0: + continue + res.append(num) + self.combinationSum_helper(candidates[i:], target - num, res, ret) res.pop() + # Continue when target < num ``` ----- -### [84. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) - -The set [1,2,3,…,n] contains a total of n! unique permutations. - -By listing and labeling all of the permutations in order, -We get the following sequence (ie, for n = 3): - -"123" -"132" -"213" -"231" -"312" -"321" -Given n and k, return the kth permutation sequence. +### [3. Longest Substring Without Repeating Characters](https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/) -Note: Given n will be between 1 and 9 inclusive. +Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1. ```python class Solution: - # @return a string - def getPermutation(self, n, k): - num_list = [] - total = 1 - res = '' - for i in range(1, n+1): # Detail!!! this is n+1 - total *= i - num_list.append(str(i)) - k -= 1 # This is very important - while n > 0: - total /= n - i = k / total - k %= total - res += num_list[i] - num_list.pop(i) - n -= 1 - return res + # @return an integer + def lengthOfLongestSubstring(self, s): + start = 0 + max_len = 0 + d = {} + for i, char in enumerate(s): + if char in d: + start = max(start,d[char] + 1) + d[char] = i + max_len = max(max_len, i-start+1) + return max_len - # total is very important here + # I did this totally by myself. Previous solution was wrong. + + + This is not incorrect, but waste too much time + def lengthOfLongestSubstring(self, s): + N = len(s) + if N <= 1: + return N + d = {} + max_len = 0 + cur = 0 + i = 0 + while i < N: + if s[i] not in d: + d[s[i]] = i + cur += 1 + max_len = max(max_len, cur) + i += 1 + else: + i = d[s[i]] + 1 + d = {} + cur = 0 + return max_len + ``` ----- -### [85. Permutations](https://oj.leetcode.com/problems/permutations/) +### [40. Combination Sum II](https://oj.leetcode.com/problems/combination-sum-ii/) -Given a collection of numbers, return all possible permutations. +Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. -For example, -[1,2,3] have the following permutations: -[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. +Each number in C may only be used once in the combination. + +Note: +All numbers (including target) will be positive integers. +Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). +The solution set must not contain duplicate combinations. +For example, given candidate set 10,1,2,7,6,1,5 and target 8, +A solution set is: +[1, 7] +[1, 2, 5] +[2, 6] +[1, 1, 6] ```python class Solution: - # @param num, a list of integer + # @param candidates, a list of integers + # @param target, integer # @return a list of lists of integers - def permute(self, num): - return self.permute_2(num) - - def permute_1(self, num): + def combinationSum2(self, candidates, target): ret = [] - self.permute_helper(num, [], ret) + self.combinationSum_helper(sorted(candidates), target, [], ret) # Look into the question, need sorted return ret - def permute_helper(self, num, res, ret): - if len(num) == 0: + def combinationSum_helper(self, candidates, target, res, ret): + if target == 0: ret.append(res[:]) return - - for i, n in enumerate(num): - res.append(n) - self.permute_helper(num[:i] + num[i+1:], res, ret) + for i, num in enumerate(candidates): + if target < num or (i > 0 and candidates[i] == candidates[i-1]): + continue + res.append(num) + self.combinationSum_helper(candidates[i+1:], target - num, res, ret) res.pop() - # Do this "inplace" - def permute_2(self, num): - if len(num) == 0: - return [[]] # This is the tricky part - ret = [] - for i, n in enumerate(num): - rest_perms = self.permute_2( num[:i]+num[i+1:] ) - for perm in rest_perms: - ret.append( [n] + perm) - return ret + # Note some diffs with I: + # 1. line 32 check dup + # 2. line 35 [i+1:] ``` ----- -### [86. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) +### [41. First Missing Positive](https://oj.leetcode.com/problems/first-missing-positive/) -Given a collection of numbers that might contain duplicates, return all possible unique permutations. +Given an unsorted integer array, find the first missing positive integer. For example, -[1,1,2] have the following unique permutations: -[1,1,2], [1,2,1], and [2,1,1]. +Given [1,2,0] return 3, +and [3,4,-1,1] return 2. + +Your algorithm should run in O(n) time and uses constant space. ```python class Solution: - # @param num, a list of integer - # @return a list of lists of integers - def permuteUnique(self, num): - return self.permuteUnique_2(num) - - def permuteUnique_1(self, num): - ret = [] - self.permuteUnique_helper(sorted(num), [], ret) - return ret + # @param A, a list of integers + # @return an integer + def firstMissingPositive(self, A): + N = len(A) + i = 0 + while i < N: + if A[i] <= 0 or A[i] == i + 1 or A[i] > N: + i += 1 + else: + x = A[i] + if A[i] == A[x-1]: + i += 1 + continue + A[i], A[x-1] = A[x-1], A[i] - def permuteUnique_helper(self, num, res, ret): - if len(num) == 0: - ret.append(res[:]) - return - for i, n in enumerate(num): - if i > 0 and num[i] == num[i-1]: - continue - res.append(n) - self.permuteUnique_helper(num[:i] + num[i+1:], res, ret) - res.pop() - # Note: - # Should do it in this way - # 1. line 17 sorted(num) - # 2. line 25 check if already used as permutation + for i in range(N): + if A[i] != i + 1: + return i + 1 + return N + 1 - def permuteUnique_2(self, num): - if len(num) == 0: - return [[]] - unique_perm = {} - ret = [] - for i, n in enumerate(num): - if n not in unique_perm: - unique_perm[n] = True - rest_perms = self.permuteUnique_2(num[:i]+num[i+1:]) - for perm in rest_perms: - ret.append([n,]+perm) - return ret + # Note details + # 1. Good way to do this is name A[i] = x + # 2. line 22 need to check if it's already equal, like [1,1] will cause dead loop + # 3. line 29, return i+1 not A[i] + # 4. line 31 return N + 1 ``` ----- -### [87. Plus One](https://oj.leetcode.com/problems/plus-one/) +### [42. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) -Given a non-negative number represented as an array of digits, plus one to the number. +Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. -The digits are stored such that the most significant digit is at the head of the list. +For example, +Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. + + +The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image! ```python class Solution: - # @param digits, a list of integer digits - # @return a list of integer digits - def plusOne(self, digits): - i = len(digits) - 1 - carry = 1 - while i >= 0 and carry == 1: # So many detail! No need to continue calculation if carry == 0 - s = digits[i] + carry # Calculate s first - digits[i] = s % 10 - carry = s / 10 - i -= 1 - if carry == 1: # Last check - digits.insert(0, 1) - return digits + # @param A, a list of integers + # @return an integer + def trap(self, A): + N = len(A) + if N == 0: + return 0 + left_to_right = [0 for i in range(N)] + right_to_left = [0 for i in range(N)] + left_to_right[0] = A[0] + right_to_left[-1] = A[-1] + + for i in range(1, N): + left_to_right[i] = max(left_to_right[i-1], A[i]) + right_to_left[-i-1] = max(right_to_left[-i], A[-i-1]) + + water = 0 + for i in range(N): + water += min(left_to_right[i], right_to_left[i]) - A[i] # Note here + return water ``` ----- -### [88. Populating Next Right Pointers in Each Node](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/) - -Given a binary tree +### [43. Multiply Strings](https://oj.leetcode.com/problems/multiply-strings/) - struct TreeLinkNode { - TreeLinkNode *left; - TreeLinkNode *right; - TreeLinkNode *next; - } -Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. +Given two numbers represented as strings, return multiplication of the numbers as a string. -Initially, all next pointers are set to NULL. +Note: The numbers can be arbitrarily large and are non-negative. -Note: +```python -You may only use constant extra space. -You may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children). -For example, -Given the following perfect binary tree, -``` - 1 - / \ - 2 3 - / \ / \ - 4 5 6 7 -After calling your function, the tree should look like: - 1 -> NULL - / \ - 2 -> 3 -> NULL - / \ / \ - 4->5->6->7 -> NULL +class Solution: + # @param num1, a string + # @param num2, a string + # @return a string + def multiply(self, num1, num2): + res = 0 + for i, bit_i in enumerate(num1[::-1]): + num_i = int(bit_i) * (10**i) + for j, bit_j in enumerate(num2[::-1]): + num_j = int(bit_j) * (10**j) + res += num_i * num_j + return str(res) ``` +----- -```python +### [44. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None -# self.next = None +Implement wildcard pattern matching with support for '?' and '*'. -class Solution: - # @param root, a tree node - # @return nothing - def connect(self, root): - if root is None or root.left is None: - return - root.left.next = root.right - if root.right is not None and root.next is not None: - root.right.next = root.next.left - self.connect(root.left) - self.connect(root.right) +'?' Matches any single character. +'*' Matches any sequence of characters (including the empty sequence). - # Or maybe use a level order traversal - # Removed one line -``` ------ +The matching should cover the entire input string (not partial). -### [89. Populating Next Right Pointers in Each Node II](https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) +The function prototype should be: +bool isMatch(const char *s, const char *p) -Follow up for problem "Populating Next Right Pointers in Each Node". +Some examples: +isMatch("aa","a") -> false +isMatch("aa","aa") -> true +isMatch("aaa","aa") -> false +isMatch("aa", "*") -> true +isMatch("aa", "a*") -> true +isMatch("ab", "?*") -> true +isMatch("aab", "c*a*b") -> false -What if the given tree could be any binary tree? Would your previous solution still work? +```python -Note: +class Solution: + # @param s, an input string + # @param p, a pattern string + # @return a boolean + def isMatch(self, s, p): + i = 0 + j = 0 + backupS = -1 + backupP = -1 + while i < len(s): + if j < len(p) and (p[j] == '?' or s[i] == p[j]): # Move to next if s[i] == p[j] or p[j] == '?' + i += 1 + j += 1 + elif j < len(p) and p[j] == '*': # Backup if p[j] == '*'. Keep s but move p + j += 1 + backupS = i + backupP = j + else: # No match + if backupP == -1: # if no backup, return false + return False + backupS += 1 # Have a backup, move backupS, restore all the backup + i = backupS + j = backupP -You may only use constant extra space. -For example, -Given the following binary tree, -``` - 1 - / \ - 2 3 - / \ \ - 4 5 7 -After calling your function, the tree should look like: - 1 -> NULL - / \ - 2 -> 3 -> NULL - / \ \ - 4-> 5 -> 7 -> NULL + while j < len(p) and p[j] == '*': + j += 1 + return j == len(p) # and i == len(s) + # Note + # 1. Line 47 can be removed because when it's out of loop, i must == len(s) + # 2. Line 39 doens't matter if it is backupS or backupP ``` +----- -```python - -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None -# self.next = None - -class Solution: - # @param root, a tree node - # @return nothing - def connect(self, root): - if not root or (not root.left and not root.right): - return - if root.left and root.right: - root.left.next = root.right +### [45. Jump Game II](https://oj.leetcode.com/problems/jump-game-ii/) - next_node = self.find_next(root.next) - if root.right: - root.right.next = next_node - else: - root.left.next = next_node +Given an array of non-negative integers, you are initially positioned at the first index of the array. - self.connect(root.right) # Do right first then left - self.connect(root.left) +Each element in the array represents your maximum jump length at that position. - def find_next(self, root): - if not root: - return None - if not root.left and not root.right: - return self.find_next(root.next) - if root.left: - return root.left - else: - return root.right - # Notice: - # 1. Note that line 47 need to do right first then left - # 2. The reason that I doesn't need to process I first is it doesn't need to process - # nodes of root.next.next... -``` ------ +Your goal is to reach the last index in the minimum number of jumps. -### [90. Powx-n](https://oj.leetcode.com/problems/powx-n/) +For example: +Given array A = [2,3,1,1,4] -Implement pow(x, n). +The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.) ```python class Solution: - # @param x, a float - # @param n, a integer - # @return a float - def pow(self, x, n): - if x == 0 or x == 1: - return x - elif x < 0 and n % 2 == 0: - return self.pow(-x, n) - elif x < 0 and n % 2 ==1: - return self.pow(-x, n) * (-1) - elif n < 0: - return 1.0 / self.pow(x, -n) - elif n == 0: - return 1.0 - # Notice here: - # 1. Must checks: n < 0 and n == 0 - # 2. No need to check x, but if x == 0 or 1 will reduce calculation - # 3. Below the code, need to store half, if doing self.pow all the time, it's O(n) but not O(logn) - half = self.pow(x, n/2) - if n % 2 == 0: - return half * half - else: - return half * half * x - # Note to use the half var to make the code clean - # O(logn) complexity + # @param A, a list of integers + # @return an integer + def jump(self, A): + N = len(A) + dp = [N for i in range(N)] + dp[0] = 0 + for i in range(N): + for j in range(i)[::-1]: + if A[j] + j >= i: + dp[i] = min(dp[i], dp[j]+1) + return dp[N-1] + # Note: + # 1. dp means jump to i, the min jump steps + # 2. dp[0] = 0 + # 3. dp[i] = min(dp[i],dp[j]+1) if A[j] + j >= i + + def jump(self, A): + n = len(A) + if n == 1: + return 0 + res = 0 + start = 0 + while start < n-1: + res += 1 + if start + A[start] >= n-1: + return res + max_step = start + for i in range(start+1, start+A[start]+1): + if i + A[i] >= max_step + A[max_step]: # Here doesn't have to be >= + max_step = i + start = max_step ``` ----- -### [91. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) +### [46. Permutations](https://oj.leetcode.com/problems/permutations/) -Two elements of a binary search tree (BST) are swapped by mistake. - -Recover the tree without changing its structure. +Given a collection of numbers, return all possible permutations. -Note: -A solution using O(n) space is pretty straight forward. Could you devise a constant space solution? +For example, +[1,2,3] have the following permutations: +[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - class Solution: - # @param root, a tree node - # @return a tree node - def recoverTree(self, root): - self.last = None - self.wrongs = [None, None] - self.recover_helper(root) - self.wrongs[0].val, self.wrongs[1].val = self.wrongs[1].val, self.wrongs[0].val - return root + # @param num, a list of integer + # @return a list of lists of integers + def permute(self, num): + return self.permute_2(num) - def recover_helper(self, root): - if not root: + def permute_1(self, num): + ret = [] + self.permute_helper(num, [], ret) + return ret + + def permute_helper(self, num, res, ret): + if len(num) == 0: + ret.append(res[:]) return - self.recover_helper(root.left) - if self.last and self.last.val > root.val: - if not self.wrongs[0]: - self.wrongs[0] = self.last - self.wrongs[1] = root - self.last = root - self.recover_helper(root.right) + for i, n in enumerate(num): + res.append(n) + self.permute_helper(num[:i] + num[i+1:], res, ret) + res.pop() - # Note: - # 1. Very normal inorder traversal - # 2. Notice line 32,33. Always update wrongs[1], but wrongs[0] will only update one time - # Reason is image [1,2,3,4,5,6], swap to [1,2,6,4,5,3] - # We will find out 6 > 4 and 5 > 3 - # So first time we should update wrongs[0] = last, - # second time we should update wrongs[1] = root - # But line 34 first time we also update wrong[1] because if we have [1,2,4,3,5,6] - # 4 is next to 3 so we need to update them at the same time + # Do this "inplace" + def permute_2(self, num): + if len(num) == 0: + return [[]] # This is the tricky part + ret = [] + for i, n in enumerate(num): + rest_perms = self.permute_2( num[:i]+num[i+1:] ) + for perm in rest_perms: + ret.append( [n] + perm) + return ret ``` ----- -### [92. Regular Expression Matching](https://oj.leetcode.com/problems/regular-expression-matching/) +### [47. Permutations II](https://oj.leetcode.com/problems/permutations-ii/) -Implement regular expression matching with support for '.' and '*'. +Given a collection of numbers that might contain duplicates, return all possible unique permutations. -'.' Matches any single character. -'*' Matches zero or more of the preceding element. +For example, +[1,1,2] have the following unique permutations: +[1,1,2], [1,2,1], and [2,1,1]. -The matching should cover the entire input string (not partial). +```python -The function prototype should be: -bool isMatch(const char *s, const char *p) +class Solution: + # @param num, a list of integer + # @return a list of lists of integers + def permuteUnique(self, num): + return self.permuteUnique_2(num) -Some examples: -isMatch("aa","a") → false -isMatch("aa","aa") → true -isMatch("aaa","aa") → false -isMatch("aa", "a*") → true -isMatch("aa", ".*") → true -isMatch("ab", ".*") → true -isMatch("aab", "c*a*b") → true - -```python - -class Solution: - # @return a boolean - def isMatch(self, s, p): - M = len(s) - N = len(p) - dp = [ [False for j in range(N+1)] for i in range(M+1) ] - dp[0][0] = True - pi = 2 # Means pair increase, e.g. p = a*b*c*d*, s ='', should be true - while pi < N + 1 and p[pi-1] == '*': - dp[0][pi] = True - pi += 2 + def permuteUnique_1(self, num): + ret = [] + self.permuteUnique_helper(sorted(num), [], ret) + return ret - for i in range(1, M+1): - for j in range(1, N+1): - if p[j-1] == '.' or s[i-1] == p[j-1]: - dp[i][j] = dp[i-1][j-1] - elif p[j-1] == '*': - dp[i][j] = dp[i][j-2] or \ # * is used as previous*0 e.g. "aaa" = "ab*ac*a" - (dp[i-1][j] and (s[i-1] == p[j-2] or p[j-2] == '.')) # * is used as copy previous e.g. "aa" = "a*" + def permuteUnique_helper(self, num, res, ret): + if len(num) == 0: + ret.append(res[:]) + return + for i, n in enumerate(num): + if i > 0 and num[i] == num[i-1]: + continue + res.append(n) + self.permuteUnique_helper(num[:i] + num[i+1:], res, ret) + res.pop() + # Note: + # Should do it in this way + # 1. line 17 sorted(num) + # 2. line 25 check if already used as permutation - return dp[M][N] - # Notice - # 1. Line 30 initializing - # 2. Line 39 ~ 41 + def permuteUnique_2(self, num): + if len(num) == 0: + return [[]] + unique_perm = {} + ret = [] + for i, n in enumerate(num): + if n not in unique_perm: + unique_perm[n] = True + rest_perms = self.permuteUnique_2(num[:i]+num[i+1:]) + for perm in rest_perms: + ret.append([n,]+perm) + return ret ``` ----- -### [93. Remove Duplicates from Sorted Array](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/) - -Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. +### [48. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) -Do not allocate extra space for another array, you must do this in place with constant memory. +You are given an n x n 2D matrix representing an image. -For example, -Given input array A = [1,1,2], +Rotate the image by 90 degrees (clockwise). -Your function should return length = 2, and A is now [1,2]. +Follow up: +Could you do this in-place? ```python class Solution: - # @param a list of integers - # @return an integer - def removeDuplicates(self, A): - return self.removeDuplicates_2(A) + # @param matrix, a list of lists of integers + # @return a list of lists of integers + def rotate(self, matrix): + start = 0 + end = len(matrix) - 1 + while start < end: + for i in range(end-start): + tmp = matrix[start][start+i] + matrix[start][start+i] = matrix[end-i][start] + matrix[end-i][start] = matrix[end][end-i] + matrix[end][end-i] = matrix[start+i][end] + matrix[start+i][end] = tmp + #print matrix + start += 1 + end -= 1 + return matrix - def removeDuplicates_1(self, A): - i = 0 - for j in range(len(A)): - if i == 0 or A[j] != A[j-1]: - A[i] = A[j] - i += 1 - return i + # Note: + # 1. Remember line 17, which is end-start - def removeDuplicates_2(self, A): - if len(A) <= 1: - return len(A) - i = 0 - for j in range(1, len(A)): - if A[i] != A[j]: - A[i+1] = A[j] - i += 1 - return i+1 - # Second way is my way + + matrix = [[2,29,20,26,16,28],[12,27,9,25,13,21],[32,33,32,2,28,14],[13,14,32,27,22,26],[33,1,20,7,21,7],[4,24,1,6,32,34]] + def rotate(matrix): + return [list(reversed(x)) for x in zip(*matrix)] + print rotate(matrix) + ``` ----- -### [94. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) +### [49. Group Anagrams](https://oj.leetcode.com/problems/group-anagrams/) -Follow up for "Remove Duplicates": -What if duplicates are allowed at most twice? +Given an array of strings, group anagrams together. -For example, -Given sorted array A = [1,1,1,2,2,3], +Example: -Your function should return length = 5, and A is now [1,1,2,2,3]. +Input: ["eat", "tea", "tan", "ate", "nat", "bat"], +Output: +[ + ["ate","eat","tea"], + ["nat","tan"], + ["bat"] +] +Note: + +All inputs will be in lowercase. +The order of your output does not matter. ```python class Solution: - # @param A a list of integers - # @return an integer - def removeDuplicates(self, A): - if len(A) <= 2: - return len(A) - start = 1 - cur = 2 - while cur < len(A): - if A[cur] != A[start] or A[cur] != A[start-1]: - A[start+1] = A[cur] - start += 1 - cur+= 1 - return start+1 + # @param strs, a list of strings + # @return a list of strings + def anagrams(self, strs): + d = {} + for s in strs: + key = ''.join(sorted(s)) + d.setdefault(key,[]).append(s) + ret = [] + for key in d: + if len(d[key]) > 1: + ret.extend(d[key]) + return ret + # Note: + # 1. Need to use extend here, return those len(d[key]) > 1 + # 2. Need to remember the definition of Anagrams ``` ----- -### [95. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) +### [4. Median of Two Sorted Arrays](https://oj.leetcode.com/problems/median-of-two-sorted-arrays/) -Given a sorted linked list, delete all duplicates such that each element appear only once. - -For example, -Given 1->1->2, return 1->2. -Given 1->1->2->3->3, return 1->2->3. +There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). ```python -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - class Solution: - # @param head, a ListNode - # @return a ListNode - def deleteDuplicates(self, head): - if head is None or head.next is None: - return head - current = head - while current.next is not None: - if current.val == current.next.val: - current.next = current.next.next - else: - current = current.next - return head -``` ------ + # @return a float + def findMedianSortedArrays(self, A, B): + length = len(A) + len(B) + if length % 2 == 0: + return ( self.findKth(A, 0, B, 0, length / 2) + self.findKth(A, 0, B, 0, length / 2 + 1) ) / 2.0 + else: + return self.findKth(A, 0, B, 0, length / 2 + 1) -### [96. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) + def findKth(self, A, A_start, B, B_start, k): + if A_start >= len(A): + return B[B_start + k - 1] + if B_start >= len(B): + return A[A_start + k - 1] -Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. + if k == 1: + return min(A[A_start], B[B_start]) -For example, -Given 1->2->3->3->4->4->5, return 1->2->5. -Given 1->1->1->2->3, return 2->3. + if A_start + k/2 -1 < len(A): + A_key = A[A_start + k/2 -1] + else: + A_key = 9223372036854775807 -```python + if B_start + k/2 -1 < len(B): + B_key = B[B_start + k/2 -1] + else: + B_key = 9223372036854775807 -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None + if A_key < B_key: + return self.findKth(A, A_start + k / 2, B, B_start, k - k/2) + else: + return self.findKth(A, A_start, B, B_start + k / 2, k - k/2) -class Solution: - # @param head, a ListNode - # @return a ListNode - def deleteDuplicates(self, head): - if not head or not head.next: - return head - dummy = ListNode(0) - dummy.next = head - prev = dummy - cur = head.next - while cur: - if prev.next.val != cur.val: - prev = prev.next - cur = cur.next - else: - while cur and cur.val == prev.next.val: - cur = cur.next - prev.next = cur - if cur: - cur = cur.next - return dummy.next - # Better way to do this + # So manny details: + # 1. last line is k - k/2 + # 2. Line 10, divided by 2.0 to make it float + # 3. don't forget to -1 or +1 on some index ``` ----- -### [97. Remove Element](https://oj.leetcode.com/problems/remove-element/) +### [50. Powx-n](https://oj.leetcode.com/problems/powx-n/) -Given an array and a value, remove all instances of that value in place and return the new length. - -The order of elements can be changed. It doesn't matter what you leave beyond the new length. +Implement pow(x, n). ```python class Solution: - # @param A a list of integers - # @param elem an integer, value need to be removed - # @return an integer - def removeElement(self, A, elem): - i = 0 - for j, num in enumerate(A): - if num != elem: - A[i] = A[j] - i += 1 - return i - - # Two pointer problem + # @param x, a float + # @param n, a integer + # @return a float + def pow(self, x, n): + if x == 0 or x == 1: + return x + elif x < 0 and n % 2 == 0: + return self.pow(-x, n) + elif x < 0 and n % 2 ==1: + return self.pow(-x, n) * (-1) + elif n < 0: + return 1.0 / self.pow(x, -n) + elif n == 0: + return 1.0 + # Notice here: + # 1. Must checks: n < 0 and n == 0 + # 2. No need to check x, but if x == 0 or 1 will reduce calculation + # 3. Below the code, need to store half, if doing self.pow all the time, it's O(n) but not O(logn) + half = self.pow(x, n/2) + if n % 2 == 0: + return half * half + else: + return half * half * x + # Note to use the half var to make the code clean + # O(logn) complexity ``` ----- -### [98. Remove Nth Node From End of List](https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/) - -Given a linked list, remove the nth node from the end of list and return its head. - -For example, - - Given linked list: 1->2->3->4->5, and n = 2. - - After removing the second node from the end, the linked list becomes 1->2->3->5. -Note: -Given n will always be valid. -Try to do this in one pass. - -```python - -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - -class Solution: - # @return a ListNode - def removeNthFromEnd(self, head, n): - fast = head - dummy = ListNode(0) - dummy.next = head - while n > 0: - fast = fast.next - n -= 1 - slow = dummy - while fast is not None: - fast = fast.next - slow = slow.next - slow.next = slow.next.next - return dummy.next -``` ------ +### [51. N-Queens](https://oj.leetcode.com/problems/n-queens/) -### [99. Reorder List](https://oj.leetcode.com/problems/reorder-list/) +The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. -Given a singly linked list L: L0→L1→…→Ln-1→Ln, -reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… +Given an integer n, return all distinct solutions to the n-queens puzzle. -You must do this in-place without altering the nodes' values. +Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively. For example, -Given {1,2,3,4}, reorder it to {1,4,2,3}. +There exist two distinct solutions to the 4-queens puzzle: +[ + [".Q..", // Solution 1 + "...Q", + "Q...", + "..Q."], -```python + ["..Q.", // Solution 2 + "Q...", + "...Q", + ".Q.."] +] -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None +```python class Solution: - # @param head, a ListNode - # @return nothing - def reorderList(self, head): - if not head or not head.next: - return head - mid = self.find_mid(head) - next_node = mid.next - mid.next = None - second_half = self.reverse(next_node) - - self.merge(head, second_half) - return head + # @return a list of lists of string + def solveNQueens(self, n): + ret = [] + res = ['.' * n for i in range(n)] + self.solveNQueens_helper(n, res, ret, 0) + return ret - def find_mid(self, head): - slow = head - fast = head.next - while fast and fast.next: - fast = fast.next.next - slow = slow.next - return slow + def solveNQueens_helper(self, n, res, ret, queens): + if queens == n: + ret.append(res[:]) + return + for i in range(n): + new_row = '.'*n + res[queens] = new_row[:i] + 'Q' + new_row[i+1:] + if self.is_valid(res, queens, i): + self.solveNQueens_helper(n, res, ret, queens+1) + res[queens] = new_row - def reverse(self, head): - dummy = ListNode(0) - dummy.next = head - while head.next: - move = head.next - head.next = move.next - move.next = dummy.next - dummy.next = move - return dummy.next + def is_valid(self, board, row, col): + for i in range(row): + for j in range(len(board[0])): + if board[i][j] == 'Q' and (j == col or abs(row-i) == abs(col-j)): + return False + return True - def merge(self, l1, l2): - dummy = ListNode(0) - cur = dummy - i = 0 - while l1 and l2: - if i % 2 == 0: - cur.next = l1 - l1 = l1.next - else: - cur.next = l2 - l2 = l2.next - cur = cur.next - i += 1 - if l1: - cur.next = l1 - if l2: - cur.next = l2 + # Note: + # 1. Remember this it's row-i == col-j + # 2. The other way to do is use res.append() then pop() + # 3. In this case, is_valid, we can do str.find('Q') or [char for char in line].index('Q') to get index ``` ----- -### [100. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) - -Given a string containing only digits, restore it by returning all possible valid IP address combinations. +### [52. N-Queens II](https://oj.leetcode.com/problems/n-queens-ii/) -For example: -Given "25525511135", +Follow up for N-Queens problem. -return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) +Now, instead outputting board configurations, return the total number of distinct solutions. ```python class Solution: - # @param s, a string - # @return a list of strings - def restoreIpAddresses(self, s): - ret = [] - self.restoreIpAddresses_helper(s, [], ret) - return ret + # @return an integer + def totalNQueens(self, n): + self.ret = 0 + self.totalNQueens_helper(n, []) + return self.ret - def restoreIpAddresses_helper(self, s, res, ret): - if len(res) == 4 and len(s) == 0: - ret.append('.'.join(res)) - if len(res) >= 4 or len(s) == 0: + def totalNQueens_helper(self, n, res): + if len(res) == n: + self.ret += 1 # ret.append(res[:]) return + for i in range(n): + res.append(i) + if self.is_valid(res): + self.totalNQueens_helper(n, res) + res.pop() - for i in range(1, min(3,len(s))+1): - if ( 0 <= int(s[:i]) < 256 and s[:i][0]!= '0' ) or ( int(s[:i]) == 0 and len(s[:i]) == 1): - res.append(s[:i]) - self.restoreIpAddresses_helper(s[i:], res, ret) - res.pop() + def is_valid(self, board): + l = len(board) - 1 + for i in range(len(board)-1): + if board[i] == board[l] or abs(board[i]-board[l]) == abs(i-l): + return False + return True - # Note the check: - # 1. 0<= ip < 255 - # 2. ip shouldn't like 001, 000 + # First remember this is diff to a normal cheesboard, + # placing a n*n chess board + # input 1, expect 1 but not 8 + # Keep in mind the way to use self.ret as global ``` ----- -### [101. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) - -Reverse digits of an integer. - -Example1: x = 123, return 321 -Example2: x = -123, return -321 - -click to show spoilers. +### [53. Maximum Subarray](https://oj.leetcode.com/problems/maximum-subarray/) -Have you thought about this? -Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! +Find the contiguous subarray within an array (containing at least one number) which has the largest sum. -If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. +For example, given the array [−2,1,−3,4,−1,2,1,−5,4], +the contiguous subarray [4,−1,2,1] has the largest sum = 6. -Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases? +click to show more practice. -Throw an exception? Good, but what if throwing an exception is not an option? You would then have to re-design the function (ie, add an extra parameter). +More practice: +If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. ```python class Solution: + # @param A, a list of integers # @return an integer - def reverse(self, x): - if x < 0: - return (-1) * self.reverse( (-1) * x) - res = 0 - while x > 0: - res = res*10 + x%10 - x /= 10 - return res -``` ------ - -### [102. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) - -Reverse a linked list from position m to n. Do it in-place and in one-pass. + def maxSubArray(self, A): + return self.maxSubArray_2(A) -For example: -Given 1->2->3->4->5->NULL, m = 2 and n = 4, + def maxSubArray_1(self, A): + max_sum = A[0] + cur_sum = 0 + for num in A: + cur_sum += num + max_sum = max(max_sum, cur_sum) + if cur_sum < 0: + cur_sum = 0 + return max_sum -return 1->4->3->2->5->NULL. - -Note: -Given m, n satisfy the following condition: -1 ≤ m ≤ n ≤ length of list. - -```python - -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - -class Solution: - # @param head, a ListNode - # @param m, an integer - # @param n, an integer - # @return a ListNode - def reverseBetween(self, head, m, n): - dummy = ListNode(0) - dummy.next = head - start = dummy - i = 1 - while i < m: - start = start.next - i += 1 - cur = start.next - while i < n: - move = cur.next - cur.next = move.next - move.next = start.next - start.next = move - i += 1 - return dummy.next - # Notice the m and n + def maxSubArray_2(self, A): + res = A[0] + dp = A[0] + for num in A[1:]: + dp = max(num, dp+num) + res = max(res, dp) + return res + # Note + # 1. dp[i] means maximum subarray ends with A[i] + # 2. dp[0] = A[0] + # 3. dp[i] = max(A[i], A[i] + dp[i-1]) 意思就是如果end with A[i-1]的dp是负的话我们就不取,otherwise就取 + # 4. dp[N-1] + # Because we don't need to store dp[i], so simplify to dp ``` ----- -### [103. Reverse Nodes in k-Group](https://oj.leetcode.com/problems/reverse-nodes-in-k-group/) +### [54. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) -Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. - -If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. - -You may not alter the values in the nodes, only nodes itself may be changed. - -Only constant memory is allowed. +Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, -Given this linked list: 1->2->3->4->5 - -For k = 2, you should return: 2->1->4->3->5 +Given the following matrix: -For k = 3, you should return: 3->2->1->4->5 +[ + [ 1, 2, 3 ], + [ 4, 5, 6 ], + [ 7, 8, 9 ] +] +You should return [1,2,3,6,9,8,7,4,5] ```python -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - class Solution: - # @param head, a ListNode - # @param k, an integer - # @return a ListNode - def reverseKGroup(self, head, k): - if k <= 1: - return head - dummy = ListNode(0) - dummy.next = head + # @param matrix, a list of lists of integers + # @return a list of integers + def spiralOrder(self, matrix): + M = len(matrix) + if len(matrix) == 0: + return [] + N = len(matrix[0]) + start_col = start_row = 0 + end_row = M - 1 + end_col = N - 1 + ret = [] - total_nodes = 0 - cur = head - while cur is not None: - cur = cur.next - total_nodes += 1 - n = total_nodes / k + while True: + for i in range(start_col, end_col + 1): + ret.append(matrix[start_row][i]) + start_row += 1 + if start_row > end_row: + break + for i in range(start_row, end_row + 1): + ret.append(matrix[i][end_col]) + end_col -= 1 + if start_col > end_col: + break + for i in range(start_col, end_col + 1)[::-1]: + ret.append(matrix[end_row][i]) + end_row -= 1 + if start_row > end_row: + break + for i in range(start_row, end_row + 1)[::-1]: + ret.append(matrix[i][start_col]) + start_col += 1 + if start_col > end_col: + break + return ret - prev = dummy - while n > 0: - i = 1 - cur = prev.next - while i < k: - move = cur.next - cur.next = move.next - move.next = prev.next - prev.next = move - i += 1 - prev = cur - n -= 1 - return dummy.next + # Note: + # This way is a lot better to memory ``` ----- -### [104. Reverse Words in a String](https://oj.leetcode.com/problems/reverse-words-in-a-string/) +### [55. Jump Game](https://oj.leetcode.com/problems/jump-game/) -Given an input string, reverse the string word by word. +Given an array of non-negative integers, you are initially positioned at the first index of the array. -For example, -Given s = 'the sky is blue', -return 'blue is sky the'. +Each element in the array represents your maximum jump length at that position. -Clarification: -What constitutes a word? -A sequence of non-space characters constitutes a word. -Could the input string contain leading or trailing spaces? -Yes. However, your reversed string should not contain leading or trailing spaces. -How about multiple spaces between two words? -Reduce them to a single space in the reversed string. +Determine if you are able to reach the last index. + +For example: +A = [2,3,1,1,4], return true. +A = [3,2,1,0,4], return false. ```python + class Solution: - # @param s, a string - # @return a string - def reverseWords(self, s): - return self.reverseWords_2(s) + # @param A, a list of integers + # @return a boolean + def canJump(self, A): + return self.canJump_1(A) - def reverseWords_1(self, str): - return ' '.join(str.split()[::-1]) + # Real DP way, but TLE. This is a O(n^2)'s solution + def canJump_3(self, A): + if A[0] == 0: + return False + N = len(A) + dp = [False for i in range(N)] + dp[0] = True + for i in range(1, N): + for j in range(i)[::-1]: + if dp[j] and j + A[j] >= i: + dp[i] = True + break + return dp[N-1] + # Note: + # 1. dp[i] means whether we can jump to i + # 2. dp[0] = True + # 3. dp[i] = True if from i-1 ... 0 if we can jump to i + # 4. dp[N-1] - def reverseWords_2(self, str): - res = '' - word = '' - for char in str: - if char != ' ': - word += char - elif len(word) > 0: - if res != '': - res = ' ' + res - res = word + res - word = '' + # Constant DP + def canJump_1(self, A): + pre_max = A[0] + for i in range(1, len(A)): + max_jump = max(pre_max-1, A[i-1]-1) + if max_jump < 0: # Note this is < 0 but not <= 0 + return False + pre_max = max_jump + return True - if len(word) > 0: - if res != '': - res = ' ' + res - res = word + res - return res + # Another DP + def canJump_2(self, A): + dp = [0 for i in range(len(A))] + dp[0] = A[0] + for i in range(1, len(A)): + dp[i] = max(dp[i-1]-1, A[i-1]-1) + if dp[i] < 0: + return False + return True + # Note: + # 1. dp[i] means at i, we can jump to where + # 2. dp[0] = A[0] + # 3. dp[i] = max(A[i-1]-1, dp[i-1]-1), if dp[i] < 0: then return False + # return True if we can finish the loop ``` ----- -### [105. Roman to Integer](https://oj.leetcode.com/problems/roman-to-integer/) +### [56. Merge Intervals](https://oj.leetcode.com/problems/merge-intervals/) -Given a roman numeral, convert it to an integer. +Given a collection of intervals, merge all overlapping intervals. -Input is guaranteed to be within the range from 1 to 3999. +For example, +Given [1,3],[2,6],[8,10],[15,18], +return [1,6],[8,10],[15,18]. ```python -class Solution: - # @return an integer - def romanToInt(self, s): - roman_map = { 'I': 1, - 'V': 5, - 'X': 10, - 'L': 50, - 'C': 100, - 'D': 500, - 'M': 1000, - } - ret = 0 - prev = s[0] - for char in s: - if roman_map[char] <= roman_map[prev]: - ret += roman_map[char] - else: - ret += roman_map[char] - 2 * roman_map[prev] - prev = char - return ret -``` ------ - -### [106. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) - -You are given an n x n 2D matrix representing an image. - -Rotate the image by 90 degrees (clockwise). - -Follow up: -Could you do this in-place? - -```python +# Definition for an interval. +# class Interval: +# def __init__(self, s=0, e=0): +# self.start = s +# self.end = e class Solution: - # @param matrix, a list of lists of integers - # @return a list of lists of integers - def rotate(self, matrix): - start = 0 - end = len(matrix) - 1 - while start < end: - for i in range(end-start): - tmp = matrix[start][start+i] - matrix[start][start+i] = matrix[end-i][start] - matrix[end-i][start] = matrix[end][end-i] - matrix[end][end-i] = matrix[start+i][end] - matrix[start+i][end] = tmp - #print matrix - start += 1 - end -= 1 - return matrix - - # Note: - # 1. Remember line 17, which is end-start - - - matrix = [[2,29,20,26,16,28],[12,27,9,25,13,21],[32,33,32,2,28,14],[13,14,32,27,22,26],[33,1,20,7,21,7],[4,24,1,6,32,34]] - def rotate(matrix): - return [list(reversed(x)) for x in zip(*matrix)] - print rotate(matrix) - + # @param intervals, a list of Interval + # @return a list of Interval + def merge(self, intervals): + N = len(intervals) + if N <= 1: + return intervals + intervals.sort(key=lambda x: x.start) + ret = [] + prev = intervals[0] + for inter in intervals[1:]: + if inter.start <= prev.end: # Can merge + prev.end = max(prev.end, inter.end) + else: + ret.append(prev) + prev = inter + ret.append(prev) + return ret ``` ----- -### [107. Rotate List](https://oj.leetcode.com/problems/rotate-list/) - -Given a list, rotate the list to the right by k places, where k is non-negative. - -For example: -Given 1->2->3->4->5->NULL and k = 2, -return 4->5->1->2->3->NULL. - -```python - -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None +### [57. Insert Interval](https://oj.leetcode.com/problems/insert-interval/) -class Solution: - # @param head, a ListNode - # @param k, an integer - # @return a ListNode - def rotateRight(self, head, k): - if not head: - return None - length = 1 - tail = head # Naming - while tail.next: # No need to use extra prev - tail = tail.next - length += 1 - k %= length - if k == 0: - return head # Detail - tail.next = head - cur = head - i = 0 - while i < length - k - 1: # Note this detail - cur = cur.next - i += 1 - new_head = cur.next - cur.next = None - return new_head -``` ------ +Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). -### [108. Same Tree](https://oj.leetcode.com/problems/same-tree/) +You may assume that the intervals were initially sorted according to their start times. -Given two binary trees, write a function to check if they are equal or not. +Example 1: +Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. -Two binary trees are considered equal if they are structurally identical and the nodes have the same value. +Example 2: +Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16]. +This is because the new interval [4,9] overlaps with [3,5],[6,7],[8,10]. ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None +# Definition for an interval. +# class Interval: +# def __init__(self, s=0, e=0): +# self.start = s +# self.end = e class Solution: - # @param p, a tree node - # @param q, a tree node - # @return a boolean - def isSameTree(self, p, q): - if not p and not q: - return True - if not p or not q: - return False - if p.val != q.val: - return False - return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right) -``` ------ - -### [109. Scramble String](https://oj.leetcode.com/problems/scramble-string/) - -Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. - -Below is one possible representation of s1 = "great": + # @param intervals, a list of Intervals + # @param newInterval, a Interval + # @return a list of Interval + def insert(self, intervals, newInterval): + res = [] + inserted = False + for inter in intervals: + if newInterval.end < inter.start: + if not inserted: + res.append(newInterval) + inserted = True + res.append(inter) + elif inter.end < newInterval.start: + res.append(inter) + else: + newInterval.start = min(newInterval.start, inter.start) + newInterval.end = max(newInterval.end, inter.end) + if not inserted: + res.append(newInterval) + return res + # Note + # 分三种情况讨论 + # 1. 插入区间在当前区间左边 - 如果没插入就插入, 添加当前区间 + # 2. 插入区间在当前区间右边 - 插入当前区间 + # 3. 剩余的mix情况 - 合并两个区间 ``` - great - / \ - gr eat - / \ / \ -g r e at - / \ - a t -To scramble the string, we may choose any non-leaf node and swap its two children. +----- -For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat". +### [58. Length of Last Word](https://oj.leetcode.com/problems/length-of-last-word/) - rgeat - / \ - rg eat - / \ / \ -r g e at - / \ - a t -We say that "rgeat" is a scrambled string of "great". +Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. -Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae". +If the last word does not exist, return 0. - rgtae - / \ - rg tae - / \ / \ -r g ta e - / \ - t a -``` -We say that "rgtae" is a scrambled string of "great". +Note: A word is defined as a character sequence consists of non-space characters only. -Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1. +For example, +Given s = "Hello World", +return 5. ```python class Solution: - # @return a boolean - def isScramble(self, s1, s2): - if len(s1) != len(s2): - return False - if not self.hasSameLetter(s1, s2): - return False - if len(s1) <= 2: - return True - for i in range(1, len(s1)): - if ( self.isScramble(s1[:i], s2[:i]) and self.isScramble(s1[i:], s2[i:]) ) or ( self.isScramble(s1[:i], s2[-i:]) and self.isScramble(s1[i:], s2[:-i]) ): # This is soooo important, -i!!! - return True - return False + # @param s, a string + # @return an integer + def lengthOfLastWord(self, s): + return self.lengthOfLastWord_3(s) - def hasSameLetter(self, s1, s2): - if sorted(s1) != sorted(s2): - return False - return True - # Another way to do this in dp, need to learn + def lengthOfLastWord_1(self, s): + if len(s.strip()) == 0: # Need to check if len(s) is 0 + return 0 + return len(s.strip().split()[-1]) # Python way + + def lengthOfLastWord_2(self, s): # My way + n = len(s) - 1 + while n >= 0 and s[n] == ' ': + n -= 1 + i = 0 + while n >= 0 and s[n] != ' ': + n -= 1 + i += 1 + return i + + def lengthOfLastWord_3(self, s): # Annie way + n = len(s) - 1 + res = 0 + while n >= 0: + if s[n] != ' ': + res += 1 + elif res > 0: + break + n -= 1 + return res ``` ----- -### [110. Search Insert Position](https://oj.leetcode.com/problems/search-insert-position/) +### [59. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) -Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. +Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. -You may assume no duplicates in the array. +For example, +Given n = 3, -Here are few examples. -[1,3,5,6], 5 → 2 -[1,3,5,6], 2 → 1 -[1,3,5,6], 7 → 4 -[1,3,5,6], 0 → 0 +You should return the following matrix: +[ + [ 1, 2, 3 ], + [ 8, 9, 4 ], + [ 7, 6, 5 ] +] ```python class Solution: - # @param A, a list of integers - # @param target, an integer to be inserted - # @return integer - def searchInsert(self, A, target): - start = 0 - end = len(A) - 1 - while start <= end: - mid = (start + end) / 2 - if A[mid] == target: - return mid - elif A[mid] < target: # need to search second half - start = mid + 1 - else: - end = mid - 1 - return start - - # Too easy way, not the way wanted - def searchInsert_2(self, A, target): - for i, num in enumerate(A): - if target <= num: - return i - return len(A) -``` ------ - -### [111. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) - -Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: - -Integers in each row are sorted from left to right. -The first integer of each row is greater than the last integer of the previous row. -For example, - -Consider the following matrix: - -[ - [1, 3, 5, 7], - [10, 11, 16, 20], - [23, 30, 34, 50] -] -Given target = 3, return true. - -```python - -class Solution: - # @param matrix, a list of lists of integers - # @param target, an integer - # @return a boolean - def searchMatrix(self, matrix, target): - M = len(matrix) - N = len(matrix[0]) - start = 0 - end = M*N - 1 - while start <= end: - mid = (start+end) / 2 - i = mid / N - j = mid % N - if matrix[i][j] == target: - return True - elif matrix[i][j] < target: - start = mid + 1 - else: - end = mid - 1 - return False - -``` -#####Search a 2D Matrix II -What if we allow duplicate in the matrix and need to find out all the posisitons -``` - -def search_matrix_II(matrix, target): - lb = search_for_bound(matrix, target, True) - if lb == -1: - return False - rb = search_for_bound(matrix, target, False) - res = [] - for i in range(lb, rb+1): - res.append((i/N, i%N)) - return res - -def search_for_bound(matrix, target, is_lower_bound): - M = len(matrix) - N = len(matrix[0]) - start = 0 - end = M*N - 1 - while start + 1 < end: - mid = (start+end) / 2 - if matrix[mid/N][mid%N] == target: - if is_lower_bound: - end = mid - else: - start = mid - elif matrix[mid/N][mid%N] < target: - start = mid - else: - end = mid - - if is_lower_bound: - if matrix[start/N][start%N] == target: - return start - elif matrix[end/N][end%N] == target: - return end - else: - if matrix[end/N][end%N] == target: - return end - elif matrix[start/N][start%N] == target: - return start - - return -1 - -``` -Note: -1. from [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32775405.html) that answer check mid-1 == mid -2. I don't think this is a good way. So need to discuss here. -``` -``` ------ - -### [112. Search for a Range](https://oj.leetcode.com/problems/search-for-a-range/) - -Given a sorted array of integers, find the starting and ending position of a given target value. - -Your algorithm's runtime complexity must be in the order of O(log n). - -If the target is not found in the array, return [-1, -1]. - -For example, -Given [5, 7, 7, 8, 8, 10] and target value 8, -return [3, 4]. - -```python - -class Solution: - # @param A, a list of integers - # @param target, an integer to be searched - # @return a list of length 2, [index1, index2] - def searchRange(self, A, target): - start = 0 - end = len(A) - 1 - bound = [-1, -1] - - # Check for left bound - while start + 1 < end: - mid = (start + end) / 2 - if A[mid] == target: - end = mid - elif A[mid] < target: - start = mid - else: - end = mid - - if A[start] == target: - bound[0] = start - elif A[end] == target: - bound[0] = end - else: - return bound + # @return a list of lists of integer + def generateMatrix(self, n): + ret = [ [ 0 for i in range(n)] for j in range(n) ] + num = 1 + start_row = start_col = 0 + end_row = end_col = n - 1 + while True: + for i in range(start_col, end_col + 1): + ret[start_row][i] = num + num += 1 + start_row += 1 + if start_row > end_row: + break - # Check right bound - start = 0 - end = len(A) - 1 - while start + 1 < end: - mid = (start + end) / 2 - if A[mid] == target: - start = mid - elif A[mid] < target: - start = mid - else: - end = mid + for i in range(start_row, end_row + 1): + ret[i][end_col] = num + num += 1 + end_col -= 1 + if start_col > end_col: + break - if A[end] == target: - bound[1] = end - elif A[start] == target: - bound[1] = start + for i in range(end_col, start_col - 1, -1): + ret[end_row][i] = num + num += 1 + end_row -= 1 + if start_row > end_row: + break - return bound + for i in range(end_row, start_row -1, -1): + ret[i][start_col] = num + num += 1 + start_col += 1 + if start_col > end_col: + break + # This is the old way + #if n%2 == 1: + # ret[start_col][start_row] = num + return ret ``` ----- -### [113. Search in Rotated Sorted Array](https://oj.leetcode.com/problems/search-in-rotated-sorted-array/) - -Suppose a sorted array is rotated at some pivot unknown to you beforehand. - -(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). +### [5. Longest Palindromic Substring](https://oj.leetcode.com/problems/longest-palindromic-substring/) -You are given a target value to search. If found in the array return its index, otherwise return -1. - -You may assume no duplicate exists in the array. +Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. ```python class Solution: - # @param A, a list of integers - # @param target, an integer to be searched - # @return an integer - def search(self, A, target): - return self.search_1(A, target) - - def search_1(self, A, target): - start = 0 - end = len(A) - 1 - while start + 1 < end: - mid = (start + end) / 2 - if target == A[mid]: - return mid - if A[start] < A[mid]: # First half sorted - if A[start] <= target < A[mid]: # In first half - end = mid - else: # In second half - start = mid - else: # Second half sorted - if A[mid] < target <= A[end]: # In second half - start = mid - else: - end = mid - if A[start] == target: - return start - if A[end] == target: - return end - return -1 - - # Switching to NC way, use start+1 < end instead - - def search_rec(self, A, target): - return self.search_helper(A, target, 0, len(A) - 1) - - def search_helper(self, A, target, start, end): - if start > end: - return -1 - mid = (start + end) / 2 - if A[mid] == target: - return mid - elif A[mid] > A[end]: # First half sorted - if A[start] <= target and target < A[mid]: - return self.search_helper(A, target, start, mid - 1) - else: - return self.search_helper(A, target, mid + 1, end) - else: # Second half sorted - if A[mid] < target and target <= A[end]: - return self.search_helper(A, target, mid + 1, end) - else: - return self.search_helper(A, target, start, mid - 1) -``` ------ - -### [114. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) - -Follow up for "Search in Rotated Sorted Array": -What if duplicates are allowed? - -Would this affect the run-time complexity? How and why? + # @return a string + def longestPalindrome(self, s): + N = len(s) + dp = [ [ False for j in range(N)] for i in range(N) ] + for i in range(N): + dp[i][i] = True -Write a function to determine if a given target is in the array. + for i in range(N-1): + dp[i][i+1] = s[i] == s[i+1] -```python + length = 2 + max_length = 1 -class Solution: - # @param A a list of integers - # @param target an integer - # @return a boolean - def search(self, A, target): - start = 0 - end = len(A) - 1 - while start <= end: - mid = (start + end) / 2 - if A[mid] == target: - return True - elif A[start] < A[mid]: # First half sorted - if A[start] <= target and target < A[mid]: - end = mid - 1 - else: - start = mid + 1 - elif A[start]> A[mid]: # Second half sorted - if A[mid] < target and target <= A[end]: - start = mid + 1 - else: - end = mid - 1 - else: + while length < N: + start = 0 + while start + length < N: + if dp[start+1][start+length-1] and s[start] == s[start+length]: + dp[start][start+length] = True + max_length = max(max_length, length) start += 1 - return False + length += 1 + return max_length + + # Notice + # 1. dp[i][j] means if s[i:j] is a palindrome + # 2. dp[i][i] = True + # dp[i][i+1] = True if s[i] == s[i+1] + # 3. dp[start][start+length] = True if s[start] == s[star+length] and dp[start+1][start+length-1] + # 4. Update length + # This dp way is O(n^2) will get TLE + + Other Ways + def longestPalindrome(self, s): + arr = ['$', '#'] + for i in range(len(s)): + arr.append(s[i]) + arr.append('#') + p = [0] * len(arr) + mx, pos, ansp = 0, 0, 0 + for i in range(1, len(arr)): + p[i] = min(mx - i, p[2 * pos - i]) if mx > i else 1 + while p[i] + i < len(arr) and arr[i + p[i]] == arr[i - p[i]]: + p[i] += 1 + if p[i] + i > mx: + mx, pos = p[i] + i, i + if p[i] > p[ansp]: + ansp = i + st = (ansp - p[ansp] + 1) / 2 + return s[st:st + p[ansp] - 1] + ``` ----- -### [115. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) +### [60. Permutation Sequence](https://oj.leetcode.com/problems/permutation-sequence/) -Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. +The set [1,2,3,…,n] contains a total of n! unique permutations. -click to show follow up. +By listing and labeling all of the permutations in order, +We get the following sequence (ie, for n = 3): -Follow up: -Did you use extra space? -A straight forward solution using O(mn) space is probably a bad idea. -A simple improvement uses O(m + n) space, but still not the best solution. -Could you devise a constant space solution? +"123" +"132" +"213" +"231" +"312" +"321" +Given n and k, return the kth permutation sequence. + +Note: Given n will be between 1 and 9 inclusive. ```python class Solution: - # @param matrix, a list of lists of integers - # RETURN NOTHING, MODIFY matrix IN PLACE. - def setZeroes(self, matrix): - n = len(matrix[0]) - m = len(matrix) - zero_row = False - zero_col = False - - for i in range(m): - for j in range(n): - if matrix[i][j] == 0: - if i == 0: - zero_row = True - if j == 0: - zero_col = True - matrix[i][0] = matrix[0][j] = 0 - - for i in range(1, m): - for j in range(1, n): - if matrix[i][0] == 0 or matrix[0][j] == 0: - matrix[i][j] = 0 - if zero_col: - for i in range(m): - matrix[i][0] = 0 - - if zero_row: - for j in range(n): - matrix[0][j] = 0 + # @return a string + def getPermutation(self, n, k): + num_list = [] + total = 1 + res = '' + for i in range(1, n+1): # Detail!!! this is n+1 + total *= i + num_list.append(str(i)) + k -= 1 # This is very important + while n > 0: + total /= n + i = k / total + k %= total + res += num_list[i] + num_list.pop(i) + n -= 1 + return res - return matrix + # total is very important here ``` ----- -### [116. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) - -Given an absolute path for a file (Unix-style), simplify it. +### [61. Rotate List](https://oj.leetcode.com/problems/rotate-list/) -For example, -path = "/home/", => "/home" -path = "/a/./b/../../c/", => "/c" -click to show corner cases. +Given a list, rotate the list to the right by k places, where k is non-negative. -Corner Cases: -Did you consider the case where path = "/../"? -In this case, you should return "/". -Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/". -In this case, you should ignore redundant slashes and return "/home/foo". +For example: +Given 1->2->3->4->5->NULL and k = 2, +return 4->5->1->2->3->NULL. ```python +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + class Solution: - # @param path, a string - # @return a string - def simplifyPath(self, path): - path_list = path.strip('/').split('/') - ret = [] - jump = 0 - for p in path_list[::-1]: - if p == '.' or p == '': - continue - elif p == '..': - jump += 1 - else: # p is a valid path - if jump > 0: - jump -= 1 - else: - ret.insert(0, p) - return '/'+'/'.join(ret) - # Note: - # 1. Remove dup '/', if using split(), // will become '', remove it - # 2. Keep in mind those two [::-1] - # 3. Don't forget to attach the first '/' + # @param head, a ListNode + # @param k, an integer + # @return a ListNode + def rotateRight(self, head, k): + if not head: + return None + length = 1 + tail = head # Naming + while tail.next: # No need to use extra prev + tail = tail.next + length += 1 + k %= length + if k == 0: + return head # Detail + tail.next = head + cur = head + i = 0 + while i < length - k - 1: # Note this detail + cur = cur.next + i += 1 + new_head = cur.next + cur.next = None + return new_head ``` ----- -### [117. Single Number](https://oj.leetcode.com/problems/single-number/) +### [62. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) -Given an array of integers, every element appears twice except for one. Find that single one. +A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). -Note: -Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? +The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). + +How many possible unique paths are there? + +Above is a 3 x 7 grid. How many possible unique paths are there? + +Note: m and n will be at most 100. ```python class Solution: - # @param A, a list of integer # @return an integer - def singleNumber(self, A): - for num in A[1:]: - A[0] ^= num - return A[0] + def uniquePaths(self, m, n): + dp = [ [0 for j in range(n)] for i in range(m) ] + for i in range(m): + for j in range(n): + if i == 0 or j == 0: + dp[i][j] = 1 + else: + dp[i][j] = dp[i-1][j] + dp[i][j-1] + return dp[m-1][n-1] + + # Note: + # 1. dp[i][j] means from (0,0) to (i, j) how many ways to finish + # 2. init dp[i][0] = 1, dp[0][j] = 1 + # 3. dp[i][j] = dp[i-1][j] + dp[i][j-1] + # 4. result dp[m-1][n-1] ``` ----- -### [118. Single Number II](https://oj.leetcode.com/problems/single-number-ii/) +### [63. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) -Given an array of integers, every element appears three times except for one. Find that single one. +Follow up for "Unique Paths": -Note: -Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? +Now consider if some obstacles are added to the grids. How many unique paths would there be? + +An obstacle and empty space is marked as 1 and 0 respectively in the grid. + +For example, +There is one obstacle in the middle of a 3x3 grid as illustrated below. + +[ + [0,0,0], + [0,1,0], + [0,0,0] +] +The total number of unique paths is 2. + +Note: m and n will be at most 100. ```python class Solution: - # @param A, a list of integer + # @param obstacleGrid, a list of lists of integers # @return an integer - def singleNumber(self, A): - res = 0 - bits = [0 for i in range(32)] - for i in range(32): - for num in A: - bits[i] += (num >> i & 1) - bits[i] %= 3 - if bits[31] % 3 == 0: # Positive - for i in range(31): - if bits[i] == 1: - res += 1 << i - else: # Negative - for i in range(31): - if bits[i] == 0: - res += 1 << i - res = -(res + 1) - return res - - A = [-2,-2,1,1,-3,1,-3,-3,-4,-2] - A = [1,2,3,1,2,3,1,2,3,-4] - print singleNumber('shit', A) - - # Note: - # Python is a little different with doing this - # In java, int is 32 bits, so we can just play with it - # But in python, need to check if number is positive or negative - # So need to do line 18 to 26 check - # Otherwise should looks like somthing + def uniquePathsWithObstacles(self, obstacleGrid): + if obstacleGrid[0][0] == 1: + return 0 + M = len(obstacleGrid) + N = len(obstacleGrid[0]) - def singleNumber(self, A): - res = 0 - bit = [0 for i in range(32)] - for i in range(32): - for num in A: - bit[i] += num >> i & 1 - bit[i] %= 3 - res += bit[i] << i - return res, bit - # A = [1,2,3,1,2,3,1,2,3,-4] - # print int(singleNumber('shit', A)[1]) - # int(''.join(['0' if i==1 else '1' for i in a])[::-1], 2) + 1 真他妈爽 - # This one works fine in python if all num > 0 + dp = [ [0 for j in range(N)] for i in range(M) ] + for i in range(M): + for j in range(N): + if obstacleGrid[i][j] == 1: + dp[i][j] = 0 + elif i == 0 and j == 0: + dp[i][j] = 1 + elif i == 0: + dp[i][j] = dp[i][j-1] + elif j == 0: + dp[i][j] = dp[i-1][j] + else: + dp[i][j] = dp[i-1][j] + dp[i][j-1] + return dp[M-1][N-1] + + # Note: + # Same to unique path I but more steps to initialize ``` ----- -### [119. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) +### [64. Minimum Path Sum](https://oj.leetcode.com/problems/minimum-path-sum/) -Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. +Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. -Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. +Note: You can only move either down or right at any point in time. -Note: -You are not suppose to use the library's sort function for this problem. +```python -click to show follow up. +class Solution: + # @param grid, a list of lists of integers + # @return an integer + def minPathSum(self, grid): + M = len(grid) + N = len(grid[0]) + dp = [ [0 for j in range(N)] for i in range(M)] + for i in range(M): + for j in range(N): + if i == 0 and j == 0: + dp[i][j] = grid[i][j] + elif i == 0: + dp[i][j] = dp[i][j-1] + grid[i][j] + elif j == 0: + dp[i][j] = dp[i-1][j] + grid[i][j] + else: + dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] + return dp[M-1][N-1] -Follow up: -A rather straight forward solution is a two-pass algorithm using counting sort. -First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's. + # Note: + # 1. dp[i][j] means from (0, 0) to (i, j) the min path sum + # 2. init: dp[i][0] = dp[i-1][0]+grid[i][j], dp[0][j] += dp[0][j-1]+grid[i][j] + # 3. func: dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] + # 4. ret: dp[m-1][n-1] -Could you come up with an one-pass algorithm using only constant space? +All Previous work. No need to worry + def minPathSum_1(self, grid): + M = len(grid) + N = len(grid[0]) + dp = [[ 0 for j in range(N)] for i in range(M)] + dp[0][0] = grid[0][0] + for i in range(1, M): + dp[i][0] = dp[i-1][0] + grid[i][0] + for j in range(1, N): + dp[0][j] = dp[0][j-1] + grid[0][j] + for i in range(1, M): + for j in range(1, N): + dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j] + return dp[M-1][N-1] -```python + # Another time: + # dp[m][n] dp[i][j] + # M is the rows + # N is the cols + # [[for j in range(N)] for i in range(M)] + # M = len(grid) + # N = len(grid[0]) + + + Given the dynamic programming formula f[i][j]=min(f[i-1][j],f[i][j-1])+grid[i][j]: + + Assume that you are populating the table row by row, the current value (f[i][j]) will be used immediately in the calculation of f[i][j+1], so there is no need to store all the previous column values. + + Therefore, you can do it in linear space complexity. + + def minPathSum_2(self, grid): + M = len(grid) + N = len(grid[0]) + dp = [ 0 for j in range(N)] + dp[0] = grid[0][0] + for j in range(1, N): + dp[j] = dp[j-1] + grid[0][j] + for i in range(1, M): + dp[0] += grid[i][0] + for j in range(1, N): + dp[j] = min(dp[j], dp[j-1]) + grid[i][j] + + return dp[N-1] + + # This is a bit tricky. Read the above how to simplify this + # The key is we are doing this for j ... so we can just j-1 -class Solution: - # @param A a list of integers - # @return nothing, sort in place - def sortColors(self, A): - start = 0 - end = len(A) - 1 - cur = 0 - while cur <= end: - if A[cur] == 0: - A[start], A[cur] = A[cur], A[start] - cur += 1 - start += 1 - elif A[cur] == 1: - cur += 1 - else: - A[cur], A[end] = A[end], A[cur] - end -= 1 ``` ----- -### [120. Sort List](https://oj.leetcode.com/problems/sort-list/) +### [65. Valid Number](https://oj.leetcode.com/problems/valid-number/) -Sort a linked list in O(n log n) time using constant space complexity. +Validate if a given string is numeric. -```python +Some examples: +* "0" => true +* " 0.1 " => true +* "abc" => false +* "1 a" => false +* "2e10" => true -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None +Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. + +```python class Solution: - # @param head, a ListNode - # @return a ListNode - def sortList(self, head): - if not head or not head.next: - return head - mid = self.find_mid(head) - next_node = mid.next - mid.next = None - first_half = self.sortList(head) - second_half = self.sortList(next_node) - return self.merge_list(first_half, second_half) + # @param s, a string + # @return a boolean + def isNumber(self, s): + s = s.strip() + if len(s.split('e')) > 2 or len(s.split('E')) > 2: + return False - def merge_list(self, l1, l2): - dummy = ListNode(0) - cur = dummy - while l1 and l2: - if l1.val < l2.val: - cur.next = l1 - l1 = l1.next - else: - cur.next = l2 - l2 = l2.next - cur = cur.next - if l1: - cur.next = l1 - if l2: - cur.next = l2 - return dummy.next + if 'e' in s: + return self.isNumberwoE(s.split('e')[0]) and self.isNumberwoE(s.split('e')[1], False) + elif 'E' in s: + return self.isNumberwoE(s.split('E')[0]) and self.isNumberwoE(s.split('E')[1], False) + else: + return self.isNumberwoE(s) - def find_mid(self, head): - if not head or not head.next: - return head - slow = head - fast = head.next - while fast and fast.next: - slow = slow.next - fast = fast.next.next - return slow + def isNumberwoE(self, s, allow_digit = True): + has_num = False + for i, char in enumerate(s): + if i == 0 and char in ['+', '-']: + continue + if char == '.' and allow_digit: + allow_digit = False + continue + if char.isdigit(): + has_num = True + continue + return False + return has_num - # Way to think about this: - # 1. Split the list into first half and second half - # 2. Recursion sort the two half - # 3. Merge those two + # Note: + # 1. Strip white space + # 2. Check if multiple E/e, split by E/e + # 3. Check each part of num if they are valid with/wo digit + # 4. Things that can pass: + # i. i == 0 and char in ['+', '-'] + # ii. char.isdigit(), pass and set hasNum = True + # iii. char == '.': need to check if allow_digit + # Set all the rest cases to False ``` ----- -### [121. Spiral Matrix](https://oj.leetcode.com/problems/spiral-matrix/) - -Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. +### [66. Plus One](https://oj.leetcode.com/problems/plus-one/) -For example, -Given the following matrix: +Given a non-negative number represented as an array of digits, plus one to the number. -[ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] -] -You should return [1,2,3,6,9,8,7,4,5] +The digits are stored such that the most significant digit is at the head of the list. ```python class Solution: - # @param matrix, a list of lists of integers - # @return a list of integers - def spiralOrder(self, matrix): - M = len(matrix) - if len(matrix) == 0: - return [] - N = len(matrix[0]) - start_col = start_row = 0 - end_row = M - 1 - end_col = N - 1 - ret = [] - - while True: - for i in range(start_col, end_col + 1): - ret.append(matrix[start_row][i]) - start_row += 1 - if start_row > end_row: - break - for i in range(start_row, end_row + 1): - ret.append(matrix[i][end_col]) - end_col -= 1 - if start_col > end_col: - break - for i in range(start_col, end_col + 1)[::-1]: - ret.append(matrix[end_row][i]) - end_row -= 1 - if start_row > end_row: - break - for i in range(start_row, end_row + 1)[::-1]: - ret.append(matrix[i][start_col]) - start_col += 1 - if start_col > end_col: - break - return ret + # @param digits, a list of integer digits + # @return a list of integer digits + def plusOne(self, digits): + i = len(digits) - 1 + carry = 1 + while i >= 0 and carry == 1: # So many detail! No need to continue calculation if carry == 0 + s = digits[i] + carry # Calculate s first + digits[i] = s % 10 + carry = s / 10 + i -= 1 + if carry == 1: # Last check + digits.insert(0, 1) + return digits +``` +----- - # Note: - # This way is a lot better to memory +### [67. Add Binary](https://oj.leetcode.com/problems/add-binary/) + +Given two binary strings, return their sum (also a binary string). + +For example, +a = "11" +b = "1" +Return "100". + +```python + +class Solution: + # @param a, a string + # @param b, a string + # @return a string + def addBinary(self, a, b): + A = len(a) + B = len(b) + res = [] + carry = 0 + i = 1 + while i <= max(A,B): # using sum at first, then add bit if exist, this is good + sum = carry + if i <= A: + sum += int(a[-i]) + if i <= B: + sum += int(b[-i]) + bit = sum % 2 + carry = sum / 2 + i += 1 + res.insert(0, str(bit)) + if carry > 0: + res.insert(0, '1') + return ''.join(res) + # Nothing would be better than this ``` ----- -### [122. Spiral Matrix II](https://oj.leetcode.com/problems/spiral-matrix-ii/) +### [68. Text Justification](https://oj.leetcode.com/problems/text-justification/) -Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. +Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. + +You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly L characters. + +Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right. + +For the last line of text, it should be left justified and no extra space is inserted between words. For example, -Given n = 3, +words: ["This", "is", "an", "example", "of", "text", "justification."] +L: 16. -You should return the following matrix: +Return the formatted lines as: [ - [ 1, 2, 3 ], - [ 8, 9, 4 ], - [ 7, 6, 5 ] + "This is an", + "example of text", + "justification. " ] +Note: Each word is guaranteed not to exceed L in length. ```python class Solution: - # @return a list of lists of integer - def generateMatrix(self, n): - ret = [ [ 0 for i in range(n)] for j in range(n) ] - num = 1 - start_row = start_col = 0 - end_row = end_col = n - 1 - while True: - for i in range(start_col, end_col + 1): - ret[start_row][i] = num - num += 1 - start_row += 1 - if start_row > end_row: - break - - for i in range(start_row, end_row + 1): - ret[i][end_col] = num - num += 1 - end_col -= 1 - if start_col > end_col: - break + # @param words, a list of strings + # @param L, an integer + # @return a list of strings + def fullJustify(self, words, L): + cur_len = 0 + res = [] + ret = [] + for word in words: + if cur_len + len(word) + len(res) <= L: + res.append(word) + cur_len += len(word) + else: + if len(res) == 1: + ret.append(self.fill_spaces(res[0], L)) + else: + extra_spaces = L - cur_len - (len(res) - 1) + each_extra = extra_spaces / (len(res) - 1) + 1 + rest_spaces = extra_spaces % (len(res) - 1) + for i in range(rest_spaces): + res[i] += ' ' + line = (' ' * each_extra).join(res) + ret.append(line) + res = [] + res.append(word) + cur_len = len(word) + ret.append(self.fill_spaces(' '.join(res), L)) + return ret - for i in range(end_col, start_col - 1, -1): - ret[end_row][i] = num - num += 1 - end_row -= 1 - if start_row > end_row: - break + def fill_spaces(self, string, L): + length = len(string) + string += ' ' * (L - length) + return string - for i in range(end_row, start_row -1, -1): - ret[i][start_col] = num - num += 1 - start_col += 1 - if start_col > end_col: - break - # This is the old way - #if n%2 == 1: - # ret[start_col][start_row] = num - return ret + # Notice: + # 1. 算extra_spaces的时候是len(res) - 1 + # 2. 在each extra的后面+1算上必有的space + # 3. 可以用for循环做, 但是别忘了最后要reset res, cur_len + # 4. 最后是一定会append多余的一行的, line 49没必要再check了, 直接append + # 5. 把fill_space函数单独提出来比较合适 + # 6. Line 42 43 这里的思想要记住, 比较重要 ``` ----- -### [123. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) +### [69. Sqrtx](https://oj.leetcode.com/problems/sqrtx/) Implement int sqrt(int x). @@ -5715,1529 +5586,1670 @@ class Solution: ``` ----- -### [124. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) +### [6. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) -Implement atoi to convert a string to an integer. +The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) +``` +P A H N +A P L S I I G +Y I R +``` +And then read line by line: "PAHNAPLSIIGYIR" +Write the code that will take a string and make this conversion given a number of rows: -Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. +string convert(string text, int nRows); +convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR". -Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front. +```python -spoilers alert... click to show requirements for atoi. +class Solution: + # @return a string + def convert(self, s, nRows): + if nRows == 1: # Be careful about nRows ==1 + return s + size = 2 * nRows - 2 + n = len(s) / size + 1 + res = [] + for i in range(size): + if i == 0 or i == size / 2: + for j in range(n): + if j * size + i < len(s): + res.append(s[j*size+i]) + if i == size/2: + return ''.join(res) + else: + for j in range(n): + if j * size + i < len(s): + res.append(s[j*size+i]) + if (j+1) * size - i < len(s): + res.append(s[(j+1) * size - i]) +``` +----- + +### [70. Climbing Stairs](https://oj.leetcode.com/problems/climbing-stairs/) + +You are climbing a stair case. It takes n steps to reach to the top. + +Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? + +```python + +class Solution: + # @param n, an integer + # @return an integer + def climbStairs(self, n): + return self.climbStairs_2(n) + + def climbStairs_1(self, n): + if n <= 2: + return n + return self.climbStairs(n-1) + self.climbStairs(n-2) + + def climbStairs_2(self, n): + if n <= 1: + return n + dp = [ 0 for i in range(n)] + dp[0] = 1 + dp[1] = 2 + for i in range(2, n): + dp[i] = dp[i-1] + dp[i-2] + return dp[n-1] + + # Note: + # 1. dp[i] means from 0 to i-1 stair, how many ways to go + # 2. dp[0] = 1, dp[1] = 2 + # 3. dp[i] = d[i-1] + dp[i-2] + # 4. dp[N-1] + + def climbStairs_3(self, n): + if n <= 2: + return n + fn_1 = 1 + fn_2 = 2 + for i in range(3, n+1): + fn = fn_1 + fn_2 + fn_1 = fn + fn_2 = fn_1 + return fn + + # Note: + # DP way is the best, and no need to check if n <= 2 or not. +``` +----- + +### [71. Simplify Path](https://oj.leetcode.com/problems/simplify-path/) + +Given an absolute path for a file (Unix-style), simplify it. + +For example, +path = "/home/", => "/home" +path = "/a/./b/../../c/", => "/c" +click to show corner cases. + +Corner Cases: +Did you consider the case where path = "/../"? +In this case, you should return "/". +Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/". +In this case, you should ignore redundant slashes and return "/home/foo". + +```python + +class Solution: + # @param path, a string + # @return a string + def simplifyPath(self, path): + path_list = path.strip('/').split('/') + ret = [] + jump = 0 + for p in path_list[::-1]: + if p == '.' or p == '': + continue + elif p == '..': + jump += 1 + else: # p is a valid path + if jump > 0: + jump -= 1 + else: + ret.insert(0, p) + return '/'+'/'.join(ret) + # Note: + # 1. Remove dup '/', if using split(), // will become '', remove it + # 2. Keep in mind those two [::-1] + # 3. Don't forget to attach the first '/' +``` +----- -Requirements for atoi: -The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. +### [72. Edit Distance](https://oj.leetcode.com/problems/edit-distance/) -The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. +Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) -If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. +You have the following 3 operations permitted on a word: -If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned. +a) Insert a character +b) Delete a character +c) Replace a character ```python class Solution: # @return an integer - def atoi(self, str): - str = str.strip() - N = len(str) - if N == 0: - return 0 - sign = 1 - res = 0 - imin, imax = -1<<31, (1<<31)-1 - for i, bit in enumerate(str): - if i == 0 and bit in ['-', '+']: - if bit == '-': - sign = -1 - elif bit.isdigit(): - res = res*10 + int(bit) - if res * sign <= imin: - return imin - elif res * sign >= imax: - return imax - else: - break - return sign * res + def minDistance(self, word1, word2): + M = len(word1) + N = len(word2) + dp = [ [ 0 for j in range(N+1)] for i in range(M+1)] + for i in range(M+1): + for j in range(N+1): + if i == 0: + dp[0][j] = j + elif j == 0: + dp[i][0] = i + elif word1[i-1] == word2[j-1]: + dp[i][j] = dp[i-1][j-1] + else: + dp[i][j] = min( dp[i][j-1], dp[i-1][j], dp[i-1][j-1]) + 1 + return dp[M][N] + # Note: + # 1. dp[i][j] is Edit Distance of first i-1 chars in word1 with first j-1 chars in word2 + # 2. dp[0][j] = j, dp[i][0] = i + # 3. dp[i][j] = dp[i-1][j-1] # if word[i-1] == word[j-1] + # = min( dp[i][j-1], dp[i-1][j], dp[i-1][j-1]) + 1 # if word[i-1] != word[j-1] - # Don't forget to check sign at the beginning + # Note: + # 1. This dp is a bit diff, the length of dp is A+1, B+1 + # 2. Others are the same, remember how to initiate the dp matrix + # 3. When comparing the i, it compares with word[i-1] and word[j-1] + # This is not hard to think, since we start loop from 1 + # 4. Initial value of DP: add N chars for word1 + + # Transfer function: + # Target somestr1c -> somestr2d + # 1. Assume somestr1 -> somestr2 dp[i][j] + # 2. somestr1 -> somestr2d dp[i-1][j] + # 3. somestr1c -> somestr2 dp[i][j-1] + # 4. i. replace c with d: somestr1 -> somestr2 + 1 : dp[i-1][j-1] + 1 + # ii. append d to c : somestr1c -> somestr2 + 1 : dp[i][j-1] + 1 + # iii. delete c : somestr1 -> somestr2d + 1 : dp[i-1][j] + 1 ``` ----- -### [125. Subsets](https://oj.leetcode.com/problems/subsets/) +### [73. Set Matrix Zeroes](https://oj.leetcode.com/problems/set-matrix-zeroes/) -Given a set of distinct integers, S, return all possible subsets. +Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. -Note: -Elements in a subset must be in non-descending order. -The solution set must not contain duplicate subsets. -For example, -If S = [1,2,3], a solution is: +click to show follow up. -[ - [3], - [1], - [2], - [1,2,3], - [1,3], - [2,3], - [1,2], - [] -] +Follow up: +Did you use extra space? +A straight forward solution using O(mn) space is probably a bad idea. +A simple improvement uses O(m + n) space, but still not the best solution. +Could you devise a constant space solution? ```python class Solution: - # @param S, a list of integer - # @return a list of lists of integer - def subsets(self, S): - return self.subsets_2(S) + # @param matrix, a list of lists of integers + # RETURN NOTHING, MODIFY matrix IN PLACE. + def setZeroes(self, matrix): + n = len(matrix[0]) + m = len(matrix) + zero_row = False + zero_col = False - # Recursion method - def subsets_2(self, S): - ret = [] - self.subsets_helper(sorted(S), [], ret) - return ret + for i in range(m): + for j in range(n): + if matrix[i][j] == 0: + if i == 0: + zero_row = True + if j == 0: + zero_col = True + matrix[i][0] = matrix[0][j] = 0 - def subsets_helper(self, S, res, ret): - ret.append(res[:]) + for i in range(1, m): + for j in range(1, n): + if matrix[i][0] == 0 or matrix[0][j] == 0: + matrix[i][j] = 0 + if zero_col: + for i in range(m): + matrix[i][0] = 0 - for i, el in enumerate(S): - res.append(el) - self.subsets_helper(S[i+1:], res, ret) - res.pop() - # Keep in mind the sorted + if zero_row: + for j in range(n): + matrix[0][j] = 0 - # Iteration method - def subsets_1(self, S): - ret = [[]] - for i in sorted(S): - res = [] - for el in ret: - res.append(el[:]) - el.append(i) - res.append(el[:]) - ret = res[:] - return ret + return matrix ``` ----- -### [126. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) +### [74. Search a 2D Matrix](https://oj.leetcode.com/problems/search-a-2d-matrix/) -Given a collection of integers that might contain duplicates, S, return all possible subsets. +Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: -Note: -Elements in a subset must be in non-descending order. -The solution set must not contain duplicate subsets. +Integers in each row are sorted from left to right. +The first integer of each row is greater than the last integer of the previous row. For example, -If S = [1,2,2], a solution is: + +Consider the following matrix: [ - [2], - [1], - [1,2,2], - [2,2], - [1,2], - [] + [1, 3, 5, 7], + [10, 11, 16, 20], + [23, 30, 34, 50] ] +Given target = 3, return true. ```python class Solution: - # @param num, a list of integer - # @return a list of lists of integer - def subsetsWithDup(self, S): - return self.subsetsWithDup_2(S) - - # Iteration way - def subsetsWithDup_1(self, S): - ret = [[]] - for i in sorted(S): - res = [] - for el in ret: - if len(el) == 0 or el[-1] != i: # Check len(el) == 0 - res.append(el[:]) # if == 0 no el[-1] - el.append(i) # if el[-1] != 1, then append(el[:]) - res.append(el[:]) - ret = res - return ret - - # Recursion way - def subsetsWithDup_2(self, S): - ret = [] - self.subsetsWithDup_rec(sorted(S), [], ret) - return ret - - def subsetsWithDup_rec(self, S, res, ret): - ret.append(res[:]) + # @param matrix, a list of lists of integers + # @param target, an integer + # @return a boolean + def searchMatrix(self, matrix, target): + M = len(matrix) + N = len(matrix[0]) + start = 0 + end = M*N - 1 + while start <= end: + mid = (start+end) / 2 + i = mid / N + j = mid % N + if matrix[i][j] == target: + return True + elif matrix[i][j] < target: + start = mid + 1 + else: + end = mid - 1 + return False - for i, el in enumerate(S): - if i > 0 and S[i] == S[i-1]: - continue - res.append(el) - subsetsWithDup_rec(S[i+1:], res, ret) - res.pop() ``` ------ - -### [127. Substring with Concatenation of All Words](https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/) - -You are given a string, S, and a list of words, L, that are all of the same length. -Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters. +#####Search a 2D Matrix II +What if we allow duplicate in the matrix and need to find out all the posisitons +``` -For example, given: -S: "barfoothefoobarman" -L: ["foo", "bar"] +def search_matrix_II(matrix, target): + lb = search_for_bound(matrix, target, True) + if lb == -1: + return False + rb = search_for_bound(matrix, target, False) + res = [] + for i in range(lb, rb+1): + res.append((i/N, i%N)) + return res -You should return the indices: [0,9]. -(order does not matter). +def search_for_bound(matrix, target, is_lower_bound): + M = len(matrix) + N = len(matrix[0]) + start = 0 + end = M*N - 1 + while start + 1 < end: + mid = (start+end) / 2 + if matrix[mid/N][mid%N] == target: + if is_lower_bound: + end = mid + else: + start = mid + elif matrix[mid/N][mid%N] < target: + start = mid + else: + end = mid -```python + if is_lower_bound: + if matrix[start/N][start%N] == target: + return start + elif matrix[end/N][end%N] == target: + return end + else: + if matrix[end/N][end%N] == target: + return end + elif matrix[start/N][start%N] == target: + return start -class Solution: - # @param S, a string - # @param L, a list of string - # @return a list of integer - def findSubstring(self, S, L): - len_word = len(L[0]) - len_L = len(L) - len_S = len(S) - ret = [] - for i in range(len_S - len_word * len_L + 1): - list_S = [ S[j:j+len_word] for j in range(i, i + len_L*len_word, len_word)] - found = True - for word in L: - if word in list_S: - list_S.remove(word) - else: - found = False - break - if found: - ret.append(i) - return ret + return -1 - # Note - # 1. The idea is to slice S to S[i: i+len_L*len_word: len_word] and compare S's substring list with L - # Can improve it with i. replacing the list to dict increase search. ii. KMP - # 2. This is good enough. Can use KMP but it's too complicated. - # See http://c4fun.cn/blog/2014/03/20/leetcode-solution-02/#Substring_with_Concatenation_of_All_Words - # for KMP solution - # 3. Notice line 23, wrapping everything in the range is fast than calculate them in list comprehension +``` +Note: +1. from [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32775405.html) that answer check mid-1 == mid +2. I don't think this is a good way. So need to discuss here. +``` ``` ----- -### [128. Sudoku Solver](https://oj.leetcode.com/problems/sudoku-solver/) +### [75. Sort Colors](https://oj.leetcode.com/problems/sort-colors/) -Write a program to solve a Sudoku puzzle by filling the empty cells. +Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. -Empty cells are indicated by the character '.'. +Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. -You may assume that there will be only one unique solution. +Note: +You are not suppose to use the library's sort function for this problem. -```python +click to show follow up. -class Solution: - # @param board, a 9x9 2D array - # Solve the Sudoku by modifying the input board in-place. - # Do not return any value. - def solveSudoku(self, board): - self.solve(board, 0, 0) +Follow up: +A rather straight forward solution is a two-pass algorithm using counting sort. +First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's. - def solve(self, board, i, j): - i, j = self.getEmpty(board, i, j) - if i == 9: # Set end point - return True # These return valuse are very important - fill = self.getPossibleInput(board, i, j) - for f in fill: - board[i] = board[i][:j] + [f] + board[i][j+1:] # Python string is imutable, but this is weird - if self.solve(board, i, j): # in leetcode, don't know what is their input - return True - board[i] = board[i][:j] + ['.'] + board[i][j+1:] - return False +Could you come up with an one-pass algorithm using only constant space? - def getEmpty(self, board, i, j): - while i < 9 and j < 9 and board[i][j] != '.': - i += (j+1) / 9 # This is so qiao miao - j = (j+1) % 9 - return (i, j) +```python - def getPossibleInput(self, board, x, y): - fill = [str(i+1) for i in range(9)] # Note the type here - for i in range(9): - if board[x][i] in fill: - fill.remove(board[x][i]) - if board[i][y] in fill: - fill.remove(board[i][y]) - start_x = x / 3 * 3 - start_y = y / 3 * 3 - for i in range(3): - for j in range(3): - if board[start_x+i][start_y+j] in fill: - fill.remove(board[start_x+i][start_y+j]) - return fill +class Solution: + # @param A a list of integers + # @return nothing, sort in place + def sortColors(self, A): + start = 0 + end = len(A) - 1 + cur = 0 + while cur <= end: + if A[cur] == 0: + A[start], A[cur] = A[cur], A[start] + cur += 1 + start += 1 + elif A[cur] == 1: + cur += 1 + else: + A[cur], A[end] = A[end], A[cur] + end -= 1 ``` ----- -### [129. Sum Root to Leaf Numbers](https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/) - -Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. - -An example is the root-to-leaf path 1->2->3 which represents the number 123. +### [76. Minimum Window Substring](https://oj.leetcode.com/problems/minimum-window-substring/) -Find the total sum of all root-to-leaf numbers. +Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, +S = "ADOBECODEBANC" +T = "ABC" +Minimum window is "BANC". -``` - 1 - / \ - 2 3 -``` -The root-to-leaf path 1->2 represents the number 12. -The root-to-leaf path 1->3 represents the number 13. +Note: +If there is no such window in S that covers all characters in T, return the emtpy string "". -Return the sum = 12 + 13 = 25. +If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S. ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - class Solution: - # @param root, a tree node - # @return an integer - def sumNumbers(self, root): - return self.sumNumbers_2(root) - - def sumNumbers_1(self, root): - if root is None: - return 0 - ret = [0] - self.sumNumbers_helper(root, 0, ret) - return ret[0] - - def sumNumbers_helper(self, root, res, ret): - res = res * 10 + root.val - if root.left is None and root.right is None: # Found a leaf node - ret[0] += res - return - if root.left is not None: - self.sumNumbers_helper(root.left, res, ret) - if root.right is not None: - self.sumNumbers_helper(root.right, res, ret) + # @return a string + def minWindow(self, S, T): + N = len(S) + M = len(T) + wanted = {} + found = {} + for char in T: + wanted[char] = wanted.get(char, 0) + 1 + found[char] = 0 + l = 0 + res = '' + counter = 0 + for r in range(N): + if S[r] not in wanted: + continue - # Miracle to do this in one submit - # Now think about a way to do this without using list[0] + found[S[r]] += 1 + if found[S[r]] <= wanted[S[r]]: + counter += 1 - # Second way but this will reduce the check of root.left is None or root.right is None - def sumNumbers_2(self, root): - ret = [0] - self.sumNumbers_2_helper(root, 0, ret) - return ret[0] + if counter == M: + while l < r: + if S[l] not in wanted: + l += 1 + continue + if found[S[l]] > wanted[S[l]]: + found[S[l]] -= 1 + l += 1 + continue + break + if not res or len(res) > r - l + 1: + res = S[l:r+1] + return res - def sumNumbers_2_helper(self, root, res, ret): - if root is None: - return - res = root.val + res * 10 - if root.left is None and root.right is None: - ret[0] += res - return - self.sumNumbers_2_helper(root.left, res, ret) - self.sumNumbers_2_helper(root.right, res, ret) + # Note + # 1. Prepare for wo dict + # 2. Skip chars that we don't care, increase right bound + # 3. If current window contains all the chars we want(counter == M), stop and resize left bound + # 4. Skip chars that we don't care. If extra chars in found > wanted, skip them + # 5. break here + # 6. Calculate the current size ``` ----- -### [130. Surrounded Regions](https://oj.leetcode.com/problems/surrounded-regions/) - -Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. - -A region is captured by flipping all 'O's into 'X's in that surrounded region. - -For example, -``` -X X X X -X O O X -X X O X -X O X X -``` -After running your function, the board should be: -``` -X X X X -X X X X -X X X X -X O X X -``` - -```python - -class Solution: - # @param board, a 2D array - # Capture all regions by modifying the input board in-place. - # Do not return any value. - def solve(self, board): - if len(board) == 0 or len(board[0]) == 0: # This is sooooo keng - return board - M = len(board) - N = len(board[0]) - for i in range(M): - for j in range(N): - if i == 0 or i == M-1 or j == 0 or j == N-1: - self.bfs(board, i, j) - for i in range(M): - for j in range(N): - if board[i][j] == 'V': - board[i][j] = 'O' - elif board[i][j] == 'O': - board[i][j] = 'X' +### [77. Combinations](https://oj.leetcode.com/problems/combinations/) - def bfs(self, board, row, col): - if (board[row][col] != 'O'): - return - q = [] - q.append((row, col)) - while len(q) > 0: - i, j = q.pop(0) - if i < 0 or i >= len(board) or j < 0 or j >= len(board[0]): - continue - if board[i][j] != 'O': - continue - board[i][j] = 'V' - q.append((i-1, j)) - q.append((i+1, j)) - q.append((i, j-1)) - q.append((i, j+1)) +Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. - # DFS will cause stack overflow - def dfs(self, board, row, col): - if row < 0 or row >= len(board) or col < 0 or col >= len(board[0]): - return - if board[row][col] != 'O': - return - board[row][col] = 'V' - self.dfs(board, row+1, col) - self.dfs(board, row-1, col) - self.dfs(board, row, col+1) - self.dfs(board, row, col-1) +For example, +If n = 4 and k = 2, a solution is: - # Note: - # 1. For matrix/board problems, need to check if matrix/board == [], otherwise len(matrix[0]) will fail - # 2. DFS may cause stack overflow +[ + [2,4], + [3,4], + [2,3], + [1,2], + [1,3], + [1,4], +] + +```python + +class Solution: + # @return a list of lists of integers + def combine(self, n, k): + ret =[] + self.combine_helper(1, n, k, [], ret) + return ret + + def combine_helper(self, cur, n, k, res, ret): + if len(res) == k: + ret.append(res[:]) + return + for i in range(cur, n+1): + res.append(i) + self.combine_helper(i+1, n, k, res, ret) + res.pop() + # Need to notice the i+1 ``` ----- -### [131. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) +### [78. Subsets](https://oj.leetcode.com/problems/subsets/) -Given a linked list, swap every two adjacent nodes and return its head. +Given a set of distinct integers, S, return all possible subsets. +Note: +Elements in a subset must be in non-descending order. +The solution set must not contain duplicate subsets. For example, -Given 1->2->3->4, you should return the list as 2->1->4->3. +If S = [1,2,3], a solution is: -Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. +[ + [3], + [1], + [2], + [1,2,3], + [1,3], + [2,3], + [1,2], + [] +] ```python -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, x): -# self.val = x -# self.next = None - class Solution: - # @param a ListNode - # @return a ListNode - def swapPairs(self, head): - return self.swapPairs_3 + # @param S, a list of integer + # @return a list of lists of integer + def subsets(self, S): + return self.subsets_2(S) - def swapPairs_1(self, head): - dummy = ListNode(0) - dummy.next = head - prev = dummy - while head and head.next: - prev.next = head.next - head.next = head.next.next - prev.next.next = head - prev = head - head = head.next - return dummy.next + # Recursion method + def subsets_2(self, S): + ret = [] + self.subsets_helper(sorted(S), [], ret) + return ret - def swapPairs_2(self, head): - if head.next is None or head.next.next is None: - return - move = head.next.next - head.next.next = move.next - move.next = head.next.next - head.next = move - self.swapPairs_2(move.next) + def subsets_helper(self, S, res, ret): + ret.append(res[:]) - def swapPairs_3(self, head): - if head is None or head.next is None: - return head - first = head - second = head.next - first.next = second.next - second.next = first - first.next = self.swapPairs_3(first.next) - return second + for i, el in enumerate(S): + res.append(el) + self.subsets_helper(S[i+1:], res, ret) + res.pop() + # Keep in mind the sorted + + # Iteration method + def subsets_1(self, S): + ret = [[]] + for i in sorted(S): + res = [] + for el in ret: + res.append(el[:]) + el.append(i) + res.append(el[:]) + ret = res[:] + return ret ``` ----- -### [132. Symmetric Tree](https://oj.leetcode.com/problems/symmetric-tree/) +### [79. Word Search](https://oj.leetcode.com/problems/word-search/) -Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). +Given a 2D board and a word, find if the word exists in the grid. -For example, this binary tree is symmetric: +The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. +For example, +Given ``` - 1 - / \ - 2 2 - / \ / \ -3 4 4 3 -But the following is not: - 1 - / \ - 2 2 - \ \ - 3 3 +board = [ ["ABCE"], + ["SFCS"], + ["ADEE"] + ] ``` -Note: -Bonus points if you could solve it both recursively and iteratively. +word = "ABCCED", -> returns true, +word = "SEE", -> returns true, +word = "ABCB", -> returns false. ```python -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - class Solution: - # @param root, a tree node + # @param board, a list of lists of 1 length string + # @param word, a string # @return a boolean - def isSymmetric(self, root): - return self.isSymmetric_2(root) + def exist(self, board, word): + M = len(board) + N = len(board[0]) + for i in range(M): + for j in range(N): + if board[i][j] == word[0] and self.isWord(board, i, j, 0, word): + return True + return False - def isSymmetric_1(self, root): - if root is None: + def isWord(self, board, i, j, index, word): + if index == len(word): return True - return self.symmetric_helper(root.left, root.right) - def symmetric_helper(self, n1, n2): - if not n1 and not n2: - return True - if not n1 or not n2 or n1.val != n2.val: + M = len(board) + N = len(board[0]) + + if i < 0 or i >= M or j < 0 or j >= N or board[i][j] != word[index]: return False - return self.symmetric_helper(n1.left, n2.right) and self.symmetric_helper(n1.right, n2.left) - # No need to use two queues here, just one but pop twice would be fine - # Keep in mind which node should be pop first - def isSymmetric_2(self, root): - if root is None: - return True - queue = collections.deque() - queue.append(root.left) - queue.append(root.right) - while len(queue)>0: - t1 = queue.popleft() - t2 = queue.popleft() - if t1 is None and t2 is None: - continue - if t1 is None or t2 is None or t1.val != t2.val: - return False - queue.append(t1.left) - queue.append(t2.right) - queue.append(t1.right) - queue.append(t2.left) - return True + board[i][j] = '#' + if self.isWord(board, i+1, j, index+1, word) or \ + self.isWord(board, i-1, j, index+1, word) or \ + self.isWord(board, i, j+1, index+1, word) or \ + self.isWord(board, i, j-1, index+1, word): + return True + + board[i][j] = word[index] + + return False + + # Note: + # 1. Keep in mind the declare of matrix, M, N, board, board[0] + # 2. Line 28 check board[i][j] == word[0] + # 3. Use in place make board[i][j] = '#' and recover later + # 4. Line 43 line break use \ + # 5. Very important, must remark the 'visisted' part ``` ----- -### [133. Text Justification](https://oj.leetcode.com/problems/text-justification/) +### [7. Reverse Integer](https://oj.leetcode.com/problems/reverse-integer/) + +Reverse digits of an integer. + +Example1: x = 123, return 321 +Example2: x = -123, return -321 + +click to show spoilers. + +Have you thought about this? +Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! + +If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. + +Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases? + +Throw an exception? Good, but what if throwing an exception is not an option? You would then have to re-design the function (ie, add an extra parameter). -Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. +```python -You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly L characters. +class Solution: + # @return an integer + def reverse(self, x): + if x < 0: + return (-1) * self.reverse( (-1) * x) + res = 0 + while x > 0: + res = res*10 + x%10 + x /= 10 + return res +``` +----- -Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right. +### [80. Remove Duplicates from Sorted Array II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) -For the last line of text, it should be left justified and no extra space is inserted between words. +Follow up for "Remove Duplicates": +What if duplicates are allowed at most twice? For example, -words: ["This", "is", "an", "example", "of", "text", "justification."] -L: 16. +Given sorted array A = [1,1,1,2,2,3], -Return the formatted lines as: -[ - "This is an", - "example of text", - "justification. " -] -Note: Each word is guaranteed not to exceed L in length. +Your function should return length = 5, and A is now [1,1,2,2,3]. ```python class Solution: - # @param words, a list of strings - # @param L, an integer - # @return a list of strings - def fullJustify(self, words, L): - cur_len = 0 - res = [] - ret = [] - for word in words: - if cur_len + len(word) + len(res) <= L: - res.append(word) - cur_len += len(word) - else: - if len(res) == 1: - ret.append(self.fill_spaces(res[0], L)) - else: - extra_spaces = L - cur_len - (len(res) - 1) - each_extra = extra_spaces / (len(res) - 1) + 1 - rest_spaces = extra_spaces % (len(res) - 1) - for i in range(rest_spaces): - res[i] += ' ' - line = (' ' * each_extra).join(res) - ret.append(line) - res = [] - res.append(word) - cur_len = len(word) - ret.append(self.fill_spaces(' '.join(res), L)) - return ret + # @param A a list of integers + # @return an integer + def removeDuplicates(self, A): + if len(A) <= 2: + return len(A) + start = 1 + cur = 2 + while cur < len(A): + if A[cur] != A[start] or A[cur] != A[start-1]: + A[start+1] = A[cur] + start += 1 + cur+= 1 + return start+1 +``` +----- - def fill_spaces(self, string, L): - length = len(string) - string += ' ' * (L - length) - return string +### [81. Search in Rotated Sorted Array II](https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/) - # Notice: - # 1. 算extra_spaces的时候是len(res) - 1 - # 2. 在each extra的后面+1算上必有的space - # 3. 可以用for循环做, 但是别忘了最后要reset res, cur_len - # 4. 最后是一定会append多余的一行的, line 49没必要再check了, 直接append - # 5. 把fill_space函数单独提出来比较合适 - # 6. Line 42 43 这里的思想要记住, 比较重要 +Follow up for "Search in Rotated Sorted Array": +What if duplicates are allowed? + +Would this affect the run-time complexity? How and why? + +Write a function to determine if a given target is in the array. + +```python + +class Solution: + # @param A a list of integers + # @param target an integer + # @return a boolean + def search(self, A, target): + start = 0 + end = len(A) - 1 + while start <= end: + mid = (start + end) / 2 + if A[mid] == target: + return True + elif A[start] < A[mid]: # First half sorted + if A[start] <= target and target < A[mid]: + end = mid - 1 + else: + start = mid + 1 + elif A[start]> A[mid]: # Second half sorted + if A[mid] < target and target <= A[end]: + start = mid + 1 + else: + end = mid - 1 + else: + start += 1 + return False ``` ----- -### [134. Trapping Rain Water](https://oj.leetcode.com/problems/trapping-rain-water/) +### [82. Remove Duplicates from Sorted List II](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) -Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. +Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, -Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. - - -The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image! +Given 1->2->3->3->4->4->5, return 1->2->5. +Given 1->1->1->2->3, return 2->3. ```python +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + class Solution: - # @param A, a list of integers - # @return an integer - def trap(self, A): - N = len(A) - if N == 0: - return 0 - left_to_right = [0 for i in range(N)] - right_to_left = [0 for i in range(N)] - left_to_right[0] = A[0] - right_to_left[-1] = A[-1] + # @param head, a ListNode + # @return a ListNode + def deleteDuplicates(self, head): + if not head or not head.next: + return head + dummy = ListNode(0) + dummy.next = head + prev = dummy + cur = head.next + while cur: + if prev.next.val != cur.val: + prev = prev.next + cur = cur.next + else: + while cur and cur.val == prev.next.val: + cur = cur.next + prev.next = cur + if cur: + cur = cur.next + return dummy.next + # Better way to do this +``` +----- - for i in range(1, N): - left_to_right[i] = max(left_to_right[i-1], A[i]) - right_to_left[-i-1] = max(right_to_left[-i], A[-i-1]) +### [83. Remove Duplicates from Sorted List](https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/) - water = 0 - for i in range(N): - water += min(left_to_right[i], right_to_left[i]) - A[i] # Note here - return water +Given a sorted linked list, delete all duplicates such that each element appear only once. + +For example, +Given 1->1->2, return 1->2. +Given 1->1->2->3->3, return 1->2->3. + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + # @param head, a ListNode + # @return a ListNode + def deleteDuplicates(self, head): + if head is None or head.next is None: + return head + current = head + while current.next is not None: + if current.val == current.next.val: + current.next = current.next.next + else: + current = current.next + return head ``` ----- -### [135. Triangle](https://oj.leetcode.com/problems/triangle/) +### [84. Largest Rectangle in Histogram](https://oj.leetcode.com/problems/largest-rectangle-in-histogram/) -Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. +Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. -For example, given the following triangle -[ - [2], - [3,4], - [6,5,7], - [4,1,8,3] -] -The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). -Note: -Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle. +Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. + + +The largest rectangle is shown in the shaded area, which has area = 10 unit. + +For example, +Given height = [2,1,5,6,2,3], +return 10. ```python class Solution: - # @param triangle, a list of lists of integers + # @param height, a list of integer # @return an integer - def minimumTotal(self, triangle): - M = len(triangle) - N = len(triangle[-1]) - dp = [ [ 0 for j in range(N)] for i in range(M)] - for i in range(M)[::-1]: - for j in range(len(triangle[i])): - if i == M-1: - dp[i][j] = triangle[i][j] - else: - dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j] - return dp[0][0] - # Notes: - # This is not the best solution. But easier to understand - # 1. status: ```dp[x][y]```表示从bottom走到top每个坐标的最短路径 - # 2. function: dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j] - # 3. initialize: dp[-1][j] = triangle[-1][j] - # 4. answer: dp[0][0] - - #This is older way, but still pretty good - def minimumTotal_2(self, triangle): - n = len(triangle) - 1 - dp = triangle[n] - n -= 1 - while n >= 0: - for i in range(n+1): - dp[i] = triangle[n][i] + min(dp[i], dp[i+1]) - n -= 1 - return dp[0] - - # This look too simple - # Understand of this: - # 1. From bottom to top - # 2. transfer func: dp[i] = triangle[n][i] + min(dp[i], dp[i+1]) - # top level dp[i] = current triangle value + min(bottom level reachable dps) + def largestRectangleArea(self, height): + height.append(0) # append 0 to the end, used to find the last + N = len(height) + stack = [] + max_area = 0 + i = 0 + while i < N: + if len(stack) == 0 or height[i] >= height[stack[-1]]: + stack.append(i) + i += 1 + else: + index = stack.pop() # h = height[index] + if len(stack) == 0: + width = i # left bound = 0, right bound i-1, w = (i-1) - (0) + 1 = i + else: + width = i - stack[-1] - 1 # left bound = stack[-1] + 1, right bound = i-1, w = (i-1) - (stack[-1] + 1) + 1 = i - stack[-1] - 1 + max_area = max(max_area, width * height[index]) + return max_area ``` ----- -### [136. Two Sum](https://oj.leetcode.com/problems/two-sum/) +### [85. Maximal Rectangle](https://oj.leetcode.com/problems/maximal-rectangle/) -Given an array of integers, find two numbers such that they add up to a specific target number. - -The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. - -You may assume that each input would have exactly one solution. - -Input: numbers={2, 7, 11, 15}, target=9 -Output: index1=1, index2=2 +Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. ```python class Solution: - # @return a tuple, (index1, index2) - def twoSum(self, num, target): - return self.twoSum_3(num, target) - - # O(n^2) - def twoSum_1(self, num, target): - N = len(num) - for i in range(N-1): - for j in range(i+1, N): - if target == num[i] + num[j]: - return (num[i], num[j]) + # @param matrix, a list of lists of 1 length string + # @return an integer + def maximalRectangle(self, matrix): + if len(matrix) == 0 or len(matrix[0]) == 0: + return 0 + row = len(matrix) + col = len(matrix[0]) + h = [ 0 for i in range(col+1) ] + max_area = 0 + for i in range(row): + for j in range(col): + if matrix[i][j] == '0': + h[j] = 0 + else: + h[j] += 1 + max_area = max(max_area, self.largestRectangleArea(h)) + return max_area - # O(n) - def twoSum_2(self, num, target): - num_map = {} - for i, n in enumerate(num): - if target - n not in num_map: - num_map[n] = i + def largestRectangleArea(self, h): + stack = [] + max_area = 0 + i = 0 + while i < len(h): + if len(stack) == 0 or h[i] >= h[stack[-1]]: + stack.append(i) + i += 1 else: - return (num_map[target-n] + 1, i + 1) # Don't know why leetcode call the index [0] as 1 - - # O(nlgn) This is the best way, used in X Sum - def twoSum_3(self, num, target): - d = {} # This is used because we need to sort the array - for i, n in enumerate(num): - d.setdefault(n, []).append(i+1) - num = sorted(num) - l = 0 - r = len(num) - 1 - while l < r: - if num[l] + num[r] == target: - if num[l] == num[r]: - return (d[num[l]][0], d[num[r]][1]) + height = h[stack.pop()] + if len(stack) == 0: + width = i else: - return sorted((d[num[l]][0], d[num[r]][0])) - elif num[l] + num[r] < target: - l += 1 - else: - r -= 1 - - # Note: - # 1. Keep in mind we need to use a dict to store the original position. + width = i - stack[-1] - 1 + max_area = max(max_area, width * height) + return max_area ``` ----- -### [137. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) +### [86. Partition List](https://oj.leetcode.com/problems/partition-list/) -Given n, how many structurally unique BST's (binary search trees) that store values 1...n? +Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. + +You should preserve the original relative order of the nodes in each of the two partitions. For example, -Given n = 3, there are a total of 5 unique BST's. +Given 1->4->3->2->5->2 and x = 3, +return 1->2->2->4->3->5. ```python +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + class Solution: - # @return an integer - def numTrees(self, n): - dp = [0 for i in range(n+1)] - dp[0] = 1 - for i in range(1, n+1): - for j in range(0, i): - dp[i] += dp[j] * dp[i-j-1] - return dp[n] + # @param head, a ListNode + # @param x, an integer + # @return a ListNode + def partition(self, head, x): + before_dummy = ListNode(0) + after_dummy = ListNode(0) + before_cur = before_dummy + after_cur = after_dummy + while head is not None: + if head.val < x: + before_cur.next = head + before_cur = before_cur.next + head = head.next + before_cur.next = None + else: + after_cur.next = head + after_cur = after_cur.next + head = head.next + after_cur.next = None + if before_dummy.next is not None: + before_cur.next = after_dummy.next + return before_dummy.next + else: + return after_dummy.next + # Set None can be done for only last ``` ----- -### [138. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) +### [87. Scramble String](https://oj.leetcode.com/problems/scramble-string/) -Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. +Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. -For example, -Given n = 3, your program should return all 5 unique BST's shown below. +Below is one possible representation of s1 = "great": ``` - 1 3 3 2 1 - \ / / / \ \ - 3 2 1 1 3 2 - / / \ \ - 2 1 2 3 + great + / \ + gr eat + / \ / \ +g r e at + / \ + a t +To scramble the string, we may choose any non-leaf node and swap its two children. + +For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat". + + rgeat + / \ + rg eat + / \ / \ +r g e at + / \ + a t +We say that "rgeat" is a scrambled string of "great". + +Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae". + + rgtae + / \ + rg tae + / \ / \ +r g ta e + / \ + t a ``` +We say that "rgtae" is a scrambled string of "great". -```python +Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1. -# Definition for a binary tree node -# class TreeNode: -# def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None +```python class Solution: - # @return a list of tree node - def generateTrees(self, n): - nums = [ i for i in range(1, n+1)] - return self.generateTrees_helper(nums) + # @return a boolean + def isScramble(self, s1, s2): + if len(s1) != len(s2): + return False + if not self.hasSameLetter(s1, s2): + return False + if len(s1) <= 2: + return True + for i in range(1, len(s1)): + if ( self.isScramble(s1[:i], s2[:i]) and self.isScramble(s1[i:], s2[i:]) ) or ( self.isScramble(s1[:i], s2[-i:]) and self.isScramble(s1[i:], s2[:-i]) ): # This is soooo important, -i!!! + return True + return False - def generateTrees_helper(self, nums): - if not nums: - return [None] - res = [] - for i, num in enumerate(nums): - left = self.generateTrees_helper(nums[:i]) - right = self.generateTrees_helper(nums[i+1:]) - for l in left: - for r in right: - root = TreeNode(num) - root.left = l - root.right = r - res.append(root) - return res + def hasSameLetter(self, s1, s2): + if sorted(s1) != sorted(s2): + return False + return True + # Another way to do this in dp, need to learn +``` +----- - # Annie's DP way couldn't understand +### [88. Merge Sorted Array](https://oj.leetcode.com/problems/merge-sorted-array/) + +Given two sorted integer arrays A and B, merge B into A as one sorted array. + +Note: +You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m and n respectively. + +```python + +class Solution: + # @param A a list of integers + # @param m an integer, length of A + # @param B a list of integers + # @param n an integer, length of B + # @return nothing + def merge(self, A, m, B, n): + i = m - 1 + j = n - 1 + x = m + n - 1 + while i>=0 and j>=0: + if A[i] > B[j]: + A[x] = A[i] + i -= 1 + else: + A[x] = B[j] + j -= 1 + x -= 1 + while j>=0: + A[x] = B[j] + x -= 1 + j -= 1 + # Focus on detail!!! ``` ----- -### [139. Unique Paths](https://oj.leetcode.com/problems/unique-paths/) +### [89. Gray Code](https://oj.leetcode.com/problems/gray-code/) -A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). +The gray code is a binary numeral system where two successive values differ in only one bit. -The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). +Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. -How many possible unique paths are there? +For example, given n = 2, return [0,1,3,2]. Its gray code sequence is: -Above is a 3 x 7 grid. How many possible unique paths are there? +00 - 0 +01 - 1 +11 - 3 +10 - 2 +Note: +For a given n, a gray code sequence is not uniquely defined. -Note: m and n will be at most 100. +For example, [0,2,3,1] is also a valid gray code sequence according to the above definition. -```python +For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that. -class Solution: - # @return an integer - def uniquePaths(self, m, n): - dp = [ [0 for j in range(n)] for i in range(m) ] - for i in range(m): - for j in range(n): - if i == 0 or j == 0: - dp[i][j] = 1 - else: - dp[i][j] = dp[i-1][j] + dp[i][j-1] - return dp[m-1][n-1] +```python - # Note: - # 1. dp[i][j] means from (0,0) to (i, j) how many ways to finish - # 2. init dp[i][0] = 1, dp[0][j] = 1 - # 3. dp[i][j] = dp[i-1][j] + dp[i][j-1] - # 4. result dp[m-1][n-1] -``` ------ +# Tip: you can use bin(x) to check the binary form of a num -### [140. Unique Paths II](https://oj.leetcode.com/problems/unique-paths-ii/) +class Solution: + # @return a list of integers + def gray_code(self, n): + if n == 0: + return [0] + return [int(code, 2) for code in self.graycode_helper(n)] -Follow up for "Unique Paths": + def graycode_helper(self, n): + if n == 1: + return ['0', '1'] + prev_code = self.graycode_helper(n-1) + cur_code = [] + for code in prev_code: + cur_code.append('0' + code) + for code in prev_code[::-1]: + cur_code.append('1' + code) + return cur_code -Now consider if some obstacles are added to the grids. How many unique paths would there be? + # Using bit + def grayCode(self, n): + ret = [] + i = 0 + while i < 2**n: + ret.append(i>>1^i) + i+=1 + return ret -An obstacle and empty space is marked as 1 and 0 respectively in the grid. +# Using generator -For example, -There is one obstacle in the middle of a 3x3 grid as illustrated below. + def grayCodeGen(self, n, reverse=False): + if n == 1: + if reverse: + yield "1" + yield "0" + else: + yield "0" + yield "1" + else: + if reverse: + # all the "1"s start first + gcprev = self.grayCodeGen(n-1, False) + for code in gcprev: + yield "1" + code + gcprev = self.grayCodeGen(n-1, True) + for code in gcprev: + yield "0" + code + else: + # all the "0" start first + gcprev = self.grayCodeGen(n-1, False) + for code in gcprev: + yield "0" + code + gcprev = self.grayCodeGen(n-1, True) + for code in gcprev: + yield "1" + code -[ - [0,0,0], - [0,1,0], - [0,0,0] -] -The total number of unique paths is 2. +``` +----- -Note: m and n will be at most 100. +### [8. String to Integer atoi](https://oj.leetcode.com/problems/string-to-integer-atoi/) -```python +Implement atoi to convert a string to an integer. -class Solution: - # @param obstacleGrid, a list of lists of integers - # @return an integer - def uniquePathsWithObstacles(self, obstacleGrid): - if obstacleGrid[0][0] == 1: - return 0 - M = len(obstacleGrid) - N = len(obstacleGrid[0]) +Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. - dp = [ [0 for j in range(N)] for i in range(M) ] - for i in range(M): - for j in range(N): - if obstacleGrid[i][j] == 1: - dp[i][j] = 0 - elif i == 0 and j == 0: - dp[i][j] = 1 - elif i == 0: - dp[i][j] = dp[i][j-1] - elif j == 0: - dp[i][j] = dp[i-1][j] - else: - dp[i][j] = dp[i-1][j] + dp[i][j-1] - return dp[M-1][N-1] +Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front. - # Note: - # Same to unique path I but more steps to initialize -``` ------ +spoilers alert... click to show requirements for atoi. -### [141. Valid Number](https://oj.leetcode.com/problems/valid-number/) +Requirements for atoi: +The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. -Validate if a given string is numeric. +The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. -Some examples: -* "0" => true -* " 0.1 " => true -* "abc" => false -* "1 a" => false -* "2e10" => true +If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. -Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. +If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned. ```python class Solution: - # @param s, a string - # @return a boolean - def isNumber(self, s): - s = s.strip() - if len(s.split('e')) > 2 or len(s.split('E')) > 2: - return False - - if 'e' in s: - return self.isNumberwoE(s.split('e')[0]) and self.isNumberwoE(s.split('e')[1], False) - elif 'E' in s: - return self.isNumberwoE(s.split('E')[0]) and self.isNumberwoE(s.split('E')[1], False) - else: - return self.isNumberwoE(s) - - def isNumberwoE(self, s, allow_digit = True): - has_num = False - for i, char in enumerate(s): - if i == 0 and char in ['+', '-']: - continue - if char == '.' and allow_digit: - allow_digit = False - continue - if char.isdigit(): - has_num = True - continue - return False - return has_num + # @return an integer + def atoi(self, str): + str = str.strip() + N = len(str) + if N == 0: + return 0 + sign = 1 + res = 0 + imin, imax = -1<<31, (1<<31)-1 + for i, bit in enumerate(str): + if i == 0 and bit in ['-', '+']: + if bit == '-': + sign = -1 + elif bit.isdigit(): + res = res*10 + int(bit) + if res * sign <= imin: + return imin + elif res * sign >= imax: + return imax + else: + break + return sign * res - # Note: - # 1. Strip white space - # 2. Check if multiple E/e, split by E/e - # 3. Check each part of num if they are valid with/wo digit - # 4. Things that can pass: - # i. i == 0 and char in ['+', '-'] - # ii. char.isdigit(), pass and set hasNum = True - # iii. char == '.': need to check if allow_digit - # Set all the rest cases to False + # Don't forget to check sign at the beginning ``` ----- -### [142. Valid Palindrome](https://oj.leetcode.com/problems/valid-palindrome/) - -Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. +### [90. Subsets II](https://oj.leetcode.com/problems/subsets-ii/) -For example, -"A man, a plan, a canal: Panama" is a palindrome. -"race a car" is not a palindrome. +Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: -Have you consider that the string might be empty? This is a good question to ask during an interview. +Elements in a subset must be in non-descending order. +The solution set must not contain duplicate subsets. +For example, +If S = [1,2,2], a solution is: -For the purpose of this problem, we define empty string as valid palindrome. +[ + [2], + [1], + [1,2,2], + [2,2], + [1,2], + [] +] ```python class Solution: - # @param s, a string - # @return a boolean - def isPalindrome(self, s): - start = 0 - end = len(s) - 1 - while start < end: - while start < end and not s[start].isalnum(): - start += 1 - while start < end and not s[end].isalnum(): - end -= 1 - if s[start].lower() != s[end].lower(): - return False - start += 1 - end -= 1 - return True - # 1. isalnum() - # 2. lower() - # 3. no need to check len at the begining -``` ------ - -### [143. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) - -Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. + # @param num, a list of integer + # @return a list of lists of integer + def subsetsWithDup(self, S): + return self.subsetsWithDup_2(S) -The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. + # Iteration way + def subsetsWithDup_1(self, S): + ret = [[]] + for i in sorted(S): + res = [] + for el in ret: + if len(el) == 0 or el[-1] != i: # Check len(el) == 0 + res.append(el[:]) # if == 0 no el[-1] + el.append(i) # if el[-1] != 1, then append(el[:]) + res.append(el[:]) + ret = res + return ret -```python + # Recursion way + def subsetsWithDup_2(self, S): + ret = [] + self.subsetsWithDup_rec(sorted(S), [], ret) + return ret -class Solution: - # @return a boolean - def isValid(self, s): - bracket_dict = { '[' : ']', - '{' : '}', - '(' : ')', - } - stack = [] - for bracket in s: - if bracket in bracket_dict.keys(): - stack.append(bracket) - elif len(stack) == 0 or bracket !=bracket_dict[stack.pop()]: - return False - return len(stack) == 0 + def subsetsWithDup_rec(self, S, res, ret): + ret.append(res[:]) - # Note return len(stack) == 0 not True! + for i, el in enumerate(S): + if i > 0 and S[i] == S[i-1]: + continue + res.append(el) + subsetsWithDup_rec(S[i+1:], res, ret) + res.pop() ``` ----- -### [144. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) +### [91. Decode Ways](https://oj.leetcode.com/problems/decode-ways/) -Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. - -The Sudoku board could be partially filled, where empty cells are filled with the character '.'. +A message containing letters from A-Z is being encoded to numbers using the following mapping: +'A' -> 1 +'B' -> 2 +... +'Z' -> 26 +Given an encoded message containing digits, determine the total number of ways to decode it. -A partially filled sudoku which is valid. +For example, +Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12). -Note: -A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated. +The number of ways decoding "12" is 2. ```python class Solution: - # @param board, a 9x9 2D array - # @return a boolean - def isValidSudoku(self, board): - for i in range(9): - row = [] - col = [] - for j in range(9): - if board[i][j] != '.' and board[i][j] not in row: - row.append(board[i][j]) - elif board[i][j] in row: - return False - if board[j][i] != '.' and board[j][i] not in col: - col.append(board[j][i]) - elif board[j][i] in col: - return False + # @param s, a string + # @return an integer + def numDecodings(self, s): + N = len(s) + if N == 0 or s[0] == '0': + return 0 + dp = [0 for i in range(N+1)] + dp[0] = 1 + dp[1] = 1 + for i in range(2, N+1): + if s[i-1] == '0' and s[i-2] not in ['1', '2']: + return 0 + if s[i-1] != '0': + dp[i] += dp[i-1] + if 10 <= int(s[i-2: i]) <= 26: + dp[i] += dp[i-2] + return dp[N] - for i in range(0,9,3): - for j in range(0,9,3): - square = [] - for x in range(3): - for y in range(3): - if board[i+x][j+y] != '.' and board[i+x][j+y] not in square: - square.append(board[i+x][j+y]) - elif board[i+x][j+y] in square: - return False - return True + # Note: + # 1. State: dp[i] means from char 0 to char i-1 how many decode ways + # 2. Init: dp[0] = 1; dp[1] = 1 + # 3. Function: + # dp[i] = if s[i-1] == 0 and s[i-2] not in ['1', '2'] : return 0 + # if s[i-1] != 0 : += dp[i-1] + # if 10 <= int(s[i-2:i]) <= 26 : += dp[i-2] + # 4. Result: dp[N] + + # i. dp size is len(s)+1 + # ii. 10 <= x <= 26 + # iii. use if += instead of if dp = xx else dp = xx + + # Another idea + def numDecodings_2(self, s): + if s == '' or s[0] == '0': return 0 + dp = [1, 1] + length = len(s) + for i in xrange(2, length + 1): + if 10 <= int(s[i-2:i]) <= 26 and '1' <= s[i-1] <= '9': + dp.append(dp[i-1] + dp[i-2]) + elif 10 <= int(s[i-2:i]) <= 26: # s[i-1] == '0' + dp.append(dp[i-2]) + elif '1' <= s[i-1] <= '9': + dp.append(dp[i-1]) + else: # s[i] == '0' + return 0 + return dp[length] ``` ----- -### [145. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) +### [92. Reverse Linked List II](https://oj.leetcode.com/problems/reverse-linked-list-ii/) -Given a binary tree, determine if it is a valid binary search tree (BST). +Reverse a linked list from position m to n. Do it in-place and in one-pass. -Assume a BST is defined as follows: +For example: +Given 1->2->3->4->5->NULL, m = 2 and n = 4, -The left subtree of a node contains only nodes with keys less than the node's key. -The right subtree of a node contains only nodes with keys greater than the node's key. -Both the left and right subtrees must also be binary search trees. +return 1->4->3->2->5->NULL. + +Note: +Given m, n satisfy the following condition: +1 ≤ m ≤ n ≤ length of list. ```python -# Definition for a binary tree node -# class TreeNode: +# Definition for singly-linked list. +# class ListNode: # def __init__(self, x): # self.val = x -# self.left = None -# self.right = None +# self.next = None class Solution: - # @param root, a tree node - # @return a boolean - def isValidBST(self, root): - return self.isValidBST_1(root) - - def isValidBST_1(self, root): # sys.maxint and -sys.maxint-1 - return self.isValidBST_helper_1(root, -9223372036854775808, 9223372036854775807) - - def isValidBST_helper_1(self, root, min, max): - if root is None: - return True - if root.val <= min or root.val >= max: - return False - return self.isValidBST_helper_1(root.left, min, root.val) and self.isValidBST_helper_1(root.right, root.val, max) - - -This won't pass - def isValidBST_2(self, root): - return self.isValidBST_helper_2(root, -9223372036854775808) - - def isValidBST_helper_2(self, root, val): - if root is None: - return True - if root.left is not None and not self.isValidBST_helper_2(root.left, val): - return False - if root.val <= val: - return False - val = root.val - if root.right is not None and not self.isValidBST_helper_2(root.right, val): - return False - return True - + # @param head, a ListNode + # @param m, an integer + # @param n, an integer + # @return a ListNode + def reverseBetween(self, head, m, n): + dummy = ListNode(0) + dummy.next = head + start = dummy + i = 1 + while i < m: + start = start.next + i += 1 + cur = start.next + while i < n: + move = cur.next + cur.next = move.next + move.next = start.next + start.next = move + i += 1 + return dummy.next + # Notice the m and n ``` ----- -### [146. Wildcard Matching](https://oj.leetcode.com/problems/wildcard-matching/) - -Implement wildcard pattern matching with support for '?' and '*'. - -'?' Matches any single character. -'*' Matches any sequence of characters (including the empty sequence). +### [93. Restore IP Addresses](https://oj.leetcode.com/problems/restore-ip-addresses/) -The matching should cover the entire input string (not partial). +Given a string containing only digits, restore it by returning all possible valid IP address combinations. -The function prototype should be: -bool isMatch(const char *s, const char *p) +For example: +Given "25525511135", -Some examples: -isMatch("aa","a") -> false -isMatch("aa","aa") -> true -isMatch("aaa","aa") -> false -isMatch("aa", "*") -> true -isMatch("aa", "a*") -> true -isMatch("ab", "?*") -> true -isMatch("aab", "c*a*b") -> false +return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) ```python class Solution: - # @param s, an input string - # @param p, a pattern string - # @return a boolean - def isMatch(self, s, p): - i = 0 - j = 0 - backupS = -1 - backupP = -1 - while i < len(s): - if j < len(p) and (p[j] == '?' or s[i] == p[j]): # Move to next if s[i] == p[j] or p[j] == '?' - i += 1 - j += 1 - elif j < len(p) and p[j] == '*': # Backup if p[j] == '*'. Keep s but move p - j += 1 - backupS = i - backupP = j - else: # No match - if backupP == -1: # if no backup, return false - return False - backupS += 1 # Have a backup, move backupS, restore all the backup - i = backupS - j = backupP + # @param s, a string + # @return a list of strings + def restoreIpAddresses(self, s): + ret = [] + self.restoreIpAddresses_helper(s, [], ret) + return ret + + def restoreIpAddresses_helper(self, s, res, ret): + if len(res) == 4 and len(s) == 0: + ret.append('.'.join(res)) + if len(res) >= 4 or len(s) == 0: + return + + for i in range(1, min(3,len(s))+1): + if ( 0 <= int(s[:i]) < 256 and s[:i][0]!= '0' ) or ( int(s[:i]) == 0 and len(s[:i]) == 1): + res.append(s[:i]) + self.restoreIpAddresses_helper(s[i:], res, ret) + res.pop() - while j < len(p) and p[j] == '*': - j += 1 - return j == len(p) # and i == len(s) - # Note - # 1. Line 47 can be removed because when it's out of loop, i must == len(s) - # 2. Line 39 doens't matter if it is backupS or backupP + # Note the check: + # 1. 0<= ip < 255 + # 2. ip shouldn't like 001, 000 ``` ----- -### [147. Word Break](https://oj.leetcode.com/problems/word-break/) +### [94. Binary Tree Inorder Traversal](https://oj.leetcode.com/problems/binary-tree-inorder-traversal/) -Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. +Given a binary tree, return the inorder traversal of its nodes' values. -For example, given -s = "leetcode", -dict = ["leet", "code"]. +For example: +Given binary tree {1,#,2,3}, +``` + 1 + \ + 2 + / + 3 +``` +return [1,3,2]. -Return true because "leetcode" can be segmented as "leet code". +Note: Recursive solution is trivial, could you do it iteratively? ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param s, a string - # @param dict, a set of string - # @return a boolean - def wordBreak(self, s, dict): - return self.wordBreak_1(s, dict) + # @param root, a tree node + # @return a list of integers + def inorderTraversal(self, root): + return self.inorderTraversal_1(root) - def wordBreak_1(self, s, dict): - N = len(s) - dp = [False for i in range(N+1)] - dp[0] = True - for i in range(1, N+1): - for j in range(i): - if dp[j] and s[j:i] in dict: - dp[i] = True - break - return dp[N] - # Note: - # 1. dp[i] means from first i-1 chars can be break - # 2. dp[0] = True - # 3. dp[i] = for j in (i-1, ... 0) if dp[j] and s[j:i] in dict - # 4. dp[N] !!! Very important here it's N not N-1 + def inorderTraversal_1(self, root): + stack = [] + current = root + res = [] + while current is not None or len(stack) > 0: + if current is not None: + stack.append(current) + current = current.left + elif len(stack) > 0: + current = stack.pop() + res.append(current.val) + current = current.right + return res + + def inorderTraversal_2(self, root): + res = [] + self.inorderTraversal_rec(root, res) + return res + + def inorderTraversal_rec(self, root, res): + if root is None: + return + self.inorderTraversal_rec(root.left, res) + res.append(root.val) + self.inorderTraversal_rec(root.right, res) ``` ----- -### [148. Word Break II](https://oj.leetcode.com/problems/word-break-ii/) +### [95. Unique Binary Search Trees II](https://oj.leetcode.com/problems/unique-binary-search-trees-ii/) -Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. - -Return all such possible sentences. +Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. -For example, given -s = "catsanddog", -dict = ["cat", "cats", "and", "sand", "dog"]. +For example, +Given n = 3, your program should return all 5 unique BST's shown below. -A solution is ["cats and dog", "cat sand dog"]. +``` + 1 3 3 2 1 + \ / / / \ \ + 3 2 1 1 3 2 + / / \ \ + 2 1 2 3 +``` ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param s, a string - # @param dict, a set of string - # @return a list of strings - def wordBreak(self, s, dict): - ret = [] - dp = [True for i in range(len(s))] - self.wordBreak_helper(0, s, dict, [], ret, dp) - return ret + # @return a list of tree node + def generateTrees(self, n): + nums = [ i for i in range(1, n+1)] + return self.generateTrees_helper(nums) - def wordBreak_helper(self, start, s, dict, res, ret, dp): - if start == len(s): - ret.append(' '.join(res)) - return - for i in range(start+1, len(s)+1): - if s[start:i] in dict and dp[i-1]: - res.append(s[start:i]) - beforeChange = len(ret) - self.wordBreak_helper(i, s, dict, res, ret, dp) - if beforeChange == len(ret): - dp[i-1] = False - res.pop() + def generateTrees_helper(self, nums): + if not nums: + return [None] + res = [] + for i, num in enumerate(nums): + left = self.generateTrees_helper(nums[:i]) + right = self.generateTrees_helper(nums[i+1:]) + for l in left: + for r in right: + root = TreeNode(num) + root.left = l + root.right = r + res.append(root) + return res + # Annie's DP way couldn't understand ``` +----- -这两种方法本质上没有区别 -* 前者是如果运行dfs之后结果没有变化,说明没有搜到,后面也不用搜了 -* 后者是预处理dp然后用在recursion之中 - -```python +### [96. Unique Binary Search Trees](https://oj.leetcode.com/problems/unique-binary-search-trees/) - def wordBreak(self, s, dict): - ret = [] - dp = self.word_break_dp(s, dict) - self.dfs_word_break(len(s)+1, s, dict, [], ret, dp) - return ret +Given n, how many structurally unique BST's (binary search trees) that store values 1...n? - def word_break_dp(self, s, dict): - N = len(s) - dp = [False for i in range(N+1)] - dp[0] = True - for i in range(N): - for j in range(i): - if dp[j] and s[j:i]: - dp[i] = True - break - return dp +For example, +Given n = 3, there are a total of 5 unique BST's. - def dfs_word_break(self, end, s, dict, res, ret, dp): - if end == 0: - ret.append(' '.join(res)) - return - for i in range(end): - if dp[i] and s[i:end] in dict: - res.insert(0, s[i:end]) # Note this is insert(0) - self.dfs_word_break(i, s, dict, res, ret, dp) - res.pop(0) # So this is pop(0) +```python - # dict = ["cat", "cats", "and", "sand", "dog"] - # s = "catsanddog" - # print wordBreak(s, dict) +class Solution: + # @return an integer + def numTrees(self, n): + dp = [0 for i in range(n+1)] + dp[0] = 1 + for i in range(1, n+1): + for j in range(0, i): + dp[i] += dp[j] * dp[i-j-1] + return dp[n] ``` ----- -### [149. Word Ladder](https://oj.leetcode.com/problems/word-ladder/) +### [97. Interleaving String](https://oj.leetcode.com/problems/interleaving-string/) -Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: +Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. -Only one letter can be changed at a time -Each intermediate word must exist in the dictionary For example, - Given: -start = "hit" -end = "cog" -dict = ["hot","dot","dog","lot","log"] -As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", -return its length 5. +s1 = "aabcc", +s2 = "dbbca", -Note: -Return 0 if there is no such transformation sequence. -All words have the same length. -All words contain only lowercase alphabetic characters. +When s3 = "aadbbcbcac", return true. +When s3 = "aadbbbaccc", return false. ```python + class Solution: - # @param start, a string - # @param end, a string - # @param dict, a set of string - # @return an integer - def ladderLength(self, start, end, dict): - queue = collections.deque([start]) - N = len(start) - length = 1 - while len(queue) > 0: - size = len(queue) - for i in range(size): - word = queue.popleft() - if word == end: - return length - for i in range(N): - for char in 'abcdefghijklmnopqrstuvwxyz': - new_word = word[:i] + char + word[i+1:] - if new_word in dict: - queue.append(new_word) - dict.remove(new_word) - length += 1 - return 0 + # @return a boolean + def isInterleave(self, s1, s2, s3): + return self.isInterleave_1(s1, s2, s3) + + def isInterleave_1(self, s1, s2, s3): + M = len(s1) + N = len(s2) + K = len(s3) + if M + N != K: + return False + dp = [ [ False for j in range(N+1)] for i in range(M+1) ] + for i in range(M+1): + for j in range(N+1): + if i == 0 and j == 0: + dp[i][j] = True + elif i > 0 and dp[i-1][j] and s1[i-1] == s3[i-1+j]: + dp[i][j] = True + elif j > 0 and dp[i][j-1] and s2[j-1] == s3[i+j-1]: + dp[i][j] = True + else: + dp[i][j] = False + return dp[M][N] + + # Note: + # 1. dp[i][j] means whether s1[:i] and s2[:j] is interleave with s3[:i+j] + # 2. dp[0...M][0...N] = False + # 3. dp[i][j] = True # if dp[i-1][j] == True and s1[i-1] == s3[i-1+j] or + # dp[i][j-1] == True and s2[j-1] == s3[i+j-1] + # = False # else + # 4. dp[M][N] + + # Will TLE + def isInterleave_2(self, s1, s2, s3): + return self.isInterleave_re(s1, 0, s2, 0, s3, 0) + + def isInterleave_re(self, s1, i1, s2, i2, s3, i3): + if i1 >= len(s1) and i2 >= len(s2) and i3 >= len(s3): + return True + if i3 >= len(s3): + return False + if i1 >= len(s1): + return s2[i2:] == s3[i3:] + if i2 >= len(s2): + return s1[i1:] == s3[i3:] + + return (s1[i1] == s3[i3] and self.isInterleave_re(s1, i1+1, s2, i2, s3, i3+1)) or (s2[i2] == s3[i3] and self.isInterleave_re(s1, i1, s2, i2+1, s3, i3+1)) ``` ----- -### [150. Word Ladder II](https://oj.leetcode.com/problems/word-ladder-ii/) +### [98. Validate Binary Search Tree](https://oj.leetcode.com/problems/validate-binary-search-tree/) -Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: +Given a binary tree, determine if it is a valid binary search tree (BST). -Only one letter can be changed at a time -Each intermediate word must exist in the dictionary -For example, +Assume a BST is defined as follows: -Given: -start = "hit" -end = "cog" -dict = ["hot","dot","dog","lot","log"] -Return - [ - ["hit","hot","dot","dog","cog"], - ["hit","hot","lot","log","cog"] - ] -Note: -All words have the same length. -All words contain only lowercase alphabetic characters. +The left subtree of a node contains only nodes with keys less than the node's key. +The right subtree of a node contains only nodes with keys greater than the node's key. +Both the left and right subtrees must also be binary search trees. ```python +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + class Solution: - # @param start, a string - # @param end, a string - # @param dict, a set of string - # @return a list of lists of string - def findLadders(self, start, end, dict): - trace_back = { word: [] for word in dict} - prev_level = set([start]) - found = False - while len(prev_level) > 0 and not found: - cur_level = set([]) - size = len(prev_level) - for word in prev_level: - dict.remove(word) - for word in prev_level: - if word == end: - found = True - for i in range(len(word)): - for char in 'abcdefghijklmnopqrstuvwxyz': - new_word = word[:i] + char + word[i+1:] - if new_word in dict: - trace_back[new_word].append(word) - cur_level.add(new_word) - prev_level = cur_level - paths = [] - if found: - self.find_traceback(end, trace_back, [], paths) - return paths + # @param root, a tree node + # @return a boolean + def isValidBST(self, root): + return self.isValidBST_1(root) - def find_traceback(self, word, trace, cur_path, paths): - if len(trace[word]) == 0: - paths.append([word] + cur_path) - return - for prev_word in trace[word]: - self.find_traceback(prev_word, trace, [word] + cur_path, paths) + def isValidBST_1(self, root): # sys.maxint and -sys.maxint-1 + return self.isValidBST_helper_1(root, -9223372036854775808, 9223372036854775807) - # Note: - # 1. while loop is doing a BFS - # 2. find_traceback is doing a DFS from the end traceback to start -``` ------ + def isValidBST_helper_1(self, root, min, max): + if root is None: + return True + if root.val <= min or root.val >= max: + return False + return self.isValidBST_helper_1(root.left, min, root.val) and self.isValidBST_helper_1(root.right, root.val, max) -### [151. Word Search](https://oj.leetcode.com/problems/word-search/) -Given a 2D board and a word, find if the word exists in the grid. +This won't pass + def isValidBST_2(self, root): + return self.isValidBST_helper_2(root, -9223372036854775808) -The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. + def isValidBST_helper_2(self, root, val): + if root is None: + return True + if root.left is not None and not self.isValidBST_helper_2(root.left, val): + return False + if root.val <= val: + return False + val = root.val + if root.right is not None and not self.isValidBST_helper_2(root.right, val): + return False + return True -For example, -Given ``` -board = [ ["ABCE"], - ["SFCS"], - ["ADEE"] - ] -``` -word = "ABCCED", -> returns true, -word = "SEE", -> returns true, -word = "ABCB", -> returns false. +----- -```python +### [99. Recover Binary Search Tree](https://oj.leetcode.com/problems/recover-binary-search-tree/) -class Solution: - # @param board, a list of lists of 1 length string - # @param word, a string - # @return a boolean - def exist(self, board, word): - M = len(board) - N = len(board[0]) - for i in range(M): - for j in range(N): - if board[i][j] == word[0] and self.isWord(board, i, j, 0, word): - return True - return False +Two elements of a binary search tree (BST) are swapped by mistake. - def isWord(self, board, i, j, index, word): - if index == len(word): - return True +Recover the tree without changing its structure. - M = len(board) - N = len(board[0]) +Note: +A solution using O(n) space is pretty straight forward. Could you devise a constant space solution? - if i < 0 or i >= M or j < 0 or j >= N or board[i][j] != word[index]: - return False +```python - board[i][j] = '#' - if self.isWord(board, i+1, j, index+1, word) or \ - self.isWord(board, i-1, j, index+1, word) or \ - self.isWord(board, i, j+1, index+1, word) or \ - self.isWord(board, i, j-1, index+1, word): - return True +# Definition for a binary tree node +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None - board[i][j] = word[index] +class Solution: + # @param root, a tree node + # @return a tree node + def recoverTree(self, root): + self.last = None + self.wrongs = [None, None] + self.recover_helper(root) + self.wrongs[0].val, self.wrongs[1].val = self.wrongs[1].val, self.wrongs[0].val + return root - return False + def recover_helper(self, root): + if not root: + return + self.recover_helper(root.left) + if self.last and self.last.val > root.val: + if not self.wrongs[0]: + self.wrongs[0] = self.last + self.wrongs[1] = root + self.last = root + + self.recover_helper(root.right) # Note: - # 1. Keep in mind the declare of matrix, M, N, board, board[0] - # 2. Line 28 check board[i][j] == word[0] - # 3. Use in place make board[i][j] = '#' and recover later - # 4. Line 43 line break use \ - # 5. Very important, must remark the 'visisted' part + # 1. Very normal inorder traversal + # 2. Notice line 32,33. Always update wrongs[1], but wrongs[0] will only update one time + # Reason is image [1,2,3,4,5,6], swap to [1,2,6,4,5,3] + # We will find out 6 > 4 and 5 > 3 + # So first time we should update wrongs[0] = last, + # second time we should update wrongs[1] = root + # But line 34 first time we also update wrong[1] because if we have [1,2,4,3,5,6] + # 4 is next to 3 so we need to update them at the same time ``` ----- -### [152. ZigZag Conversion](https://oj.leetcode.com/problems/zigzag-conversion/) +### [9. Palindrome Number](https://oj.leetcode.com/problems/palindrome-number/) -The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) -``` -P A H N -A P L S I I G -Y I R -``` -And then read line by line: "PAHNAPLSIIGYIR" -Write the code that will take a string and make this conversion given a number of rows: +Determine whether an integer is a palindrome. Do this without extra space. -string convert(string text, int nRows); -convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR". +click to show spoilers. + +Some hints: +Could negative integers be palindromes? (ie, -1) No! + +If you are thinking of converting the integer to string, note the restriction of using extra space. + +You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that the reversed integer might overflow. How would you handle such case? + +There is a more generic way of solving this problem. ```python class Solution: - # @return a string - def convert(self, s, nRows): - if nRows == 1: # Be careful about nRows ==1 - return s - size = 2 * nRows - 2 - n = len(s) / size + 1 - res = [] - for i in range(size): - if i == 0 or i == size / 2: - for j in range(n): - if j * size + i < len(s): - res.append(s[j*size+i]) - if i == size/2: - return ''.join(res) - else: - for j in range(n): - if j * size + i < len(s): - res.append(s[j*size+i]) - if (j+1) * size - i < len(s): - res.append(s[(j+1) * size - i]) + # @return a boolean + def isPalindrome(self, x): + if x < 0: + return False + div = 10 + while x > div: + div *= 10 + div /= 10 + while x > 0: + if x / div != x % 10: + return False + x = (x % div) / 10 + div /= 100 + return True ``` ----- -### 153. Absolute Minimum +### 153. ['Absolute', 'Minimum'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32782345.html) for Amazon Interview Given three arrays A,B,C containing unsorted numbers. Find three numbers a, @@ -7283,7 +7295,7 @@ def get_min_distance(A1, A2, A3): ``` ----- -### 154. Alternating Positive N Negative +### 154. ['Alternating', 'Positive', 'N', 'Negative'] or Rearrange Array Alternating Positive Negative Items Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance. @@ -7368,7 +7380,7 @@ print rearrange_array_rotate(B) ``` ----- -### 155. BFS DFS +### 155. ['BFS', 'DFS'] #####Summarize all kind of ways to do Tree Traversal * BFS @@ -7604,7 +7616,7 @@ print_tree_as_list(head) ``` ----- -### 156. Binary Tree Level K Nodes +### 156. ['Binary', 'Tree', 'Level', 'K', 'Nodes'] #####From [blog](http://blog.csdn.net/luckyxiaoqiang/article/details/7518888#topic6) @@ -7635,7 +7647,7 @@ print get_kth_level_nodes(root, 5) ``` ----- -### 157. Blocking Queue +### 157. ['Blocking', 'Queue'] #####From Tango Interview Challenge This is pretty important design pattern, including the knowledge of thread @@ -7752,7 +7764,7 @@ random_result() ``` ----- -### 158. Coin Change +### 158. ['Coin', 'Change'] #####From [Geeksforgeeks](http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/) @@ -7787,7 +7799,7 @@ print coin_change(5) ``` ----- -### 159. Consecutive Subarray +### 159. ['Consecutive', 'Subarray'] #####Interview With Cyan 1. Shortest Path @@ -7839,7 +7851,7 @@ print find_consecutive(num, sum) ``` ----- -### 161. Count zeros in Factorial +### 161. ['Count', 'zeros', 'in', 'Factorial'] From mitbbs for Facebook @@ -7868,7 +7880,7 @@ print fact(N) ``` ----- -### 162. Delete a Node in BST +### 162. ['Delete', 'a', 'Node', 'in', 'BST'] [Solution](http://answer.ninechapter.com/solutions/delete-a-node-in-binary-search-tree/) 实际上有好几种做法 @@ -7931,7 +7943,7 @@ def delete_node_in_BST(parent, node): ``` ----- -### 165. Flatten a Multilevel Linked List +### 165. ['Flatten', 'a', 'Multilevel', 'Linked', 'List'] Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in below figure.You are given the head of the first level of the list. Flatten the list so that all the nodes appear in a single-level linked list. You need to flatten the list in way that all nodes at first level should come first, then nodes of second level, and so on. @@ -7964,7 +7976,7 @@ def flatten_list(head): ``` ----- -### 166. Flattening a Linked List +### 166. ['Flattening', 'a', 'Linked', 'List'] Given a linked list where every node represents a linked list and contains two pointers of its type: (i) Pointer to next node in the main list (we call it ‘right’ pointer in below code) @@ -8017,7 +8029,7 @@ def merge(node1, node2): ``` ----- -### 167. Largest None Close Sum +### 167. ['Largest', 'None', 'Close', 'Sum'] #####9/23/2014 Interview with Kevin from Fivestars @@ -8053,7 +8065,7 @@ def find_largest_none_close_sum(A): ``` ----- -### 168. Longest Common Subsequence +### 168. ['Longest', 'Common', 'Subsequence'] Need to distinguish from Longest Common Substring @@ -8153,7 +8165,7 @@ print LCS('AGGTAB', 'GXTXAYB') ``` ----- -### 169. Longest Common Substring +### 169. ['Longest', 'Common', 'Substring'] ##### 9/4/2014 Interview with Tubular 1. Subset(second le) @@ -8211,7 +8223,7 @@ print Longest_Common_Substring("GeeksforGeeks", "GeeksQuiz") ``` ----- -### 170. Longest Increasing Subsequence +### 170. ['Longest', 'Increasing', 'Subsequence'] #####NC Class 5, slides 17 @@ -8273,7 +8285,7 @@ d_A = LIS(A) ``` ----- -### 171. Lowest Common Ancestor +### 171. ['Lowest', 'Common', 'Ancestor'] #####[LCA, Lowest Common Ancestor](http://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/) Pocket Gem possible question 9/8/2014 @@ -8347,7 +8359,7 @@ def get_LCA(root, node1, node2): ``` ----- -### 172. Majority Number +### 172. ['Majority', 'Number'] #####From mibbs for Linkedin Interview Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). @@ -8406,7 +8418,7 @@ def majority_ii(A): ``` ----- -### 173. Min Num to Composite Words +### 173. ['Min', 'Num', 'to', 'Composite', 'Words'] #####From [Career Cup](http://www.careercup.com/page?pid=pinterest-interview-questions) Pinterest @@ -8451,7 +8463,7 @@ print print_min_num_words(str, d) ``` ----- -### 174. Min Stack +### 174. ['Min', 'Stack'] #####From NC Class 7 Data Structures, slides 8 [Solution](http://www.geeksforgeeks.org/design-and-implement-special-stack-data-structure/) @@ -8490,7 +8502,7 @@ class MinStack(): ``` ----- -### 175. Nested Integer +### 175. ['Nested', 'Integer'] #####From NC QQ group and mitbbs, Linkedin Second round phone interview This is the interface that represents nested lists. @@ -8545,7 +8557,7 @@ def get_depth_recur(input, depth) ``` ----- -### 176. Operations Calculation +### 176. ['Operations', 'Calculation'] ##### 9/5/2014 Elasticbox 加减运算 @@ -8602,7 +8614,7 @@ find_next_num() ``` ----- -### 177. Print Matrix +### 177. ['Print', 'Matrix'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32570751.html) for Pinterest @@ -8647,7 +8659,7 @@ print_matrix(matrix) ``` ----- -### 178. Print Numbers With Five +### 178. ['Print', 'Numbers', 'With', 'Five'] ##### 9/7/2014 From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32651839.html) for Groupon 写一个function,对于参数n,输出从0到n之间所有含5的数字。 @@ -8675,7 +8687,7 @@ print find_five(60) ``` ----- -### 179. Queue by Two Stacks +### 179. ['Queue', 'by', 'Two', 'Stacks'] Implement a Queue by using two stacks. Support O(1) push, pop, top @@ -8703,7 +8715,7 @@ class Queue(): ``` ----- -### 180. Recover Rotated Sorted Array +### 180. ['Recover', 'Rotated', 'Sorted', 'Array'] Given a rotated sorted array, recover it to sorted array in-place. @@ -8734,7 +8746,7 @@ print recover_rotated_sorted_array(A) ``` ----- -### 181. Rotated Mirror Number +### 181. ['Rotated', 'Mirror', 'Number'] #####From Alec's email, someone's onsite interview with Facebook for finding rotated mirrow number like 808 which is less than N @@ -8779,7 +8791,7 @@ print rotated_mirror_number(10000) ``` ----- -### 184. Search a Range in BST +### 184. ['Search', 'a', 'Range', 'in', 'BST'] or Print BST Keys in the Give Range @@ -8810,7 +8822,7 @@ def search_a_range(root, k1, k2): ``` ----- -### 185. Shortest Path +### 185. ['Shortest', 'Path'] #####With Twitter & Cyan @@ -8893,7 +8905,7 @@ print find_path(map) ``` ----- -### 186. Shuffle +### 186. ['Shuffle'] #####Shuffle a given array Saw it from FiveStar's interview. @@ -8922,7 +8934,7 @@ print shuffle_array(A) ``` ----- -### 187. Sort by Stack +### 187. ['Sort', 'by', 'Stack'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32230525.html) for Quantcast @@ -8972,7 +8984,7 @@ print sort_by_two_stacks(s) ``` ----- -### 188. isOneEditDistance +### 188. ['isOneEditDistance'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32760941.html) for facebook diff --git a/tool.py b/tool.py index c9431e0..af6b0ac 100755 --- a/tool.py +++ b/tool.py @@ -7,15 +7,18 @@ def combiner(file_list): f = open('solutions.md', 'w') for i, answer in enumerate(file_list): with open(answer) as file: - title = ' '.join(answer.split('/')[-1].split('.py')[0].split('_')) + title = answer.split('/')[-1].split('.py')[0].split('_') folder = answer.split('/')[2] content = file.read() sections = content.split("\"\"\"") if len(sections) < 3 or len(sections[2]) < 10: continue if folder == 'Leetcode': - address = title.lower().replace(' ', '-') - f.write('### [%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (i+1,title,address)) + whole_name = answer.split('/')[-1].split('.py')[0] + leetcode_num = whole_name.split('_')[0] + leetcode_title = ' '.join(whole_name.split('_')[1:]) + leetcode_address = leetcode_title.replace(' ', '-').lower() + f.write('### [%d. %s](https://oj.leetcode.com/problems/%s/)\n' % (int(leetcode_num), leetcode_title, leetcode_address)) else: f.write('### %d. %s\n' % (i+1,title)) if '\\' in sections[1]: From 8e460a12c4a58390f5ef0a08e5c01d19b4eafa0e Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sat, 7 Dec 2019 22:54:19 -0800 Subject: [PATCH 28/50] Add License key --- Ninja/Leetcode/482_License_Key_Formatting.py | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Ninja/Leetcode/482_License_Key_Formatting.py diff --git a/Ninja/Leetcode/482_License_Key_Formatting.py b/Ninja/Leetcode/482_License_Key_Formatting.py new file mode 100644 index 0000000..8bb864f --- /dev/null +++ b/Ninja/Leetcode/482_License_Key_Formatting.py @@ -0,0 +1,39 @@ +""" +You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. + +Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the first group which could be shorter than K, but still must contain at least one character. Furthermore, there must be a dash inserted between two groups and all lowercase letters should be converted to uppercase. + +Given a non-empty string S and a number K, format the string according to the rules described above. + +Example 1: + Input: S = "5F3Z-2e-9-w", K = 4 + Output: "5F3Z-2E9W" + +Explanation: The string S has been split into two parts, each part has 4 characters. +Note that the two extra dashes are not needed and can be removed. + + +Example 2: + Input: S = "2-5g-3-J", K = 2 + Output: "2-5G-3J" + +Explanation: The string S has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above. + + +Note: +1. The length of string S will not exceed 12,000, and K is a positive integer. +2. String S consists only of alphanumerical characters (a-z and/or A-Z and/or 0-9) and dashes(-). +3. String S is non-empty. + +""" + +class Solution: + def licenseKeyFormatting(self, S: str, K: int) -> str: + original = S.replace('-','').upper() + reformat_list = [] + length = len(original) + for i in range(int(length/K) + 1): + current = original[max(0, length-(i+1)*K):length-i*K] + if current: + reformat_list.insert(0, current) + return '-'.join(reformat_list) From a9fef17b1e008bf4bb39c499e518949d399c354f Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 26 Jan 2020 15:17:11 -0800 Subject: [PATCH 29/50] Update basic concepts --- Ninja/basic_concepts.py | 126 ++++++++++++++++++++++++++++++++++++++++ Ninja/playground.py | 67 --------------------- 2 files changed, 126 insertions(+), 67 deletions(-) create mode 100644 Ninja/basic_concepts.py delete mode 100644 Ninja/playground.py diff --git a/Ninja/basic_concepts.py b/Ninja/basic_concepts.py new file mode 100644 index 0000000..421a731 --- /dev/null +++ b/Ninja/basic_concepts.py @@ -0,0 +1,126 @@ +## LinkedList +class LinkedListNode: + def __init__(self, val): + self.val = val + self.next = None + + def reverse(self, head): + prev = None + while(head): + temp = head.next + head.next = prev + prev = head + head = temp + return prev + +class DLinkedListNode: + def __init__(self, val): + self.val = val + self.prev = self.next = None + + def reverse(self, head): + prev = None + while(head.next): + temp = head.next + head.next = prev + if (prev): + prev.prev = head + prev = head + head = tmp + + +class TreeNode: + def __init__(self, val): + self.val = val + self.left = None + self.right = None + +class TreeTraversal: + def pre_order(self, root): + if not root: + return + + print(root.val) + self.pre_order(root.left) + self.pre_order(root.right) + + def in_order(self, root): + if not root: + return + + self.in_order(root.left) + print(root.val) + self.in_order(root.right) + + def post_order(self, root): + if not root: + return + + self.in_order(root.left) + self.in_order(root.right) + print(root.val) + + def binary_search(root_node, target): + while(root_node.left or root_node.right): + if root_node.data == target: + return True + elif root_node.data < target: + root_node = root_node.right + else: + root_node = root_node.left + return False + + def binary_search(search_list, target): + left_index = 0 + right_index = len(list) - 1 + while left_index < right_index: + mid = (left_index + right_index) / 2 + if target == search_list[mid]: + return True + elif target < search_list[mid]: + right_index = mid - 1 + else: + left_index = mid + 1 + + return False + + def bfs(tree_node, target): + q = [] + q.append(tree_node) + while q: + current = q.popleft() + if not current: + continue + if current.data == target: + return True + q.append(current.left) + q.append(current.right) + return False + + + + + + + + + +## Permutation +def permute(self, n): + self.result = [] + self.permute_helper([], n) + return self.result + +def permute_helper(self, current_result, n): + if len(current_result) == n: + self.result.append(current_result) + return + + cannot_permute_R = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'R' + cannot_permute_B = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'B' + + if not cannot_permute_R: + self.permute_helper(current_result + ['R'], n) + + if not cannot_permute_B: + self.permute_helper(current_result + ['B'], n) diff --git a/Ninja/playground.py b/Ninja/playground.py deleted file mode 100644 index f4fe3c4..0000000 --- a/Ninja/playground.py +++ /dev/null @@ -1,67 +0,0 @@ -class TreeNode: - def __init__(self, data): - self.left = None - self.right = None - self.data = data - -class LinkedListNode: - def __init__(self, data): - self.data = data - self.next = None - - -def binary_search(root_node, target): - while(root_node.left or root_node.right): - if root_node.data == target: - return True - elif root_node.data < target: - root_node = root_node.right - else: - root_node = root_node.left - return False - -def binary_search(search_list, target): - left_index = 0 - right_index = len(list) - 1 - while left_index < right_index: - mid = (left_index + right_index) / 2 - if target == search_list[mid]: - return True - elif target < search_list[mid]: - right_index = mid - 1 - else: - left_index = mid + 1 - - return False - -def bfs(tree_node, target): - q = [] - q.append(tree_node) - while q: - current = q.popleft() - if not current: - continue - if current.data == target: - return True - q.append(current.left) - q.append(current.right) - return False - -def permute(self, n): - self.result = [] - self.permute_helper([], n) - return self.result - -def permute_helper(self, current_result, n): - if len(current_result) == n: - self.result.append(current_result) - return - - cannot_permute_R = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'R' - cannot_permute_B = len(current_result) >= 2 and current_result[-1] == current_result[-2] == 'B' - - if not cannot_permute_R: - self.permute_helper(current_result + ['R'], n) - - if not cannot_permute_B: - self.permute_helper(current_result + ['B'], n) From 9c8f6a28b92632e4122f2a845857f417e09a7117 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 26 Jan 2020 16:49:49 -0800 Subject: [PATCH 30/50] Added more BFS --- Ninja/basic_concepts.py | 81 +++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/Ninja/basic_concepts.py b/Ninja/basic_concepts.py index 421a731..5930c9d 100644 --- a/Ninja/basic_concepts.py +++ b/Ninja/basic_concepts.py @@ -1,4 +1,4 @@ -## LinkedList +## LinkedList, Double LinkedList. LinkedList Reverse class LinkedListNode: def __init__(self, val): self.val = val @@ -18,6 +18,7 @@ def __init__(self, val): self.val = val self.prev = self.next = None + # Unconfirmed yet def reverse(self, head): prev = None while(head.next): @@ -28,7 +29,7 @@ def reverse(self, head): prev = head head = tmp - +## Tree and Tree Search class TreeNode: def __init__(self, val): self.val = val @@ -60,17 +61,28 @@ def post_order(self, root): self.in_order(root.right) print(root.val) - def binary_search(root_node, target): - while(root_node.left or root_node.right): - if root_node.data == target: + def binary_search_iteration(root, value): + while(root.left and root.right): + if root.val == value return True - elif root_node.data < target: - root_node = root_node.right + elif value < root.val: + root = root.left else: - root_node = root_node.left + root = root.right return False - def binary_search(search_list, target): + def binary_search_recursion(root, value): + if not root: + return False + + if root.val == value: + return True + elif value < root.val: + return binary_search_recursion(root.left, value) + else: + return binary_search_recursion(root.right, value) + + def list_binary_search(search_list, target): left_index = 0 right_index = len(list) - 1 while left_index < right_index: @@ -97,12 +109,51 @@ def bfs(tree_node, target): q.append(current.right) return False - - - - - - +## Queue +queue = [] # same as list() +size = len(queue) +queue.append(1) +queue.append(2) +queue.pop(0) # return 1 +queue[0] # return 2 examine the first element + +## Stack +stack = [] +size = len(stack) +stack.append(1) +stack.append(2) +stack.pop() # return 2 + +## Priority Queue - https://docs.python.org/2/library/heapq.html +import heapq +heap = [] +heapq.heappush(heap, 1) # heap [1] +heapq.heappush(heap, 3) # heap [1,3] +heapq.heappush(heap, 2) # heap [1,3,2] +heapq.heappop(heap) # 1 +heapq.heappop(heap) # 2 +heapq.heappop(heap) # 3 + +## Deque +import collections +dq = collections.deque() +dq.append(1) # [1] +dq.appendleft(2) # [2,1] +dq.popleft() # [1] + + +## Set +s = set({1,3,4,5,6,5}) # {1, 3, 4, 5, 6} + +## List +a = [5,4,3,2,1] +for index, value in enumerate(a): + print(index, value) + +## Dictionary +d.items() +d.keys() +d.values() ## Permutation From 4c355d93aa7016dfff8be3851700baf64438a23b Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 26 Jan 2020 21:04:13 -0800 Subject: [PATCH 31/50] Added 399 --- Ninja/Leetcode/399_Evaluate_Division.py | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Ninja/Leetcode/399_Evaluate_Division.py diff --git a/Ninja/Leetcode/399_Evaluate_Division.py b/Ninja/Leetcode/399_Evaluate_Division.py new file mode 100644 index 0000000..cc33377 --- /dev/null +++ b/Ninja/Leetcode/399_Evaluate_Division.py @@ -0,0 +1,64 @@ +""" +Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0. + +Example: +Given a / b = 2.0, b / c = 3.0. +queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ? . +return [6.0, 0.5, -1.0, 1.0, -1.0 ]. + +The input is: vector> equations, vector& values, vector> queries , where equations.size() == values.size(), and the values are positive. This represents the equations. Return vector. + +According to the example above: + +equations = [ ["a", "b"], ["b", "c"] ], +values = [2.0, 3.0], +queries = [ ["a", "c"], ["b", "a"], ["a", "e"], ["a", "a"], ["x", "x"] ]. +  + +The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction. +""" + +class Solution: + def calcEquation(self, equations: List[List[str]], values: List[float], queries: List[List[str]]) -> List[float]: + graph = {} + + for index, e in enumerate(equations): + g_value = values[index] + d_value = (e[1], g_value) + d_key = e[0] + graph.setdefault(d_key, []).append(d_value) + + if g_value != 0: + d_value = (e[0], 1.0 / g_value) + d_key = e[1] + graph.setdefault(d_key, []).append(d_value) + + result = [] + for q in queries: + result.append(self.dfs(q, graph)) + + return result + + def dfs(self, query, graph): + start = query[0] + end = query[1] + if start == end and start not in graph: + return -1.0 + stack = [(start, 1)] + visited = set(start) + while stack: + current, value = stack.pop() + visited.add(current) + if current == end: + return value + + if current not in graph: + continue + + edges = graph[current] + for edge, cost in edges: + if edge not in visited: + stack.append((edge, value * cost)) + + return -1.0 + From 9cb607e23db1aa632233b621c9668d15d0d1c557 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 26 Jan 2020 23:01:33 -0800 Subject: [PATCH 32/50] Added 843 --- Ninja/Leetcode/843_Guess_the_Word.py | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Ninja/Leetcode/843_Guess_the_Word.py diff --git a/Ninja/Leetcode/843_Guess_the_Word.py b/Ninja/Leetcode/843_Guess_the_Word.py new file mode 100644 index 0000000..a253903 --- /dev/null +++ b/Ninja/Leetcode/843_Guess_the_Word.py @@ -0,0 +1,60 @@ +""" +This problem is an interactive problem new to the LeetCode platform. + +We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret. + +You may call master.guess(word) to guess a word.  The guessed word should have type string and must be from the original list with 6 lowercase letters. + +This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word.  Also, if your guess is not in the given wordlist, it will return -1 instead. + +For each test case, you have 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or less calls to master.guess and at least one of these guesses was the secret, you pass the testcase. + +Besides the example test case below, there will be 5 additional test cases, each with 100 words in the word list.  The letters of each word in those testcases were chosen independently at random from 'a' to 'z', such that every word in the given word lists is unique. + +Example 1: +Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"] + +Explanation: + +master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist. +master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches. +master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches. +master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches. +master.guess("abcczz") returns 4, because "abcczz" has 4 matches. + +We made 5 calls to master.guess and one of them was the secret, so we pass the test case. +""" + +# """ +# This is Master's API interface. +# You should not implement it, or speculate about its implementation +# """ +# class Master: +# def guess(self, word: str) -> int: + +class Solution: + def findSecretWord(self, wordlist: List[str], master: 'Master') -> None: + word_set = set(wordlist) + while word_set: + w = word_set.pop() + num = master.guess(w) + if num == len(w): + return + + candidate = set() + for word in word_set: + same = self.compare(w, word) + if num == same: + candidate.add(word) + word_set = candidate + + + def compare(self, w1, w2): + if w1 == w2: + return -1 + + same = 0 + for i in range(len(w1)): + if w1[i] == w2[i]: + same += 1 + return same From 1a2a11ad34f7320c11a57740ead97f764f56d271 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 26 Jan 2020 23:43:02 -0800 Subject: [PATCH 33/50] Adding 890 --- .../Leetcode/890_Find_and_Replace_Pattern.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Ninja/Leetcode/890_Find_and_Replace_Pattern.py diff --git a/Ninja/Leetcode/890_Find_and_Replace_Pattern.py b/Ninja/Leetcode/890_Find_and_Replace_Pattern.py new file mode 100644 index 0000000..463915e --- /dev/null +++ b/Ninja/Leetcode/890_Find_and_Replace_Pattern.py @@ -0,0 +1,45 @@ +""" +You have a list of words and a pattern, and you want to know which words in words matches the pattern. + +A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word. + +(Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.) + +Return a list of the words in words that match the given pattern.  + +You may return the answer in any order. + +  + +Example 1: + +Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb" +Output: ["mee","aqq"] +Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. +"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, +since a and b map to the same letter. +  + +Note: + +1 <= words.length <= 50 +1 <= pattern.length = words[i].length <= 20 +""" + +class Solution: + def findAndReplacePattern(self, words: List[str], pattern: str) -> List[str]: + return [word for word in words if self.isMatch(word, pattern)] + + def isMatch(self, word, pattern): + if len(word) != len(pattern) or len(set(word)) != len(set(pattern)): + return False + + d = {} + for w, p in zip(word, pattern): + if p not in d: + d[p] = w + else: + if d[p] != w: + return False + + return True From daeac6461a549f57d820e8d9a72b8cbdc82df80a Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 27 Jan 2020 21:09:37 -0800 Subject: [PATCH 34/50] Adding robot clean --- Ninja/Leetcode/489_Robot_Room_Cleaner.py | 110 +++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Ninja/Leetcode/489_Robot_Room_Cleaner.py diff --git a/Ninja/Leetcode/489_Robot_Room_Cleaner.py b/Ninja/Leetcode/489_Robot_Room_Cleaner.py new file mode 100644 index 0000000..75f5a24 --- /dev/null +++ b/Ninja/Leetcode/489_Robot_Room_Cleaner.py @@ -0,0 +1,110 @@ +""" +Given a robot cleaner in a room modeled as a grid. + +Each cell in the grid can be empty or blocked. + +The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees. + +When it tries to move into a blocked cell, its bumper sensor detects the obstacle and it stays on the current cell. + +Design an algorithm to clean the entire room using only the 4 given APIs shown below. + +interface Robot { +  // returns true if next cell is open and robot moves into the cell. +  // returns false if next cell is obstacle and robot stays on the current cell. +  boolean move(); + + // Robot will stay on the same cell after calling turnLeft/turnRight. +  // Each turn will be 90 degrees. +  void turnLeft(); +  void turnRight(); + + // Clean the current cell. + void clean(); +} +Example: + +Input: +room = [ + [1,1,1,1,1,0,1,1], + [1,1,1,1,1,0,1,1], + [1,0,1,1,1,1,1,1], + [0,0,0,1,0,0,0,0], + [1,1,1,1,1,1,1,1] +], +row = 1, +col = 3 + +Explanation: +All grids in the room are marked by either 0 or 1. +0 means the cell is blocked, while 1 means the cell is accessible. +The robot initially starts at the position of row=1, col=3. +From the top left corner, its position is one row below and three columns right. +Notes: + +The input is only given to initialize the room and the robot's position internally. You must solve this problem "blindfolded". In other words, you must control the robot using only the mentioned 4 APIs, without knowing the room layout and the initial robot's position. +The robot's initial position will always be in an accessible cell. +The initial direction of the robot will be facing up. +All accessible cells are connected, which means the all cells marked as 1 will be accessible by the robot. +Assume all four edges of the grid are all surrounded by wall. +""" +# """ +# This is the robot's control interface. +# You should not implement it, or speculate about its implementation +# """ +#class Robot: +# def move(self): +# """ +# Returns true if the cell in front is open and robot moves into the cell. +# Returns false if the cell in front is blocked and robot stays in the current cell. +# :rtype bool +# """ +# +# def turnLeft(self): +# """ +# Robot will stay in the same cell after calling turnLeft/turnRight. +# Each turn will be 90 degrees. +# :rtype void +# """ +# +# def turnRight(self): +# """ +# Robot will stay in the same cell after calling turnLeft/turnRight. +# Each turn will be 90 degrees. +# :rtype void +# """ +# +# def clean(self): +# """ +# Clean the current cell. +# :rtype void +# """ + +class Solution: + def cleanRoom(self, robot): + """ + :type robot: Robot + :rtype: None + """ + def go_back(): + robot.turnRight() + robot.turnRight() + robot.move() + robot.turnRight() + robot.turnRight() + + def dfs(x, y, direction): + robot.clean() + visited.add((x,y)) + for i in range(4): + next_d = (direction + i) % 4 + next_point = (x+directions[next_d][0], y+directions[next_d][1]) + if next_point not in visited and robot.move(): + dfs(next_point[0], next_point[1], next_d) + go_back() + robot.turnRight() + + + directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] + visited = set() + dfs(0,0,0) From 2139019110da32f5b58ecd87563aa4207e9e0a57 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Tue, 28 Jan 2020 23:27:21 -0800 Subject: [PATCH 35/50] Update Markdown --- Ninja/coding_index.md | 359 +++++++++++++++++++++--------------------- 1 file changed, 179 insertions(+), 180 deletions(-) diff --git a/Ninja/coding_index.md b/Ninja/coding_index.md index 0730849..4d3b562 100644 --- a/Ninja/coding_index.md +++ b/Ninja/coding_index.md @@ -1,6 +1,6 @@ -## Coding Summary by Keywords and Type +# Coding Summary by Keywords and Type -### Permutation & Combination Type +## Permutation & Combination Type * [x] Permutations * [x] Permutations II * [x] Permutation Sequence @@ -23,41 +23,41 @@ ----- -#### 总结 -[Permutations](./Leetcode/Permutations.py) [II](./Leetcode/Permutations_II.py), -[Combinations](./Leetcode/Combinations.py), -[Combinations Sum](./Leetcode/Combination_Sum.py) [II](./Leetcode/Combination_Sum_II.py) -和[Subset](./Leetcode/Subsets.py) [II](./Leetcode/Subsets_II.py)都是DFS, 区别在于: - -1. 将```res```放入```ret```的条件不一样 - * Permu - ```len(res) = len(S)``` - * Combin - ```len(res) == k``` - * Combin Sum - ```target == 0``` - * Subsets - 只要生成新的res就要存一次 +### 总结 +[Permutations](./Leetcode/46_Permutations.py) [II](./Leetcode/47_Permutations_II.py), +[Combinations](./Leetcode/77_Combinations.py), +[Combinations Sum](./Leetcode/39_Combination_Sum.py) [II](./Leetcode/40_Combination_Sum_II.py) +和[Subset](./Leetcode/78_Subsets.py) [II](./Leetcode/90_Subsets_II.py)都是DFS, 区别在于: + +1. 将`res`放入`ret`的条件不一样 + * Permu - `len(res) = len(S)` + * Combin - `len(res) == k` + * Combin Sum - `target == 0` + * Subsets - 只要生成新的res就要存一次 前三种题存过结果只后程序应该return -2. 循环内call recursion时的输入变量不一样 - * Permu - ```permu_helper(num[:i] + num[i+i:], res, ret)```(除了S[i]) - * Combin - ```comb_helper(i+1, n, k, res, ret)```(S[i+1:]) - * Combin Sum - ```comb_sum_helper(num[i:], target - n, res, ret)```(S[i:]) - * Subsets - ```sub_helper(S[i+1:], res, ret)```(S[i+1:]) - ```S[i+1:]``决定了res内是不会有重复项的(除非S本身就有重复), ```S[i:]```让当前元素可以重复使用 - -##### Note -* II类去重题相比较I类题唯一的差别就是在循环的第一行需要check```if i > 0 and S[i] == S[i-1]: continue``` -* 注意II类题都需要先```sort```, 因为去重是判断前项相等否 -* 普通题目看情况如果要求输入时```res```内的元素有序那也需要```sort``` -* Comb Sum题有一点点特殊在于在循环内需要判断```target - num < 0: continue``` -* Comb Sum II和I比题目有点点变化在于,数字不能无限重取,只能有限重取, - 所以是```comb_sum_II_helper(num[i+1:], target - n, res, ret)``` -* 记得尽量用```enumerate``` - -##### 复杂度O(n) -* Permutation: ```T(n) = n * T(n-1) + O(1)```所以是O(n!) -* Combination and Subsets - 运用递归公式 - - ```python +2. 循环内call recursion时的输入变量不一样 + * Permu - `permu_helper(num[:i] + num[i+i:], res, ret)`(除了S[i]) + * Combin - `comb_helper(i+1, n, k, res, ret)`(S[i+1:]) + * Combin Sum - `comb_sum_helper(num[i:], target - n, res, ret)`(S[i:]) + * Subsets - `sub_helper(S[i+1:], res, ret)`(S[i+1:]) + `S[i+1:]` 决定了res内是不会有重复项的(除非S本身就有重复), `S[i:]`让当前元素可以重复使用 + +### Note +* II类去重题相比较I类题唯一的差别就是在循环的第一行需要check`if i > 0 and S[i] == S[i-1]: continue` +* 注意II类题都需要先`sort`, 因为去重是判断前项相等否 +* 普通题目看情况如果要求输入时`res`内的元素有序那也需要`sort` +* Comb Sum题有一点点特殊在于在循环内需要判断`target - num < 0: continue` +* Comb Sum II和I比题目有点点变化在于,数字不能无限重取,只能有限重取, + 所以是`comb_sum_II_helper(num[i+1:], target - n, res, ret)` +* 记得尽量用`enumerate` + +### 复杂度O(n) +* Permutation: `T(n) = n * T(n-1) + O(1)`所以是O(n!) +* Combination and Subsets + 运用递归公式 + + `python T(n) = T(n-1) + T(n-2) + T(n-3) + ... + T(1) + O(1) = 2T(n-2) + 2T(n-3) + ... + 2T(1) + 2O(1) = 4T(n-3) +4T(n-4) + 4(T1) + 4O(1) @@ -65,7 +65,7 @@ = 2^(n-1-1) * T(n-n+1) + ... + 2^(n-1-1)O(1) = 1/4 * 2^n * T(1) + 1/4 * 2^n * O(1) = O(2^n) - ``` + ` ----- @@ -84,7 +84,7 @@ * [x] Palindrome Partitioning * [x] Palindrome Partitioning II -### Tree Traversal +## Tree Traversal * [x] Binary Tree Inorder Traversal * [x] Binary Tree Preorder Traversal * [x] Binary Tree Postorder Traversal @@ -112,7 +112,7 @@ _____ * [x] Validate Binary Search Tree * [x] Recover Binary Search Tree -### 类Tree(以tree作为Data Structure的题目) +## 类Tree(以tree作为Data Structure的题目) * [x] Path Sum * [x] Path Sum II * [x] Populating Next Right Pointers in Each Node @@ -121,7 +121,7 @@ _____ * [x] Flatten Binary Tree to Linked List * [x] Binary Tree Maximum Path Sum -### Array(意义不大) +## Array(意义不大) * [x] Maximum Subarray * [x] Convert Sorted Array to Binary Search Tree * [x] Merge Sorted Array @@ -132,7 +132,7 @@ _____ * [x] Median of Two Sorted Arrays * [x] Remove Element -### List(意义不大) +## List(意义不大) * [x] Linked List Cycle * [x] Linked List Cycle II * [x] Remove Duplicates from Sorted List @@ -149,11 +149,11 @@ _____ * [x] Reorder List * [x] Reverse Nodes in k-Group -###### Dup with tree +## Dup with tree * [ ] Flatten Binary Tree to Linked List * [ ] Convert Sorted List to Binary Search Tree -### Matrix +## Matrix * [x] Search a 2D Matrix * [x] Spiral Matrix * [x] Spiral Matrix II @@ -161,7 +161,7 @@ _____ * [x] Valid Sudoku * [x] Sudoku Solver -### Play With Math +## Play With Math * [x] Reverse Integer * [x] Roman to Integer * [x] Intger to Roman @@ -170,7 +170,7 @@ _____ ----- -### Dynamic Programming +## Dynamic Programming * [x] Unique Paths * [x] Unique Paths II * [x] Minimum Path Sum @@ -205,210 +205,209 @@ _____ ----- -## From NC DP Class +# From NC DP Class -### 模板 +## 模板 * 状态 state: 灵感, 创造力, 储存小规模问题的结果 * 转移方程 transfer function: 状态之间的联系, 怎么通过小的状态来算大的状态 * 初始化 initialization: 最极限的小状态是什么 * 答案 answer: 最大的那个状态是什么 -### Clues +## Clues 1. Cannot sort, or swap 2. Satisfy: * Find a maximum/minimum result * Decide whether something is possible or not * Count all possible solutions(Doesn't care about solution details, only care about the count or possibility) -### Types of DP +## Types of DP -#### 1. Matrix DP 20% (Triangle, Unique Path, ...) -* state: ```dp[x][y]```表示从起点走到坐标 (x,y) 的xxx +## 1. Matrix DP 20% (Triangle, Unique Path, ...) +* state: `dp[x][y]`表示从起点走到坐标 (x,y) 的xxx * function: 研究下一步怎么走 * initialize: 起点 * answer: 终点 * 复杂度一般为O(n^2) -##### [Triangle](./Leetcode/Triangle.py) -* status: ```dp[x][y]```表示从bottom走到top每个坐标的最短路径 -* function: ```dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j]``` -* initialize: ```dp[-1][j] = triangle[-1][j]``` -* answer: ```dp[0][0]``` (比较奇怪,因为是由下至上) +### [Triangle](./Leetcode/120_Triangle.py) +* status: `dp[x][y]`表示从bottom走到top每个坐标的最短路径 +* function: `dp[i][j] = min(dp[i+1][j], dp[i+1][j+1]) + triangle[i][j]` +* initialize: `dp[-1][j] = triangle[-1][j]` +* answer: `dp[0][0]` (比较奇怪,因为是由下至上) -##### [Unique Path](./Leetcode/Unique_Paths.py) | [Unique Path II](./Leetcode/Unique_Paths_II.py) -* state: ```dp[x][y]```表示从起点走到 (x,y) 的path数 -* function: ```dp[x][y] = dp[x-1][y] + dp[x][y-1]``` | ```if 障碍, dp[x][y] = 0``` -* initialize: ```dp[0][y] = 1, dp[x][0] = 1``` -* answer: ```dp[M-1][N-1]``` +### [Unique Path](./Leetcode/62_Unique_Paths.py) | [Unique Path II](./Leetcode/63_Unique_Paths_II.py) +* state: `dp[x][y]`表示从起点走到 (x,y) 的path数 +* function: `dp[x][y] = dp[x-1][y] + dp[x][y-1]` | `if 障碍, dp[x][y] = 0` +* initialize: `dp[0][y] = 1, dp[x][0] = 1` +* answer: `dp[M-1][N-1]` -##### [Minimum Path Sum](./Leetcode/Minimum_Path_Sum.py) -* state: ```dp[x][y]```表示从起点走到x,y的minimum path sum -* function: ```dp[x][y] = min(dp[x-1][y], dp[x][y-1]) + grid[x][y]``` -* initialize: ```dp[0][0] = grid[0][0], dp[x][0] = dp[x-1][0] + grid[x][0], dp[0][y] = dp[0][y-1] + grid[0][y]``` -* answer: ```dp[M-1][N-1]``` +### [Minimum Path Sum](./Leetcode/64_Minimum_Path_Sum.py) +* state: `dp[x][y]`表示从起点走到x,y的minimum path sum +* function: `dp[x][y] = min(dp[x-1][y], dp[x][y-1]) + grid[x][y]` +* initialize: `dp[0][0] = grid[0][0], dp[x][0] = dp[x-1][0] + grid[x][0], dp[0][y] = dp[0][y-1] + grid[0][y]` +* answer: `dp[M-1][N-1]` ----- -#### 2. One Sequence DP 40% -* state: ```dp[i]```表示前i个位置/数字/字母,以第i个为... -* function: ```dp[i] = dp[j] ...j``` 是i之前的一个位置 -* initialize: ```dp[0] = ...``` -* answer: ```dp[N-1]``` +## 2. One Sequence DP 40% +* state: `dp[i]`表示前i个位置/数字/字母,以第i个为... +* function: `dp[i] = dp[j] ...j` 是i之前的一个位置 +* initialize: `dp[0] = ...` +* answer: `dp[N-1]` * 复杂度一般为O(n^2) -###### [Climbing Stairs](./Leetcode/Climbing_Stairs.py) -* state: ```dp[i]```表示爬到前i个台阶时的方法数 -* function: ```dp[i] = dp[i-1] + dp[i-2]``` -* initialize: ```dp[0] = 1, dp[1] = 2``` -* answer: ```dp[N-1]``` - -###### [Jump Game](./Leetcode/Jump_Game.py) | [Jump Game II](./Leetcode/Jump_Game_II.py) -* state: ```dp[i]```表示能否跳到第i个位置O(n^2) (还有一种O(n)的dp, 见方法2) | dp[i]表示跳到这个位置最少需要多少步. -* function: ```dp[i] = for j in (i-1 ... 0) if dp[j] and j能跳到i)``` | ```min(dp[j] + 1, j < i and j能跳到i)``` -* initialize: ```dp[0] = True``` | ```dp[0] = 0``` -* answer: ```dp[N-1]``` - -###### [Palindrome Partitioning II](./Leetcode/Palindrome_Partitioning_II.py) -* state: ```dp[i]```表示前i-1个字符组成的字符串需要最少几次cut -* function: ```dp[i] = min( dp[j]+1, j 枚举单词长度 O(NL) N: 字符串长度 L:最长单词的长度 -###### [Longest Increasing Subsequence 最长上升子序列](./Interviews/Longest_Increasing_Subsequence.py) [(Not in Leetcode)](http://www.geeksforgeeks.org/dynamic-programming-set-3-longest-increasing-subsequence/) -* state: ~~```dp[i]```表示前i个数字中最长的LIS长度(错误)~~ ```dp[i]```表示第i个数字结尾的LIS长度(正确) -* function: ```dp[i] = max(dp[j]+1, j Find kth in two Sorted Arrays -###### From zz +### From zz * [x] Divide Two Integers (This is not binary search since not allowed to use multiply. Bit calculation) * Pow(x, n) * Sqrt(x) -#### Three steps reverse +### Three steps reverse * Recover Rotated Array * -> Recover Rotated String * -> Rotate String @@ -473,7 +472,7 @@ def binary_search(target, A): return -1 ``` -### Divide & Conquer (Most BT Problem) +## Divide & Conquer (Most BT Problem) * Merge Sort * Quick Sort * Tree Traverse @@ -493,7 +492,7 @@ Binary Tree Level Order Traversal 3 ways Check BFS and DFS template -#### Not in Leetcode +## Not in Leetcode * Print BST Keys in Give Range * __Implement Iterator of BST__ * Insert a Node in a Binary Search Tree @@ -502,25 +501,25 @@ Check BFS and DFS template 这个和CC150不太一样, 是从底走, NC答案是Divide an Conquer, CC150是recursion * (tarjan算法) -### DFS +## DFS 主要想法是先搜索到不能再底层然后再往上走 ##### 复杂度问题 * 组合的话就是O(n^2) * 排列的话就是(n!) -* [Permutations](./Leetcode/Permutations.py) +* [Permutations](./Leetcode/46_Permutations.py) 尝试把DFS的 -* [Subsets](./Leetcode/Subsets.py) -* [N Queens](./Leetcode/N-Queens.py) -* [Palindrome Partitioning](./Leetcode/Palindrome_Partitioning.py) -* [Combinations Sum](./Leetcode/Combination_Sum.py) -* [Word Ladder](./Leetcode/Word_Ladder.py) +* [Subsets](./Leetcode/78_Subsets.py) +* [N Queens](./Leetcode/51_N-Queens.py) +* [Palindrome Partitioning](./Leetcode/131_Palindrome_Partitioning.py) +* [Combinations Sum](./Leetcode/39_Combination_Sum.py) +* [Word Ladder](./Leetcode/127_Word_Ladder.py) __无向图求最短路径用BFS, 用Level Order搜索法__ 注意, 因为是单词, 所以做搜索的时候是按字母变化来 -##### [Word Ladder II](./Leetcode/Word_Ladder_II.py) +##### [Word Ladder II](./Leetcode/127_Word_Ladder_II.py) 1. 最短的是什么 2. 所有最短的是啥 @@ -530,11 +529,11 @@ Check BFS and DFS template ### Graph * 图上的BFS需要用HashTable去重 -##### [Clone Graph](./Leetcode/Clone_Graph.py) +##### [Clone Graph](./Leetcode/133_Clone_Graph.py) ##### [拓扑排序Topological sorting](http://www.geeksforgeeks.org/topological-sorting/) 主要是入度为零 -``` +` Q.offer(....) while (!Q.empty()) { Node head = Q.poll(); @@ -545,7 +544,7 @@ while (!Q.empty()) { } } } -``` +` ### DFS vs BFS ##### DFS - O(2^n), O(n!) From 6c9fe226555536a8637607f3177d469da27e0bfe Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 16:04:12 -0800 Subject: [PATCH 36/50] Add 206 --- Ninja/Leetcode/206_Reverse_Linked_List.py | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Ninja/Leetcode/206_Reverse_Linked_List.py diff --git a/Ninja/Leetcode/206_Reverse_Linked_List.py b/Ninja/Leetcode/206_Reverse_Linked_List.py new file mode 100644 index 0000000..e69d29a --- /dev/null +++ b/Ninja/Leetcode/206_Reverse_Linked_List.py @@ -0,0 +1,44 @@ +""" +Reverse a singly linked list. + +Example: + +Input: 1->2->3->4->5->NULL +Output: 5->4->3->2->1->NULL +Follow up: + +A linked list can be reversed either iteratively or recursively. Could you implement both? +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def reverseList(self, head: ListNode) -> ListNode: + # This is the moving head pointer solution + if not head: + return None + + next = None + new_head = head + while head.next: + next = head.next + head.next = next.next + next.next = new_head + new_head = next + return new_head + + def reverseList(self, head: ListNode) -> ListNode: + # This is the double pointer solution + prev = None + current = head + while current: + temp = current.next + current.next = prev + prev = current + current = temp + + return prev From 7acb47397294c9df8cada710034a1670b1828f8b Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 16:50:19 -0800 Subject: [PATCH 37/50] update 141 --- Ninja/Leetcode/141_Linked_List_Cycle.py | 35 +++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Ninja/Leetcode/141_Linked_List_Cycle.py b/Ninja/Leetcode/141_Linked_List_Cycle.py index 512c4f0..e6f00e3 100644 --- a/Ninja/Leetcode/141_Linked_List_Cycle.py +++ b/Ninja/Leetcode/141_Linked_List_Cycle.py @@ -1,8 +1,24 @@ """ Given a linked list, determine if it has a cycle in it. -Follow up: -Can you solve it without using extra space? +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Example 1: +Input: head = [3,2,0,-4], pos = 1 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the second node. + + +Example 2: +Input: head = [1,2], pos = 0 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the first node. + + +Example 3: +Input: head = [1], pos = -1 +Output: false +Explanation: There is no cycle in the linked list. """ # Definition for singly-linked list. @@ -12,14 +28,17 @@ # self.next = None class Solution: - # @param head, a ListNode - # @return a boolean - def hasCycle(self, head): - slow = head - fast = head - while fast is not None and fast.next is not None: + def hasCycle(self, head: ListNode) -> bool: + slow = fast = head + while( + fast and + fast.next + ): slow = slow.next fast = fast.next.next + if fast == slow: return True return False + + # Note that the fast == slow should be checked on the later. From 84197748e4f86eca0916008fe145377ac342de23 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 17:17:44 -0800 Subject: [PATCH 38/50] Update 142 --- Ninja/Leetcode/142_Linked_List_Cycle_II.py | 47 +++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/Ninja/Leetcode/142_Linked_List_Cycle_II.py b/Ninja/Leetcode/142_Linked_List_Cycle_II.py index 792771a..3c00ca8 100644 --- a/Ninja/Leetcode/142_Linked_List_Cycle_II.py +++ b/Ninja/Leetcode/142_Linked_List_Cycle_II.py @@ -1,7 +1,28 @@ """ Given a linked list, return the node where the cycle begins. If there is no cycle, return null. -Follow up: +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Note: Do not modify the linked list. + +Example 1: +Input: head = [3,2,0,-4], pos = 1 +Output: tail connects to node index 1 +Explanation: There is a cycle in the linked list, where tail connects to the second node. + + +Example 2: +Input: head = [1,2], pos = 0 +Output: tail connects to node index 0 +Explanation: There is a cycle in the linked list, where tail connects to the first node. + + +Example 3: +Input: head = [1], pos = -1 +Output: no cycle +Explanation: There is no cycle in the linked list. + +Follow-up: Can you solve it without using extra space? """ @@ -15,19 +36,25 @@ class Solution: # @param head, a ListNode # @return a list node def detectCycle(self, head): - if head is None or head.next is None: - return None - slow = head.next - fast = head.next.next - while slow!=fast: - if fast is None or fast.next is None: - return None + fast = slow = head + while ( + fast and + fast.next + ): slow = slow.next fast = fast.next.next + if fast == slow: + break + else: + return None + fast = head - while slow!=fast: - slow = slow.next + while fast != slow: fast = fast.next + slow = slow.next return slow # Remember to set slow = head.next and fast = head.next.next before entering the loop + # Assume non-ring_length = a, ring_length = b, pointer fast went through f, pinter slow went through s. + # So we know: f = 2s. f-s = nb + # so s = nb. Which means short has went through n cycle's of the ring so far. So if we put f back to start, at the point they meet again, it's the entry point. From f4896428b2867db990100729ab2c6cac7a9fb378 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 21:06:22 -0800 Subject: [PATCH 39/50] Update 24 --- Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py | 25 ++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py b/Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py index e6c466b..7c27a45 100644 --- a/Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py +++ b/Ninja/Leetcode/24_Swap_Nodes_in_Pairs.py @@ -1,10 +1,11 @@ """ -Given a linked list, swap every two adjacent nodes and return its head. +Given a linked list, swap every two adjacent nodes and return its head. -For example, -Given 1->2->3->4, you should return the list as 2->1->4->3. +You may not modify the values in the list's nodes, only nodes itself may be changed. + +Example: -Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. +Given 1->2->3->4, you should return the list as 2->1->4->3. """ # Definition for singly-linked list. @@ -49,3 +50,19 @@ def swapPairs_3(self, head): second.next = first first.next = self.swapPairs_3(first.next) return second + + def swapPairs_3(self, head): + # used one more variable + dummy = ListNode(0) + dummy.next = head + current = head + prev = dummy + while current and current.next: + next = current.next + prev.next = next + current.next = next.next + next.next = current + prev = current + current = current.next + + return dummy.next From 3ed52b0a51ccb18b053ca69984d8072e1ffdec25 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 21:42:51 -0800 Subject: [PATCH 40/50] Add 328 --- Ninja/Leetcode/328_Odd_Even_Linked_List.py | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Ninja/Leetcode/328_Odd_Even_Linked_List.py diff --git a/Ninja/Leetcode/328_Odd_Even_Linked_List.py b/Ninja/Leetcode/328_Odd_Even_Linked_List.py new file mode 100644 index 0000000..795b16a --- /dev/null +++ b/Ninja/Leetcode/328_Odd_Even_Linked_List.py @@ -0,0 +1,50 @@ +""" +Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. + +You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. + +Example 1: + +Input: 1->2->3->4->5->NULL +Output: 1->3->5->2->4->NULL +Example 2: + +Input: 2->1->3->5->6->4->7->NULL +Output: 2->3->6->7->1->5->4->NULL +Note: + +The relative order inside both the even and odd groups should remain as it was in the input. +The first node is considered odd, the second node even and so on ... +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def oddEvenList(self, head: ListNode) -> ListNode: + if not head: + return None + + odd_current = head + even_current = head.next + even_head = head.next + current = head + i = 0 + while current: + if i % 2 == 0: + even_current.next = current + even_current = even_current.next + else: + odd_current.next = current + odd_current = odd_current.next + + i += 1 + current = current.next + + + + + return head From 2f947472f0e74bdb17ff132f7c8f5917ffc9f9b1 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 22:10:22 -0800 Subject: [PATCH 41/50] Add 237 --- Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py diff --git a/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py b/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py new file mode 100644 index 0000000..e69de29 From 7efa21d0d491a478fed993f56f75389aa73353a6 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 22:18:39 -0800 Subject: [PATCH 42/50] Adding 203 --- .../203_Remove_Linked_List_Elements.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Ninja/Leetcode/203_Remove_Linked_List_Elements.py diff --git a/Ninja/Leetcode/203_Remove_Linked_List_Elements.py b/Ninja/Leetcode/203_Remove_Linked_List_Elements.py new file mode 100644 index 0000000..e5af8f1 --- /dev/null +++ b/Ninja/Leetcode/203_Remove_Linked_List_Elements.py @@ -0,0 +1,28 @@ +""" +Remove all elements from a linked list of integers that have value val. + +Example: + +Input: 1->2->6->3->4->5->6, val = 6 +Output: 1->2->3->4->5 +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def removeElements(self, head: ListNode, val: int) -> ListNode: + dummy = ListNode(0) + dummy.next = head + prev = dummy + while head: + if head.val == val: + prev.next = head.next + else: + prev = head + head = head.next + + return dummy.next From 957c9f672dd8e36952fe9f1737b8ef0041633c5d Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 22:22:11 -0800 Subject: [PATCH 43/50] Update 328 --- Ninja/Leetcode/328_Odd_Even_Linked_List.py | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Ninja/Leetcode/328_Odd_Even_Linked_List.py b/Ninja/Leetcode/328_Odd_Even_Linked_List.py index 795b16a..3aed6a5 100644 --- a/Ninja/Leetcode/328_Odd_Even_Linked_List.py +++ b/Ninja/Leetcode/328_Odd_Even_Linked_List.py @@ -28,23 +28,21 @@ def oddEvenList(self, head: ListNode) -> ListNode: if not head: return None - odd_current = head - even_current = head.next - even_head = head.next - current = head - i = 0 - while current: - if i % 2 == 0: - even_current.next = current - even_current = even_current.next + odd_dummy = ListNode(0) + even_dummy = ListNode(0) + cur_odd = odd_dummy + cur_even = even_dummy + is_even = False + while head: + cur_odd.next = head + cur_even.next = head.next + cur_odd = cur_odd.next + cur_even = cur_even.next + if head.next: + head = head.next.next else: - odd_current.next = current - odd_current = odd_current.next + head = None - i += 1 - current = current.next + cur_odd.next = even_dummy.next - - - - return head + return odd_dummy.next From 3334130150e5cfb0a69e48e42db029da66a05ebc Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 22:22:44 -0800 Subject: [PATCH 44/50] Update 327 --- .../237_Delete_Node_in_a_Linked_List.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py b/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py index e69de29..5692c42 100644 --- a/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py +++ b/Ninja/Leetcode/237_Delete_Node_in_a_Linked_List.py @@ -0,0 +1,40 @@ +""" +Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. + +Given linked list -- head = [4,5,1,9], which looks like following: + +Example 1: + +Input: head = [4,5,1,9], node = 5 +Output: [4,1,9] +Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function. +Example 2: + +Input: head = [4,5,1,9], node = 1 +Output: [4,5,9] +Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function. +  + +Note: + +The linked list will have at least two elements. +All of the nodes' values will be unique. +The given node will not be the tail and it will always be a valid node of the linked list. +Do not return anything from your function. + +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def deleteNode(self, node): + """ + :type node: ListNode + :rtype: void Do not return anything, modify node in-place instead. + """ + node.val = node.next.val + node.next = node.next.next From a447db24fe201cf72e57ef0414cdc71eb8e46233 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 22:50:13 -0800 Subject: [PATCH 45/50] Adding 369 --- Ninja/Leetcode/369_Plus_One_Linked_List.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Ninja/Leetcode/369_Plus_One_Linked_List.py diff --git a/Ninja/Leetcode/369_Plus_One_Linked_List.py b/Ninja/Leetcode/369_Plus_One_Linked_List.py new file mode 100644 index 0000000..f3d0bc1 --- /dev/null +++ b/Ninja/Leetcode/369_Plus_One_Linked_List.py @@ -0,0 +1,21 @@ +""" +Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. + +You may assume the integer do not contain any leading zero, except the number 0 itself. + +The digits are stored such that the most significant digit is at the head of the list. + +Example : + +Input: [1,2,3] +Output: [1,2,4] +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def plusOne(self, head: ListNode) -> ListNode: From 05486d9acdb778da2b09a2541e0aa4a962a6bc3f Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Sun, 23 Feb 2020 23:20:30 -0800 Subject: [PATCH 46/50] Adding 160 and 369 --- .../160_Intersection_of_Two_Linked_Lists.py | 55 +++++++++++++++++++ Ninja/Leetcode/369_Plus_One_Linked_List.py | 15 +++++ 2 files changed, 70 insertions(+) create mode 100644 Ninja/Leetcode/160_Intersection_of_Two_Linked_Lists.py diff --git a/Ninja/Leetcode/160_Intersection_of_Two_Linked_Lists.py b/Ninja/Leetcode/160_Intersection_of_Two_Linked_Lists.py new file mode 100644 index 0000000..399db22 --- /dev/null +++ b/Ninja/Leetcode/160_Intersection_of_Two_Linked_Lists.py @@ -0,0 +1,55 @@ +""" +Write a program to find the node at which the intersection of two singly linked lists begins. + +For example, the following two linked lists: + +begin to intersect at node c1. + +Example 1: +Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 +Output: Reference of the node with value = 8 +Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,0,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B. +  + +Example 2: +Input: intersectVal = 2, listA = [0,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1 +Output: Reference of the node with value = 2 +Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [0,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B. + +Example 3: +Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2 +Output: null +Input Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values. +Explanation: The two lists do not intersect, so return null. +  +Notes: + +If the two linked lists have no intersection at all, return null. +The linked lists must retain their original structure after the function returns. +You may assume there are no cycles anywhere in the entire linked structure. +Your code should preferably run in O(n) time and use only O(1) memory. +""" + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: + pa = headA + pb = headB + while pa and pb and pa!=pb: + pa = pa.next if pa else headB + pb = pb.next if pb else headA + + if pa == pb: + return pa + else: + return None + + # Similar to the circle of the ring + # assume length_A = A, length_B = B. a is the length for List A before intersect. b is the length for List B before intersect. + # A + b = B + a because A = a + c, b = b + c. a + c + b = b + c + a. + # So we put pa to headB when pa reach A's end. We put pb to headA when pb reach B's end. diff --git a/Ninja/Leetcode/369_Plus_One_Linked_List.py b/Ninja/Leetcode/369_Plus_One_Linked_List.py index f3d0bc1..9c5644b 100644 --- a/Ninja/Leetcode/369_Plus_One_Linked_List.py +++ b/Ninja/Leetcode/369_Plus_One_Linked_List.py @@ -19,3 +19,18 @@ class Solution: def plusOne(self, head: ListNode) -> ListNode: + dummy = ListNode(0) + dummy.next = head + slow = fast = dummy + while fast: + if fast.val != 9: + slow = fast + fast = fast.next + + slow.val += 1 + slow = slow.next + while slow: + slow.val = 0 + slow = slow.next + + return dummy.next if dummy.val == 0 else dummy From 39cfbde2797539b1a8b5ff781e7251dd5b223736 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 24 Feb 2020 21:04:40 -0800 Subject: [PATCH 47/50] Update 1, adding 286 and 325 --- Ninja/Leetcode/1_Two_Sum.py | 19 ++--- Ninja/Leetcode/286_Walls_and_Gates.py | 70 +++++++++++++++++++ .../325_Maximum_Size_Subarray_Sum_Equals_k.py | 45 ++++++++++++ 3 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 Ninja/Leetcode/286_Walls_and_Gates.py create mode 100644 Ninja/Leetcode/325_Maximum_Size_Subarray_Sum_Equals_k.py diff --git a/Ninja/Leetcode/1_Two_Sum.py b/Ninja/Leetcode/1_Two_Sum.py index ba1fc97..b27995f 100644 --- a/Ninja/Leetcode/1_Two_Sum.py +++ b/Ninja/Leetcode/1_Two_Sum.py @@ -1,12 +1,13 @@ """ -Given an array of integers, find two numbers such that they add up to a specific target number. +Given an array of integers, return indices of the two numbers such that they add up to a specific target. -The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. +You may assume that each input would have exactly one solution, and you may not use the same element twice. -You may assume that each input would have exactly one solution. +Example: +Given nums = [2, 7, 11, 15], target = 9, -Input: numbers={2, 7, 11, 15}, target=9 -Output: index1=1, index2=2 +Because nums[0] + nums[1] = 2 + 7 = 9, +return [0, 1]. """ class Solution: @@ -25,11 +26,11 @@ def twoSum_1(self, num, target): # O(n) def twoSum_2(self, num, target): num_map = {} - for i, n in enumerate(num): - if target - n not in num_map: - num_map[n] = i + for i, n in enumerate(nums): + if target - n in num_map: + return (num_map[target - n], i) else: - return (num_map[target-n] + 1, i + 1) # Don't know why leetcode call the index [0] as 1 + num_map[n] = i # O(nlgn) This is the best way, used in X Sum def twoSum_3(self, num, target): diff --git a/Ninja/Leetcode/286_Walls_and_Gates.py b/Ninja/Leetcode/286_Walls_and_Gates.py new file mode 100644 index 0000000..9864c48 --- /dev/null +++ b/Ninja/Leetcode/286_Walls_and_Gates.py @@ -0,0 +1,70 @@ +""" +You are given a m x n 2D grid initialized with these three possible values. + +-1 - A wall or an obstacle. +0 - A gate. +INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647. +Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF. + +Example:  + +Given the 2D grid: + +INF -1 0 INF +INF INF INF -1 +INF -1 INF -1 + 0 -1 INF INF +After running your function, the 2D grid should be: + + 3 -1 0 1 + 2 2 1 -1 + 1 -1 2 -1 + 0 -1 3 4 +""" +from collections import deque +class Solution: + def wallsAndGates(self, rooms: List[List[int]]) -> None: + """ + Do not return anything, modify rooms in-place instead. + """ + gates = self.find_gates(rooms) + print(gates) + if not gates: + return + + for gate in gates: + self.BFS(gate, rooms) + + def find_gates(self, rooms): + gates = [] + for i in range(len(rooms)): + for j in range(len(rooms[0])): + if rooms[i][j] == 0: + gates.append((i, j)) + return gates + + def BFS(self, start, rooms): + queue = [(start, 0)] + visited = set() + directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + while queue: + cur_pos, distance = queue.pop(0) + if ( + cur_pos in visited or + rooms[cur_pos[0]][cur_pos[1]] == -1 + ): + continue + else: + visited.add(cur_pos) + + rooms[cur_pos[0]][cur_pos[1]] = min(distance, rooms[cur_pos[0]][cur_pos[1]]) + + for d in directions: + next_point = (cur_pos[0] + d[0], cur_pos[1] + d[1]) + if ( + 0 <= next_point[0] < len(rooms) and + 0 <= next_point[1] < len(rooms[0]) and + rooms[next_point[0]][next_point[1]] > distance + 1 + ): + queue.append((next_point, distance + 1)) diff --git a/Ninja/Leetcode/325_Maximum_Size_Subarray_Sum_Equals_k.py b/Ninja/Leetcode/325_Maximum_Size_Subarray_Sum_Equals_k.py new file mode 100644 index 0000000..4cca1f1 --- /dev/null +++ b/Ninja/Leetcode/325_Maximum_Size_Subarray_Sum_Equals_k.py @@ -0,0 +1,45 @@ +""" +Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. + +Note: +The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range. + +Example 1: + +Input: nums = [1, -1, 5, -2, 3], k = 3 +Output: 4 +Explanation: The subarray [1, -1, 5, -2] sums to 3 and is the longest. +Example 2: + +Input: nums = [-2, -1, 2, 1], k = 1 +Output: 2 +Explanation: The subarray [-1, 2] sums to 1 and is the longest. +Follow Up: +Can you do it in O(n) time? +""" + +class Solution: + def maxSubArrayLen(self, nums: List[int], k: int) -> int: + # Too slow, won't AC + max_len = 0 + for i in range(len(nums)-1): + for j in range(1, len(nums)): + subarray = nums[i:j] + if sum(subarray) == k: + max_len = max(max_len, j-i) + + return max_len + + def maxSubArrayLen(self, nums: List[int], k: int) -> int: + sum_map = {0:0} + cur_sum = 0 + max_len = 0 + for i, n in enumerate(nums): + cur_sum += n + if cur_sum - k in sum_map: + max_len = max(max_len, i + 1 - sum_map[cur_sum - k]) + + if cur_sum not in sum_map: + sum_map[cur_sum] = i + 1 + + return max_len From f0357dc78cf5832d1ed9ce62a484f75b5ca065cc Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 24 Feb 2020 21:30:18 -0800 Subject: [PATCH 48/50] Adding 200 --- Ninja/Leetcode/200_Number_of_Islands.py | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Ninja/Leetcode/200_Number_of_Islands.py diff --git a/Ninja/Leetcode/200_Number_of_Islands.py b/Ninja/Leetcode/200_Number_of_Islands.py new file mode 100644 index 0000000..ea02ebd --- /dev/null +++ b/Ninja/Leetcode/200_Number_of_Islands.py @@ -0,0 +1,39 @@ +""" +Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. + +Example 1: + +Input: +11110 +11010 +11000 +00000 + +Output: 1 +Example 2: + +Input: +11000 +11000 +00100 +00011 + +Output: 3 +""" + +class Solution: + def numIslands(self, grid: List[List[str]]) -> int: + visited = [[False] * len(grid[0])] * len(grid) + islands = 0 + for i in range(len(grid)): + for j in range(len(grid[0])): + if grid[i][j] == 1 and not visited[i][j]: + islands += 1 + self.DFS((i, j), grid) + + return islands + + def DFS(self, current, grid): + directions = [(0,1), (1,0), (0, -1), (-1, 0)] + + From 65aec3f450b359013adcca46a4b6c5c482ac5372 Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 24 Feb 2020 21:33:06 -0800 Subject: [PATCH 49/50] Adding 200 --- Ninja/Leetcode/200_Number_of_Islands.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Ninja/Leetcode/200_Number_of_Islands.py b/Ninja/Leetcode/200_Number_of_Islands.py index ea02ebd..9925fe8 100644 --- a/Ninja/Leetcode/200_Number_of_Islands.py +++ b/Ninja/Leetcode/200_Number_of_Islands.py @@ -23,17 +23,31 @@ class Solution: def numIslands(self, grid: List[List[str]]) -> int: - visited = [[False] * len(grid[0])] * len(grid) + visited = [[False for i in range(len(grid[0]))] for j in range(len(grid))] islands = 0 for i in range(len(grid)): for j in range(len(grid[0])): - if grid[i][j] == 1 and not visited[i][j]: + if grid[i][j] == "1" and not visited[i][j]: islands += 1 - self.DFS((i, j), grid) + self.DFS((i, j), grid, visited) return islands - def DFS(self, current, grid): + def DFS(self, current, grid, visited): directions = [(0,1), (1,0), (0, -1), (-1, 0)] - + x, y = current + if visited[x][y]: + return + + visited[x][y] = True + for d in directions: + next_x = x + d[0] + next_y = y + d[1] + + if ( + 0 <= next_x < len(grid) and + 0 <= next_y < len(grid[0]) and + grid[next_x][next_y] == "1" + ): + self.DFS((next_x, next_y), grid, visited) From b40e6c4db10da417e72247f61146f7570621106a Mon Sep 17 00:00:00 2001 From: Yan Cao Date: Mon, 24 Feb 2020 21:44:49 -0800 Subject: [PATCH 50/50] Update tool and solutions --- solutions.md | 815 +++++++++++++++++++++++++++++++++++++++++++++++---- tool.py | 2 +- 2 files changed, 754 insertions(+), 63 deletions(-) diff --git a/solutions.md b/solutions.md index e9a1ad9..9a4d298 100644 --- a/solutions.md +++ b/solutions.md @@ -2193,8 +2193,24 @@ class Solution: Given a linked list, determine if it has a cycle in it. -Follow up: -Can you solve it without using extra space? +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Example 1: +Input: head = [3,2,0,-4], pos = 1 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the second node. + + +Example 2: +Input: head = [1,2], pos = 0 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the first node. + + +Example 3: +Input: head = [1], pos = -1 +Output: false +Explanation: There is no cycle in the linked list. ```python @@ -2205,17 +2221,20 @@ Can you solve it without using extra space? # self.next = None class Solution: - # @param head, a ListNode - # @return a boolean - def hasCycle(self, head): - slow = head - fast = head - while fast is not None and fast.next is not None: + def hasCycle(self, head: ListNode) -> bool: + slow = fast = head + while( + fast and + fast.next + ): slow = slow.next fast = fast.next.next + if fast == slow: return True return False + + # Note that the fast == slow should be checked on the later. ``` ----- @@ -2223,7 +2242,28 @@ class Solution: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. -Follow up: +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Note: Do not modify the linked list. + +Example 1: +Input: head = [3,2,0,-4], pos = 1 +Output: tail connects to node index 1 +Explanation: There is a cycle in the linked list, where tail connects to the second node. + + +Example 2: +Input: head = [1,2], pos = 0 +Output: tail connects to node index 0 +Explanation: There is a cycle in the linked list, where tail connects to the first node. + + +Example 3: +Input: head = [1], pos = -1 +Output: no cycle +Explanation: There is no cycle in the linked list. + +Follow-up: Can you solve it without using extra space? ```python @@ -2238,22 +2278,28 @@ class Solution: # @param head, a ListNode # @return a list node def detectCycle(self, head): - if head is None or head.next is None: - return None - slow = head.next - fast = head.next.next - while slow!=fast: - if fast is None or fast.next is None: - return None + fast = slow = head + while ( + fast and + fast.next + ): slow = slow.next fast = fast.next.next + if fast == slow: + break + else: + return None + fast = head - while slow!=fast: - slow = slow.next + while fast != slow: fast = fast.next + slow = slow.next return slow # Remember to set slow = head.next and fast = head.next.next before entering the loop + # Assume non-ring_length = a, ring_length = b, pointer fast went through f, pinter slow went through s. + # So we know: f = 2s. f-s = nb + # so s = nb. Which means short has went through n cycle's of the ring so far. So if we put f back to start, at the point they meet again, it's the entry point. ``` ----- @@ -2874,6 +2920,66 @@ class Solution: ``` ----- +### [160. Intersection of Two Linked Lists](https://oj.leetcode.com/problems/intersection-of-two-linked-lists/) + +Write a program to find the node at which the intersection of two singly linked lists begins. + +For example, the following two linked lists: + +begin to intersect at node c1. + +Example 1: +Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 +Output: Reference of the node with value = 8 +Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,0,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B. +  + +Example 2: +Input: intersectVal = 2, listA = [0,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1 +Output: Reference of the node with value = 2 +Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [0,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B. + +Example 3: +Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2 +Output: null +Input Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values. +Explanation: The two lists do not intersect, so return null. +  +Notes: + +If the two linked lists have no intersection at all, return null. +The linked lists must retain their original structure after the function returns. +You may assume there are no cycles anywhere in the entire linked structure. +Your code should preferably run in O(n) time and use only O(1) memory. + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: + pa = headA + pb = headB + while pa and pb and pa!=pb: + pa = pa.next if pa else headB + pb = pb.next if pb else headA + + if pa == pb: + return pa + else: + return None + + # Similar to the circle of the ring + # assume length_A = A, length_B = B. a is the length for List A before intersect. b is the length for List B before intersect. + # A + b = B + a because A = a + c, b = b + c. a + c + b = b + c + a. + # So we put pa to headB when pa reach A's end. We put pb to headA when pb reach B's end. +``` +----- + ### [16. 3Sum Closest](https://oj.leetcode.com/problems/3sum-closest/) Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. @@ -3082,14 +3188,15 @@ class Solution: ### [1. Two Sum](https://oj.leetcode.com/problems/two-sum/) -Given an array of integers, find two numbers such that they add up to a specific target number. +Given an array of integers, return indices of the two numbers such that they add up to a specific target. -The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. +You may assume that each input would have exactly one solution, and you may not use the same element twice. -You may assume that each input would have exactly one solution. +Example: +Given nums = [2, 7, 11, 15], target = 9, -Input: numbers={2, 7, 11, 15}, target=9 -Output: index1=1, index2=2 +Because nums[0] + nums[1] = 2 + 7 = 9, +return [0, 1]. ```python @@ -3109,11 +3216,11 @@ class Solution: # O(n) def twoSum_2(self, num, target): num_map = {} - for i, n in enumerate(num): - if target - n not in num_map: - num_map[n] = i + for i, n in enumerate(nums): + if target - n in num_map: + return (num_map[target - n], i) else: - return (num_map[target-n] + 1, i + 1) # Don't know why leetcode call the index [0] as 1 + num_map[n] = i # O(nlgn) This is the best way, used in X Sum def twoSum_3(self, num, target): @@ -3139,6 +3246,146 @@ class Solution: ``` ----- +### [200. Number of Islands](https://oj.leetcode.com/problems/number-of-islands/) + +Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. + +Example 1: + +Input: +11110 +11010 +11000 +00000 + +Output: 1 +Example 2: + +Input: +11000 +11000 +00100 +00011 + +Output: 3 + +```python + +class Solution: + def numIslands(self, grid: List[List[str]]) -> int: + visited = [[False for i in range(len(grid[0]))] for j in range(len(grid))] + islands = 0 + for i in range(len(grid)): + for j in range(len(grid[0])): + if grid[i][j] == "1" and not visited[i][j]: + islands += 1 + self.DFS((i, j), grid, visited) + + return islands + + def DFS(self, current, grid, visited): + directions = [(0,1), (1,0), (0, -1), (-1, 0)] + + x, y = current + if visited[x][y]: + return + + visited[x][y] = True + for d in directions: + next_x = x + d[0] + next_y = y + d[1] + + if ( + 0 <= next_x < len(grid) and + 0 <= next_y < len(grid[0]) and + grid[next_x][next_y] == "1" + ): + self.DFS((next_x, next_y), grid, visited) +``` +----- + +### [203. Remove Linked List Elements](https://oj.leetcode.com/problems/remove-linked-list-elements/) + +Remove all elements from a linked list of integers that have value val. + +Example: + +Input: 1->2->6->3->4->5->6, val = 6 +Output: 1->2->3->4->5 + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def removeElements(self, head: ListNode, val: int) -> ListNode: + dummy = ListNode(0) + dummy.next = head + prev = dummy + while head: + if head.val == val: + prev.next = head.next + else: + prev = head + head = head.next + + return dummy.next +``` +----- + +### [206. Reverse Linked List](https://oj.leetcode.com/problems/reverse-linked-list/) + +Reverse a singly linked list. + +Example: + +Input: 1->2->3->4->5->NULL +Output: 5->4->3->2->1->NULL +Follow up: + +A linked list can be reversed either iteratively or recursively. Could you implement both? + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def reverseList(self, head: ListNode) -> ListNode: + # This is the moving head pointer solution + if not head: + return None + + next = None + new_head = head + while head.next: + next = head.next + head.next = next.next + next.next = new_head + new_head = next + return new_head + + def reverseList(self, head: ListNode) -> ListNode: + # This is the double pointer solution + prev = None + current = head + while current: + temp = current.next + current.next = prev + prev = current + current = temp + + return prev +``` +----- + ### [20. Valid Parentheses](https://oj.leetcode.com/problems/valid-parentheses/) Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. @@ -3230,6 +3477,51 @@ class Solution: ``` ----- +### [237. Delete Node in a Linked List](https://oj.leetcode.com/problems/delete-node-in-a-linked-list/) + +Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. + +Given linked list -- head = [4,5,1,9], which looks like following: + +Example 1: + +Input: head = [4,5,1,9], node = 5 +Output: [4,1,9] +Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function. +Example 2: + +Input: head = [4,5,1,9], node = 1 +Output: [4,5,9] +Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function. +  + +Note: + +The linked list will have at least two elements. +All of the nodes' values will be unique. +The given node will not be the tail and it will always be a valid node of the linked list. +Do not return anything from your function. + + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def deleteNode(self, node): + + :type node: ListNode + :rtype: void Do not return anything, modify node in-place instead. + + node.val = node.next.val + node.next = node.next.next +``` +----- + ### [23. Merge k Sorted Lists](https://oj.leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. @@ -3266,12 +3558,13 @@ class Solution: ### [24. Swap Nodes in Pairs](https://oj.leetcode.com/problems/swap-nodes-in-pairs/) -Given a linked list, swap every two adjacent nodes and return its head. +Given a linked list, swap every two adjacent nodes and return its head. -For example, -Given 1->2->3->4, you should return the list as 2->1->4->3. +You may not modify the values in the list's nodes, only nodes itself may be changed. -Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. +Example: + +Given 1->2->3->4, you should return the list as 2->1->4->3. ```python @@ -3317,6 +3610,22 @@ class Solution: second.next = first first.next = self.swapPairs_3(first.next) return second + + def swapPairs_3(self, head): + # used one more variable + dummy = ListNode(0) + dummy.next = head + current = head + prev = dummy + while current and current.next: + next = current.next + prev.next = next + current.next = next.next + next.next = current + prev = current + current = current.next + + return dummy.next ``` ----- @@ -3442,6 +3751,81 @@ class Solution: ``` ----- +### [286. Walls and Gates](https://oj.leetcode.com/problems/walls-and-gates/) + +You are given a m x n 2D grid initialized with these three possible values. + +-1 - A wall or an obstacle. +0 - A gate. +INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647. +Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF. + +Example:  + +Given the 2D grid: + +INF -1 0 INF +INF INF INF -1 +INF -1 INF -1 + 0 -1 INF INF +After running your function, the 2D grid should be: + + 3 -1 0 1 + 2 2 1 -1 + 1 -1 2 -1 + 0 -1 3 4 + +```python +from collections import deque +class Solution: + def wallsAndGates(self, rooms: List[List[int]]) -> None: + + Do not return anything, modify rooms in-place instead. + + gates = self.find_gates(rooms) + print(gates) + if not gates: + return + + for gate in gates: + self.BFS(gate, rooms) + + def find_gates(self, rooms): + gates = [] + for i in range(len(rooms)): + for j in range(len(rooms[0])): + if rooms[i][j] == 0: + gates.append((i, j)) + return gates + + def BFS(self, start, rooms): + queue = [(start, 0)] + visited = set() + directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] + + while queue: + cur_pos, distance = queue.pop(0) + if ( + cur_pos in visited or + rooms[cur_pos[0]][cur_pos[1]] == -1 + ): + continue + else: + visited.add(cur_pos) + + rooms[cur_pos[0]][cur_pos[1]] = min(distance, rooms[cur_pos[0]][cur_pos[1]]) + + for d in directions: + next_point = (cur_pos[0] + d[0], cur_pos[1] + d[1]) + if ( + 0 <= next_point[0] < len(rooms) and + 0 <= next_point[1] < len(rooms[0]) and + rooms[next_point[0]][next_point[1]] > distance + 1 + ): + queue.append((next_point, distance + 1)) +``` +----- + ### [28. Implement strStr](https://oj.leetcode.com/problems/implement-strstr/) Implement strStr(). @@ -3643,6 +4027,109 @@ class Solution: ``` ----- +### [325. Maximum Size Subarray Sum Equals k](https://oj.leetcode.com/problems/maximum-size-subarray-sum-equals-k/) + +Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. + +Note: +The sum of the entire nums array is guaranteed to fit within the 32-bit signed integer range. + +Example 1: + +Input: nums = [1, -1, 5, -2, 3], k = 3 +Output: 4 +Explanation: The subarray [1, -1, 5, -2] sums to 3 and is the longest. +Example 2: + +Input: nums = [-2, -1, 2, 1], k = 1 +Output: 2 +Explanation: The subarray [-1, 2] sums to 1 and is the longest. +Follow Up: +Can you do it in O(n) time? + +```python + +class Solution: + def maxSubArrayLen(self, nums: List[int], k: int) -> int: + # Too slow, won't AC + max_len = 0 + for i in range(len(nums)-1): + for j in range(1, len(nums)): + subarray = nums[i:j] + if sum(subarray) == k: + max_len = max(max_len, j-i) + + return max_len + + def maxSubArrayLen(self, nums: List[int], k: int) -> int: + sum_map = {0:0} + cur_sum = 0 + max_len = 0 + for i, n in enumerate(nums): + cur_sum += n + if cur_sum - k in sum_map: + max_len = max(max_len, i + 1 - sum_map[cur_sum - k]) + + if cur_sum not in sum_map: + sum_map[cur_sum] = i + 1 + + return max_len +``` +----- + +### [328. Odd Even Linked List](https://oj.leetcode.com/problems/odd-even-linked-list/) + +Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. + +You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. + +Example 1: + +Input: 1->2->3->4->5->NULL +Output: 1->3->5->2->4->NULL +Example 2: + +Input: 2->1->3->5->6->4->7->NULL +Output: 2->3->6->7->1->5->4->NULL +Note: + +The relative order inside both the even and odd groups should remain as it was in the input. +The first node is considered odd, the second node even and so on ... + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def oddEvenList(self, head: ListNode) -> ListNode: + if not head: + return None + + odd_dummy = ListNode(0) + even_dummy = ListNode(0) + cur_odd = odd_dummy + cur_even = even_dummy + is_even = False + while head: + cur_odd.next = head + cur_even.next = head.next + cur_odd = cur_odd.next + cur_even = cur_even.next + if head.next: + head = head.next.next + else: + head = None + + cur_odd.next = even_dummy.next + + return odd_dummy.next +``` +----- + ### [32. Longest Valid Parentheses](https://oj.leetcode.com/problems/longest-valid-parentheses/) Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. @@ -3851,6 +4338,47 @@ class Solution: ``` ----- +### [369. Plus One Linked List](https://oj.leetcode.com/problems/plus-one-linked-list/) + +Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. + +You may assume the integer do not contain any leading zero, except the number 0 itself. + +The digits are stored such that the most significant digit is at the head of the list. + +Example : + +Input: [1,2,3] +Output: [1,2,4] + +```python + +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def plusOne(self, head: ListNode) -> ListNode: + dummy = ListNode(0) + dummy.next = head + slow = fast = dummy + while fast: + if fast.val != 9: + slow = fast + fast = fast.next + + slow.val += 1 + slow = slow.next + while slow: + slow.val = 0 + slow = slow.next + + return dummy.next if dummy.val == 0 else dummy +``` +----- + ### [36. Valid Sudoku](https://oj.leetcode.com/problems/valid-sudoku/) Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. @@ -3981,6 +4509,75 @@ class Solution: ``` ----- +### [399. Evaluate Division](https://oj.leetcode.com/problems/evaluate-division/) + +Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0. + +Example: +Given a / b = 2.0, b / c = 3.0. +queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ? . +return [6.0, 0.5, -1.0, 1.0, -1.0 ]. + +The input is: vector> equations, vector& values, vector> queries , where equations.size() == values.size(), and the values are positive. This represents the equations. Return vector. + +According to the example above: + +equations = [ ["a", "b"], ["b", "c"] ], +values = [2.0, 3.0], +queries = [ ["a", "c"], ["b", "a"], ["a", "e"], ["a", "a"], ["x", "x"] ]. +  + +The input is always valid. You may assume that evaluating the queries will result in no division by zero and there is no contradiction. + +```python + +class Solution: + def calcEquation(self, equations: List[List[str]], values: List[float], queries: List[List[str]]) -> List[float]: + graph = {} + + for index, e in enumerate(equations): + g_value = values[index] + d_value = (e[1], g_value) + d_key = e[0] + graph.setdefault(d_key, []).append(d_value) + + if g_value != 0: + d_value = (e[0], 1.0 / g_value) + d_key = e[1] + graph.setdefault(d_key, []).append(d_value) + + result = [] + for q in queries: + result.append(self.dfs(q, graph)) + + return result + + def dfs(self, query, graph): + start = query[0] + end = query[1] + if start == end and start not in graph: + return -1.0 + stack = [(start, 1)] + visited = set(start) + while stack: + current, value = stack.pop() + visited.add(current) + if current == end: + return value + + if current not in graph: + continue + + edges = graph[current] + for edge, cost in edges: + if edge not in visited: + stack.append((edge, value * cost)) + + return -1.0 + +``` +----- + ### [39. Combination Sum](https://oj.leetcode.com/problems/combination-sum/) Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. @@ -4415,6 +5012,50 @@ class Solution: ``` ----- +### [482. License Key Formatting](https://oj.leetcode.com/problems/license-key-formatting/) + +You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups by N dashes. + +Given a number K, we would want to reformat the strings such that each group contains exactly K characters, except for the first group which could be shorter than K, but still must contain at least one character. Furthermore, there must be a dash inserted between two groups and all lowercase letters should be converted to uppercase. + +Given a non-empty string S and a number K, format the string according to the rules described above. + +Example 1: + Input: S = "5F3Z-2e-9-w", K = 4 + Output: "5F3Z-2E9W" + +Explanation: The string S has been split into two parts, each part has 4 characters. +Note that the two extra dashes are not needed and can be removed. + + +Example 2: + Input: S = "2-5g-3-J", K = 2 + Output: "2-5G-3J" + +Explanation: The string S has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above. + + +Note: +1. The length of string S will not exceed 12,000, and K is a positive integer. +2. String S consists only of alphanumerical characters (a-z and/or A-Z and/or 0-9) and dashes(-). +3. String S is non-empty. + + +```python + +class Solution: + def licenseKeyFormatting(self, S: str, K: int) -> str: + original = S.replace('-','').upper() + reformat_list = [] + length = len(original) + for i in range(int(length/K) + 1): + current = original[max(0, length-(i+1)*K):length-i*K] + if current: + reformat_list.insert(0, current) + return '-'.join(reformat_list) +``` +----- + ### [48. Rotate Image](https://oj.leetcode.com/problems/rotate-image/) You are given an n x n 2D matrix representing an image. @@ -6575,6 +7216,56 @@ class Solution: ``` ----- +### [890. Find and Replace Pattern](https://oj.leetcode.com/problems/find-and-replace-pattern/) + +You have a list of words and a pattern, and you want to know which words in words matches the pattern. + +A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word. + +(Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.) + +Return a list of the words in words that match the given pattern.  + +You may return the answer in any order. + +  + +Example 1: + +Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb" +Output: ["mee","aqq"] +Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. +"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, +since a and b map to the same letter. +  + +Note: + +1 <= words.length <= 50 +1 <= pattern.length = words[i].length <= 20 + +```python + +class Solution: + def findAndReplacePattern(self, words: List[str], pattern: str) -> List[str]: + return [word for word in words if self.isMatch(word, pattern)] + + def isMatch(self, word, pattern): + if len(word) != len(pattern) or len(set(word)) != len(set(pattern)): + return False + + d = {} + for w, p in zip(word, pattern): + if p not in d: + d[p] = w + else: + if d[p] != w: + return False + + return True +``` +----- + ### [89. Gray Code](https://oj.leetcode.com/problems/gray-code/) The gray code is a binary numeral system where two successive values differ in only one bit. @@ -7249,7 +7940,7 @@ class Solution: ``` ----- -### 153. ['Absolute', 'Minimum'] +### 167. ['Absolute', 'Minimum'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32782345.html) for Amazon Interview Given three arrays A,B,C containing unsorted numbers. Find three numbers a, @@ -7295,7 +7986,7 @@ def get_min_distance(A1, A2, A3): ``` ----- -### 154. ['Alternating', 'Positive', 'N', 'Negative'] +### 168. ['Alternating', 'Positive', 'N', 'Negative'] or Rearrange Array Alternating Positive Negative Items Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance. @@ -7380,7 +8071,7 @@ print rearrange_array_rotate(B) ``` ----- -### 155. ['BFS', 'DFS'] +### 169. ['BFS', 'DFS'] #####Summarize all kind of ways to do Tree Traversal * BFS @@ -7616,7 +8307,7 @@ print_tree_as_list(head) ``` ----- -### 156. ['Binary', 'Tree', 'Level', 'K', 'Nodes'] +### 170. ['Binary', 'Tree', 'Level', 'K', 'Nodes'] #####From [blog](http://blog.csdn.net/luckyxiaoqiang/article/details/7518888#topic6) @@ -7647,7 +8338,7 @@ print get_kth_level_nodes(root, 5) ``` ----- -### 157. ['Blocking', 'Queue'] +### 171. ['Blocking', 'Queue'] #####From Tango Interview Challenge This is pretty important design pattern, including the knowledge of thread @@ -7764,7 +8455,7 @@ random_result() ``` ----- -### 158. ['Coin', 'Change'] +### 172. ['Coin', 'Change'] #####From [Geeksforgeeks](http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/) @@ -7799,7 +8490,7 @@ print coin_change(5) ``` ----- -### 159. ['Consecutive', 'Subarray'] +### 173. ['Consecutive', 'Subarray'] #####Interview With Cyan 1. Shortest Path @@ -7851,7 +8542,7 @@ print find_consecutive(num, sum) ``` ----- -### 161. ['Count', 'zeros', 'in', 'Factorial'] +### 175. ['Count', 'zeros', 'in', 'Factorial'] From mitbbs for Facebook @@ -7880,7 +8571,7 @@ print fact(N) ``` ----- -### 162. ['Delete', 'a', 'Node', 'in', 'BST'] +### 176. ['Delete', 'a', 'Node', 'in', 'BST'] [Solution](http://answer.ninechapter.com/solutions/delete-a-node-in-binary-search-tree/) 实际上有好几种做法 @@ -7943,7 +8634,7 @@ def delete_node_in_BST(parent, node): ``` ----- -### 165. ['Flatten', 'a', 'Multilevel', 'Linked', 'List'] +### 179. ['Flatten', 'a', 'Multilevel', 'Linked', 'List'] Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in below figure.You are given the head of the first level of the list. Flatten the list so that all the nodes appear in a single-level linked list. You need to flatten the list in way that all nodes at first level should come first, then nodes of second level, and so on. @@ -7976,7 +8667,7 @@ def flatten_list(head): ``` ----- -### 166. ['Flattening', 'a', 'Linked', 'List'] +### 180. ['Flattening', 'a', 'Linked', 'List'] Given a linked list where every node represents a linked list and contains two pointers of its type: (i) Pointer to next node in the main list (we call it ‘right’ pointer in below code) @@ -8029,7 +8720,7 @@ def merge(node1, node2): ``` ----- -### 167. ['Largest', 'None', 'Close', 'Sum'] +### 181. ['Largest', 'None', 'Close', 'Sum'] #####9/23/2014 Interview with Kevin from Fivestars @@ -8065,7 +8756,7 @@ def find_largest_none_close_sum(A): ``` ----- -### 168. ['Longest', 'Common', 'Subsequence'] +### 182. ['Longest', 'Common', 'Subsequence'] Need to distinguish from Longest Common Substring @@ -8165,7 +8856,7 @@ print LCS('AGGTAB', 'GXTXAYB') ``` ----- -### 169. ['Longest', 'Common', 'Substring'] +### 183. ['Longest', 'Common', 'Substring'] ##### 9/4/2014 Interview with Tubular 1. Subset(second le) @@ -8223,7 +8914,7 @@ print Longest_Common_Substring("GeeksforGeeks", "GeeksQuiz") ``` ----- -### 170. ['Longest', 'Increasing', 'Subsequence'] +### 184. ['Longest', 'Increasing', 'Subsequence'] #####NC Class 5, slides 17 @@ -8285,7 +8976,7 @@ d_A = LIS(A) ``` ----- -### 171. ['Lowest', 'Common', 'Ancestor'] +### 185. ['Lowest', 'Common', 'Ancestor'] #####[LCA, Lowest Common Ancestor](http://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/) Pocket Gem possible question 9/8/2014 @@ -8359,7 +9050,7 @@ def get_LCA(root, node1, node2): ``` ----- -### 172. ['Majority', 'Number'] +### 186. ['Majority', 'Number'] #####From mibbs for Linkedin Interview Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). @@ -8418,7 +9109,7 @@ def majority_ii(A): ``` ----- -### 173. ['Min', 'Num', 'to', 'Composite', 'Words'] +### 187. ['Min', 'Num', 'to', 'Composite', 'Words'] #####From [Career Cup](http://www.careercup.com/page?pid=pinterest-interview-questions) Pinterest @@ -8463,7 +9154,7 @@ print print_min_num_words(str, d) ``` ----- -### 174. ['Min', 'Stack'] +### 188. ['Min', 'Stack'] #####From NC Class 7 Data Structures, slides 8 [Solution](http://www.geeksforgeeks.org/design-and-implement-special-stack-data-structure/) @@ -8502,7 +9193,7 @@ class MinStack(): ``` ----- -### 175. ['Nested', 'Integer'] +### 189. ['Nested', 'Integer'] #####From NC QQ group and mitbbs, Linkedin Second round phone interview This is the interface that represents nested lists. @@ -8557,7 +9248,7 @@ def get_depth_recur(input, depth) ``` ----- -### 176. ['Operations', 'Calculation'] +### 190. ['Operations', 'Calculation'] ##### 9/5/2014 Elasticbox 加减运算 @@ -8614,7 +9305,7 @@ find_next_num() ``` ----- -### 177. ['Print', 'Matrix'] +### 191. ['Print', 'Matrix'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32570751.html) for Pinterest @@ -8659,7 +9350,7 @@ print_matrix(matrix) ``` ----- -### 178. ['Print', 'Numbers', 'With', 'Five'] +### 192. ['Print', 'Numbers', 'With', 'Five'] ##### 9/7/2014 From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32651839.html) for Groupon 写一个function,对于参数n,输出从0到n之间所有含5的数字。 @@ -8687,7 +9378,7 @@ print find_five(60) ``` ----- -### 179. ['Queue', 'by', 'Two', 'Stacks'] +### 193. ['Queue', 'by', 'Two', 'Stacks'] Implement a Queue by using two stacks. Support O(1) push, pop, top @@ -8715,7 +9406,7 @@ class Queue(): ``` ----- -### 180. ['Recover', 'Rotated', 'Sorted', 'Array'] +### 194. ['Recover', 'Rotated', 'Sorted', 'Array'] Given a rotated sorted array, recover it to sorted array in-place. @@ -8746,7 +9437,7 @@ print recover_rotated_sorted_array(A) ``` ----- -### 181. ['Rotated', 'Mirror', 'Number'] +### 195. ['Rotated', 'Mirror', 'Number'] #####From Alec's email, someone's onsite interview with Facebook for finding rotated mirrow number like 808 which is less than N @@ -8791,7 +9482,7 @@ print rotated_mirror_number(10000) ``` ----- -### 184. ['Search', 'a', 'Range', 'in', 'BST'] +### 198. ['Search', 'a', 'Range', 'in', 'BST'] or Print BST Keys in the Give Range @@ -8822,7 +9513,7 @@ def search_a_range(root, k1, k2): ``` ----- -### 185. ['Shortest', 'Path'] +### 199. ['Shortest', 'Path'] #####With Twitter & Cyan @@ -8905,7 +9596,7 @@ print find_path(map) ``` ----- -### 186. ['Shuffle'] +### 200. ['Shuffle'] #####Shuffle a given array Saw it from FiveStar's interview. @@ -8934,7 +9625,7 @@ print shuffle_array(A) ``` ----- -### 187. ['Sort', 'by', 'Stack'] +### 201. ['Sort', 'by', 'Stack'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32230525.html) for Quantcast @@ -8984,7 +9675,7 @@ print sort_by_two_stacks(s) ``` ----- -### 188. ['isOneEditDistance'] +### 202. ['isOneEditDistance'] #####From [mitbbs](http://www.mitbbs.com/article_t/JobHunting/32760941.html) for facebook diff --git a/tool.py b/tool.py index af6b0ac..d21c428 100755 --- a/tool.py +++ b/tool.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import glob -from xlrd import open_workbook +# from xlrd import open_workbook def combiner(file_list): f = open('solutions.md', 'w')