Skip to content

Latest commit

 

History

History
143 lines (124 loc) · 24.2 KB

README.md

File metadata and controls

143 lines (124 loc) · 24.2 KB

Puzzlers

This repository contains a set of programming puzzles that are solved using Java or Kotlin programming language. Tests provided for every problem.

Project structure

The project directory structure is as follows:

.
├── src/main                                  # Source files
│   ├── java                                  # Java sources
│   ├── kotlin                                # Kotlin sources
├── src/test                                  # Test files
│   ├── resources/.../*tested-class-name*/    # Tested class resources (input and output files)
├── LICENSE
└── README.md

Test source

TestSource annotation and TestSourceProvider are junit's ArgumentProvider implementation that search for the test resources (input and output files) in the directory structure, the same as test(ed) class package. Allows to test different class implementations (solutions to the problem) for every input-output pair file as in the code snippet below:

@ParameterizedTest
@TestSource(
    value = RucksackReorganization::class, // used as single implementation if no custom implementations provided.
    implementations = [RucksackReorganization::class, IdiomaticRucksackReorganization::class]
)
fun findTotalRearrangementPriority(rucksackReorganization: RucksackReorganization, input: Path, output: Path)

With execution of 4 tests for 2 implementations and 2 input-output pairs. test-results.png

Advent of Code 2022

Advent of Code 2022 challenge.

Day Problem Solution
1 Calorie Counting CalorieCounting.kt
2 Rock Paper Scissors RockPaperScissors.kt
3 Rucksack Reorganization RucksackReorganization.kt
4 Camp of Cleanup CampCleanup.kt
5 Supply Stacks SupplyStacks.kt
6 Tuning Trouble TuningTrouble.kt
7 No Space Left On Device DeviceSpace.kt
8 Treetop Tree House TreetopTreeHouse.kt
9 Rope Bridge RopeBridge.kt
10 Cathode-Ray Tube CathodeRayTube.kt
11 Monkey In The Middle MonkeyInTheMiddle.kt
12 Hill Climbing Algorithm HillClimbingAlgorithm.kt
13 Distress Signal DistressSignal.kt
14 Regolith Reservoir RegolithReservoir.kt

Leetcode

The following challenges from the Leetcode.

Top Interview Questions

This is the list of the Top Interview Questions.

Number Problem Solution
1 Two Sum TwoSum.java
2 Add Two Numbers AddTwoNumbers.java
5 Longest Palindromic Substring LongestPalindromicSubstring.kt
13 Roman to Integer RomanToInt.kt
14 Longest Common Prefix LongestCommonPrefix.kt
20 Valid Parentheses ValidParentheses.kt
26 Remove Duplicates from Sorted Array RemoveDuplicatesFromSortedArray.kt
28 Find the Index of the First Occurrence in a String FirstOccurrenceInString.kt
33 Search in Rotated Sorted Array SearchInRotatedSortedArray.java
38 Count and Say CountAndSay.kt
54 Spiral Matrix SpiralMatrix.kt
55 Jump Game JumpGame.java
69 Sqrt(x) Sqrt.kt
70 Climbing Stairs ClimbingStairs.kt
78 Subsets Subsets.kt
94 Binary Tree Inorder Traversal BinaryTreeInOrderTraversal.kt
101 Symmetric Tree SymmetricTree.kt
104 Maximum Depth of Binary Tree BstMaxDepth.kt
124 Binary Tree Maximum Path Sum BinaryTreeMaxPath.java
125 Valid Palindrome ValidPalindromeSentence.kt
136 Single Number SingleNumber.java
146 LRU Cache LRUCache.java
152 Maximum Product Subarray MaxProductSubarray.kt
169 Majority Element MajorityElement.java
191 Number of 1 Bits BitsNumber.kt
200 Number of Islands NumberOfIslands.java
202 Happy Number HappyNumber.java
208 Implement Trie (Prefix Tree) Trie.java
230 Kth Smallest Element in a BST KthSmallestElementInBst.java
238 Product of Array Except Self ProductExceptSelf.java
328 Odd Even Linked List OddEvenLinkedList.java
344 Reverse String ReverseString.kt
347 Top K Frequent Elements TopKFrequentElements.kt
350 Intersection of Two Arrays II TwoArrayIntersectionII.kt
387 First Unique Character in a String FirstUniqueChar.java
412 Fizz Buzz FizzBazz.kt

May LeetCoding Challenge

May LeetCoding consists of 31 daily problems over May. Beginner-friendly.

Day Number Problem Solution
1 278 First Bad Version FirstBadVersion.java
2 771 Jewels And Stones JewelsAndStones.java
3 383 Ransom Note RansomNote.java
4 476 Number Complement NumberComplement.java
5 387 First Unique Character in a String FirstUniqueChar.java
6 169 Majority Element MajorityElement.java
7 993 Cousins in Binary Tree CousinsInBinaryTree.java
8 1232 Check If It Is a Straight Line CheckStraightLine.java
9 367 Valid Perfect Square ValidPerfectSquare.java
10 997 Find the Town Judge FindTownJudge.java
11 733 Flood Fill FloodFill.java
12 540 Single Element in a Sorted Array SingleElementInSortedArray.java
13 402 Remove K Digits RemoveDigits.java
14 208 Implement Trie (Prefix Tree) Trie.java
15 918 Maximum Sum Circular Subarray MaxSumCircularSubarray.java
16 328 Odd Even Linked List OddEvenLinkedList.java
17 438 Find All Anagrams in a String FindAllAnagrams.java
18 567 Permutation in String PermutationInString.java
19 901 Online Stock Span StockSpanner.java
20 230 Kth Smallest Element in a BST KthSmallestElementInBst.java
21 1277 Count Square Submatrices with All Ones CountSquareSubmatrices.java
22 451 Sort Characters By Frequency SortCharactersByFrequency.java
23 986 Interval List Intersections IntervalListIntersection.java
24 1008 Construct Binary Search Tree from Preorder Traversal BinarySearchTreeFromPreorder.java
25 1035 Uncrossed Lines UncrossedLines.java
26 525 Contiguous Array ContiguousArray.java
27 886 Possible Bipartition PossibleBipartition.java
28 338 Counting Bits CountingBits.java