Skip to content

jahnvisethjs/Competitive-Programming

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is it?

A collection of some programs under competetive programming competitions like Hackerrank, CodeChef, SpoJ and Leetcode etc.


Your code has poor documentation

This repository has working programs that were submitted during competitions as it is. As such they lack comments and proper documentation. However, you can use it as follows.

  • Say, you want to look for sieve of eratosthenes's code snippet. Just search in the repo.
  • If you want the implementation of the range min-max segment tree, just search segment-tree
  • File names usually correspond to the problem title they refer to. So you can search by that.
  • Solutions are grouped by languages.

Who is this for

  • Budding programmers delving into the world of competitive programming wanting to see the code in action.
  • Myself, to keep on solving problems at all stages of my life.

Questions by Companies

Google

# Title Acceptance Difficulty Finished
1 Two Sum 45.50% Easy
560 Subarray Sum Equals K 43.90% Medium
68 Text Justification 27.50% Hard
253 Meeting Rooms II 45.60% Medium
76 Minimum Window Substring 34.40% Hard
85 Maximal Rectangle 37.40% Hard
221 Maximal Square 37.60% Medium
127 Word Ladder 29.20% Medium
295 Find Median from Data Stream 43.90% Hard
394 Decode String 49.60% Medium
362 Design Hit Counter 63.40% Medium
528 Random Pick with Weight 43.90% Medium
843 Guess the Word 46.00% Hard
1048 Longest String Chain 54.50% Medium
329 Longest Increasing Path in a Matrix 43.20% Hard
315 Count of Smaller Numbers After Self 41.40% Hard
642 Design Search Autocomplete System 44.40% Hard
410 Split Array Largest Sum 44.40% Hard
359 Logger Rate Limiter 70.30% Easy
593 Valid Square 42.90% Medium
946 Validate Stack Sequences 61.40% Medium
1153 String Transforms Into Another String 35.90% Hard
727 Minimum Window Subsequence 41.50% Hard
399 Evaluate Division 51.30% Medium
1110 Delete Nodes And Return Forest 66.70% Medium
722 Remove Comments 34.30% Medium
809 Expressive Words 47.20% Medium
729 My Calendar I 51.50% Medium
1031 Maximum Sum of Two Non-Overlapping Subarrays 57.70% Medium
752 Open the Lock 51.50% Medium
679 24 Game 46.10% Hard
489 Robot Room Cleaner 69.40% Hard
1146 Snapshot Array 37.00% Medium
862 Shortest Subarray with Sum at Least K 24.40% Hard
846 Hand of Straights 53.90% Medium
659 Split Array into Consecutive Subsequences 43.60% Medium
346 Moving Average from Data Stream 70.70% Easy
1438 Longest Continuous Subarray With Abs Diff <= Limit 42.60% Medium
1088 Confusing Number II 43.50% Hard
299 Bulls and Cows 42.30% Easy
951 Flip Equivalent Binary Trees 65.70% Medium
1376 Time Needed to Inform All Employees 55.20% Medium
1231 Divide Chocolate 52.20% Hard
1296 Divide Array in Sets of K Consecutive Numbers 53.20% Medium
375 Guess Number Higher or Lower II 40.20% Medium
1140 Stone Game II 62.80% Medium
1423 Maximum Points You Can Obtain from Cards 41.30% Medium
833 Find And Replace in String 50.30% Medium
1345 Jump Game IV 37.40% Hard
1463 Cherry Pickup II 64.50% Hard

Amazon

