Online coding interview Questions

  • Max Consecutive Ones – Leetcode #485

    Problem Statement This problem is from Leetcode – Max Consecutive Ones. The problem statement is as below: Given a binary array nums, return the length of the longest run of consecutive 1’s in the array. Solution Initialize variables Iterate Though the Array You can checkout the code from Github here: Max Consecutive Ones. See the…

    Read More

  • Number Complement – Leetcode #476

    Problem Statement This problem is from Leetcode – Number Complement. The problem statement in short is as below: Given an integer num, return its binary complement by flipping all 0s to 1s and all 1s to 0s in its binary representation. Solution This problem is simple enough. We first compute the binary of the given…

    Read More

  • Assign Cookies – Leetcode #455

    Problem Statement This problem is from Leetcode – Assign Cookies. The problem statement in short is as below: Given two arrays g (children’s greed factors) and s (cookie sizes), assign each child at most one cookie such that s[j] >= g[i] to satisfy the child. Return the maximum number of content children. Solution You can…

    Read More

  • Longest Uniform Sub-String

    Problem Statement Given a string, find the longest uniform sub-string in it. Return the repeating character and the number of times it repeats. Solution Let us take an example string like “abcdddss“. The question is asking us to return the longest sub-string with the same characters. In this case the longest uniform sub-string is “ddd”.…

    Read More

  • First Non-Repeating Character

    Problem Statement Given an input string, find the first non-repeating character in it. Solution Let us take an example string like “aabccdeff“. The question is asking us to return the first character that does not repeat. In this case the first non-repeating character is “b“ Approach Declare a hashmap with Character as key and Boolean…

    Read More