LEETCODE: ZIGZAG CONVERSION SOLUTION IN KOTLIN

  1. Zigzag Conversion Create a dummy 2D array, canvas and draw the pattern recursively. Note that the directions only change on the first and last rows.

Read more

LEETCODE: VERIFYING AN ALIEN DICTIONARY SOLUTION IN KOTLIN

  1. Verifying an Alien Dictionary Create a map of the unusual indexing of characters, use the map to compare adjacent strings’ order.

Read more

LEETCODE: GREATEST COMMON DIVISOR OF STRINGS SOLUTION IN KOTLIN

  1. Greatest Common Divisor of Strings The brute force way would be considering all the prefixes of one of the strings and simulate to see if that is a candidate answer.

Read more

LEETCODE: BEST TEAM WITH NO CONFLICTS KOTLIN SOLUTION

  1. Best Team With No Conflicts Since there are two variable values, it’ll be easier to work with if we could put them into some kind of order.

Read more

LEETCODE: N TH TRIBONACCI NUMBER KOTLIN SOLUTION

  1. N-th Tribonacci Number Since each number only depends on the last three numbers, we can pre compute the results in an array and return the results in ({\Omicron(1)}) for all the queries.

Read more

LEETCODE: LFU CACHE SOLUTION IN KOTLIN

  1. LFU Cache This problem is pretty much about implementing the requirement. I chose to do it in a more object oriented way.

Read more

LEETCODE: DATA STREAM AS DISJOINT INTERVALS SOLUTION IN KOTLIN

  1. Data Stream as Disjoint Intervals In this problem, we need to maintain a list of intervals and return the list for each getIntervals() call.

Read more

LEETCODE: CONCATENATED WORDS SOLUTION IN KOTLIN

  1. Concatenated Words The problem basically asks to check which of the given words can be composed by concatenating two or more other words.

Read more

LEETCODE: MAXIMUM SUM CIRCULAR SUBARRAY SOLUTION IN KOTLIN

  1. Maximum Sum Circular Subarray The maximum sum problem can be solved using the well known Kadane’s algo. But this problem becomes a bit special because of the circular element.

Read more

LEETCODE: SUBARRAY SUMS DIVISIBLE BY K SOLUTION IN KOTLIN

  1. Subarray Sums Divisible by K Well known sub-array divisibility problem. Only catch was that the numbers could be negative. So don’t forget to handle modulus for negative values.

Read more