# Title Acceptance Difficulty Finished
1 Two Sum 45.50% Easy
200 Number of Islands 46.50% Medium
2 Add Two Numbers 33.70% Medium
937 Reorder Data in Log Files 54.30% Easy
42 Trapping Rain Water 48.50% Hard
146 LRU Cache 32.80% Medium
5 Longest Palindromic Substring 29.30% Medium
23 Merge k Sorted Lists 39.90% Hard
1192 Critical Connections in a Network 48.60% Hard
21 Merge Two Sorted Lists 53.20% Easy
994 Rotting Oranges 47.60% Medium
56 Merge Intervals 39.10% Medium
273 Integer to English Words 26.90% Hard
121 Best Time to Buy and Sell Stock 50.30% Easy
692 Top K Frequent Words 51.50% Medium
269 Alien Dictionary 33.30% Hard
973 K Closest Points to Origin 63.60% Medium
139 Word Break 39.80% Medium
253 Meeting Rooms II 45.60% Medium
297 Serialize and Deserialize Binary Tree 47.10% Hard
49 Group Anagrams 56.40% Medium
763 Partition Labels 75.60% Medium
127 Word Ladder 29.20% Medium
138 Copy List with Random Pointer 35.80% Medium
295 Find Median from Data Stream 43.90% Hard
140 Word Break II 31.50% Hard
227 Basic Calculator II 36.70% Medium
79 Word Search 34.90% Medium
588 Design In-Memory File System 45.30% Hard
460 LFU Cache 33.90% Hard
239 Sliding Window Maximum 42.80% Hard
348 Design Tic-Tac-Toe 54.00% Medium
472 Concatenated Words 43.30% Hard
1152 Analyze User Website Visit Pattern 43.60% Medium
819 Most Common Word 44.60% Easy
211 Add and Search Word - Data structure design 36.60% Medium
126 Word Ladder II 21.90% Hard
240 Search a 2D Matrix II 43.10% Medium
210 Course Schedule II 39.70% Medium
642 Design Search Autocomplete System 44.40% Hard
480 Sliding Window Median 37.00% Hard
863 All Nodes Distance K in Binary Tree 55.00% Medium
733 Flood Fill 55.10% Easy
353 Design Snake Game 33.90% Medium
694 Number of Distinct Islands 55.70% Medium
909 Snakes and Ladders 38.30% Medium
564 Find the Closest Palindrome 19.60% Hard
1268 Search Suggestions System 63.30% Medium
1167 Minimum Cost to Connect Sticks 62.60% Medium
726 Number of Atoms 48.50% Hard

Facebook

# Title Acceptance Difficulty Finished
23 Merge k Sorted Lists 39.90% Hard
238 Product of Array Except Self 59.90% Medium
56 Merge Intervals 39.10% Medium
273 Integer to English Words 26.90% Hard
953 Verifying an Alien Dictionary 54.30% Easy
560 Subarray Sum Equals K 43.90% Medium
1249 Minimum Remove to Make Valid Parentheses 62.40% Medium
269 Alien Dictionary 33.30% Hard
973 K Closest Points to Origin 63.60% Medium
31 Next Permutation 32.50% Medium
415 Add Strings 47.30% Easy
297 Serialize and Deserialize Binary Tree 47.10% Hard
88 Merge Sorted Array 39.20% Easy
215 Kth Largest Element in an Array 54.90% Medium
199 Binary Tree Right Side View 53.70% Medium
124 Binary Tree Maximum Path Sum 34.10% Hard
680 Valid Palindrome II 36.50% Easy
301 Remove Invalid Parentheses 43.10% Hard
986 Interval List Intersections 67.20% Medium
173 Binary Search Tree Iterator 56.10% Medium
987 Vertical Order Traversal of a Binary Tree 35.40% Medium
236 Lowest Common Ancestor of a Binary Tree 45.20% Medium
67 Add Binary 44.10% Easy
543 Diameter of Binary Tree 48.30% Easy
528 Random Pick with Weight 43.90% Medium
438 Find All Anagrams in a String 43.00% Medium
767 Reorganize String 48.30% Medium
211 Add and Search Word - Data structure design 36.60% Medium
158 Read N Characters Given Read4 II - Call multiple times 33.30% Hard
125 Valid Palindrome 35.80% Easy
636 Exclusive Time of Functions 51.80% Medium
340 Longest Substring with At Most K Distinct Characters 43.90% Hard
621 Task Scheduler 48.60% Medium
311 Sparse Matrix Multiplication 61.50% Medium
523 Continuous Subarray Sum 24.60% Medium
65 Valid Number 15.20% Hard
278 First Bad Version 35.40% Easy
721 Accounts Merge 48.30% Medium
938 Range Sum of BST 81.10% Easy
785 Is Graph Bipartite? 47.20% Medium
282 Expression Add Operators 35.40% Hard
270 Closest Binary Search Tree Value 47.80% Easy
1060 Missing Element in Sorted Array 54.40% Medium
670 Maximum Swap 43.30% Medium
249 Group Shifted Strings 54.50% Medium
1428 Leftmost Column with at Least a One 46.50% Medium
398 Random Pick Index 55.50% Medium
689 Maximum Sum of 3 Non-Overlapping Subarrays 46.00% Hard
896 Monotonic Array 57.70% Easy
1026 Maximum Difference Between Node and Ancestor 65.50% Medium

LinkedIn

# Title Acceptance Difficulty Finished
53 Maximum Subarray 46.40% Easy
297 Serialize and Deserialize Binary Tree 47.10% Hard
380 Insert Delete GetRandom O(1) 47.40% Medium
127 Word Ladder 29.20% Medium
364 Nested List Weight Sum II 62.60% Medium
150 Evaluate Reverse Polish Notation 36.10% Medium
102 Binary Tree Level Order Traversal 54.20% Medium
698 Partition to K Equal Sum Subsets 45.00% Medium
101 Symmetric Tree 46.60% Easy
339 Nested List Weight Sum 73.60% Easy
716 Max Stack 42.50% Easy
149 Max Points on a Line 16.90% Hard
244 Shortest Word Distance II 52.20% Medium
605 Can Place Flowers 31.60% Easy
272 Closest Binary Search Tree Value II 50.30% Hard
254 Factor Combinations 46.60% Medium
244 Shortest Word Distance II 48.20% Medium
364 Nested List Weight Sum II 58.40% Medium
170 Two Sum III - Data structure design 31.00% Easy
339 Nested List Weight Sum 69.00% Easy
272 Closest Binary Search Tree Value II 45.80% Hard
156 Binary Tree Upside Down 51.60% Medium
256 Paint House 49.40% Easy
243 Shortest Word Distance 57.90% Easy
149 Max Points on a Line 16.00% Hard
265 Paint House II 42.00% Hard
65 Valid Number 14.20% Hard
716 Max Stack 40.40% Easy
254 Factor Combinations 44.70% Medium
380 Insert Delete GetRandom O(1) 43.30% Medium
68 Text Justification 23.90% Hard
366 Find Leaves of Binary Tree 66.50% Medium
605 Can Place Flowers 31.10% Easy

Microsoft

# Title Acceptance Difficulty Finished
1246 Palindrome Removal 45.90% Hard
1239 Maximum Length of a Concatenated String with Unique Characters 47.60% Medium
273 Integer to English Words 26.90% Hard
428 Serialize and Deserialize N-ary Tree 59.00% Hard
146 LRU Cache 32.80% Medium
1156 Swap For Longest Repeated Character Substring 48.70% Medium
54 Spiral Matrix 33.90% Medium
212 Word Search II 34.50% Hard
1236 Web Crawler 64.30% Medium
828 Count Unique Characters of All Substrings of a Given String 44.80% Hard
138 Copy List with Random Pointer 35.80% Medium
545 Boundary of Binary Tree 38.90% Medium
25 Reverse Nodes in k-Group 41.70% Hard
348 Design Tic-Tac-Toe 54.00% Medium
450 Delete Node in a BST 42.90% Medium
124 Binary Tree Maximum Path Sum 34.10% Hard
340 Longest Substring with At Most K Distinct Characters 43.90% Hard
218 The Skyline Problem 34.40% Hard
200 Number of Islands 46.50% Medium
358 Rearrange String k Distance Apart 34.70% Hard
1375 Bulb Switcher III 62.10% Medium
99 Recover Binary Search Tree 39.30% Hard
468 Validate IP Address 24.00% Medium
116 Populating Next Right Pointers in Each Node 44.60% Medium
41 First Missing Positive 31.80% Hard
93 Restore IP Addresses 35.30% Medium
23 Merge k Sorted Lists 39.90% Hard
103 Binary Tree Zigzag Level Order Traversal 47.00% Medium
232 Implement Queue using Stacks 49.10% Easy
1 Two Sum 45.50% Easy
79 Word Search 34.90% Medium
1116 Print Zero Even Odd 55.70% Medium
297 Serialize and Deserialize Binary Tree 47.10% Hard
4 Median of Two Sorted Arrays 29.40% Hard
134 Gas Station 38.20% Medium
207 Course Schedule 42.80% Medium
445 Add Two Numbers II 54.30% Medium
105 Construct Binary Tree from Preorder and Inorder Traversal 48.20% Medium
42 Trapping Rain Water 48.50% Hard
74 Search a 2D Matrix 36.40% Medium
151 Reverse Words in a String 21.10% Medium
102 Binary Tree Level Order Traversal 54.20% Medium
10 Regular Expression Matching 26.70% Hard
173 Binary Search Tree Iterator 56.10% Medium
140 Word Break II 31.50% Hard
443 String Compression 41.00% Easy
8 String to Integer (atoi) 15.30% Medium
148 Sort List 41.80% Medium
630 Course Schedule III 33.30% Hard
155 Min Stack 44.20% Easy
621 Task Scheduler 48.60% Medium
432 All O`one Data Structure 32.20% Hard
285 Inorder Successor in BST 40.00% Medium
240 Search a 2D Matrix II 43.10% Medium
636 Exclusive Time of Functions 51.80% Medium
510 Inorder Successor in BST II 57.90% Medium
716 Max Stack 42.50% Easy
179 Largest Number 28.50% Medium
85 Maximal Rectangle 37.40% Hard
295 Find Median from Data Stream 43.90% Hard
46 Permutations 63.00% Medium
133 Clone Graph 34.20% Medium
89 Gray Code 48.90% Medium
622 Design Circular Queue 43.50% Medium
127 Word Ladder 29.20% Medium
126 Word Ladder II 21.90% Hard
37 Sudoku Solver 43.20% Hard
253 Meeting Rooms II 45.60% Medium
236 Lowest Common Ancestor of a Binary Tree 45.20% Medium
346 Moving Average from Data Stream 70.70% Easy
767 Reorganize String 48.30% Medium
706 Design HashMap 60.90% Easy
460 LFU Cache 33.90% Hard
277 Find the Celebrity 41.60% Medium
419 Battleships in a Board 69.80% Medium
695 Max Area of Island 62.40% Medium
48 Rotate Image 56.20% Medium
722 Remove Comments 34.30% Medium
380 Insert Delete GetRandom O(1) 47.40% Medium
75 Sort Colors 47.10% Medium
457 Circular Array Loop 29.20% Medium
557 Reverse Words in a String III 69.50% Easy
49 Group Anagrams 56.40% Medium
98 Validate Binary Search Tree 27.70% Medium
679 24 Game 46.10% Hard
1044 Longest Duplicate Substring 32.00% Hard
950 Reveal Cards In Increasing Order 74.30% Medium
128 Longest Consecutive Sequence 44.90% Hard
56 Merge Intervals 39.10% Medium
43 Multiply Strings 33.70% Medium
681 Next Closest Time 44.90% Medium
1229 Meeting Scheduler 52.30% Medium
149 Max Points on a Line 16.90% Hard
121 Best Time to Buy and Sell Stock 50.30% Easy
21 Merge Two Sorted Lists 53.20% Easy
17 Letter Combinations of a Phone Number 46.50% Medium
24 Swap Nodes in Pairs 50.00% Medium
33 Search in Rotated Sorted Array 34.50% Medium
773 Sliding Puzzle 59.00% Hard
129 Sum Root to Leaf Numbers 48.70% Medium
238 Product of Array Except Self 59.90% Medium
77 Combinations 54.30% Medium
528 Random Pick with Weight 43.90% Medium
53 Maximum Subarray 46.40% Easy

Why is it even here

I like to share and showcase all facets of my professional career. Competitive programming is something I extensively did during my college days and I still give it a try whenever time permits.

As such this is a subtle reminder of my capabilites. I'd encourage others to do the same. The check box is motivation enough :)

About

Collection of all competitive code snippets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 64.1%
  • Python 31.1%
  • Java 3.2%
  • C 0.7%
  • Haskell 0.5%
  • Ruby 0.2%
  • Other 0.2%