Logo Miradil's Blog
  • Home
  • About
  • Skills
  • Experiences
  • Education
  • More
    Projects Publications Recent Posts
  • Posts
  • Dark Theme
    Light Theme Dark Theme System Theme
Logo Inverted Logo
  • Posts
  • Introduction
  • DSA
    • CodeForces
      • 1918-A: Brick Wall
    • ICPC
      • 2023
        • Azerbaijani
          • Classify The Roman Numerals
        • Nordic
          • Karl Coder
    • LeetCode
      • 2: Add Two numbers
      • 58: Length of Last Word
      • 142: Linked List Cycle II
    • Eolymp
      • 87: Robot
      • 325: Dangerous route
      • 4036 & 4038: Pre-Order/Post-Order Traversal of a Tree
      • 6254: Timebomb
    • HackerRank
      • Queen's Attack II
      • Winning Lottery Ticket
      • Balanced Brackets
  • Django
    • How to detect field changes in Django
  • Reinventing the wheel
    • Linux command: `ls`
      • Command, file types and flags
      • Starting with C
      • Getting the list of files and their info
      • Processing flags
      • Sorting and formatting the output
  • Open Source Projects
    • Integrify
  • Misc
    • How did I get into programming?
    • How I got job in two hours
  • Podcast Notes
    • The Diary of A CEO
      • Vinh Giang
Hero Image
Eolymp 6254: Timebomb

Problem statement You and your teammates from the anti-bomb squad of the local police have been called to defuse a bomb found in the only pub in town. Fearing the tragic consequences this might produce, you go to the scene as quickly as possible. After some research, you learn that the bad guys have created a tricky way to allow them to defuse the bomb at will. You find a remote control with a button that you can take to a safe place. You also find that it is possible to connect to the bomb through a wireless connection and retrieve an ASCII representation of a code every 2 seconds. The bomb then gets defused if the button is pressed when the code is a number divisible by 6. But you have to be careful. If you press the button when the ASCII representation of the code is not a number divisible by 6 or has an invalid representation for any digit, the bomb will explode instead.

Monday, March 18, 2024 | 5 minutes Read
Hero Image
Hackerrank: Winning Lottery Ticket

Problem statement The SuperBowl Lottery is about to commence, and there are several lottery tickets being sold, and each ticket is identified with a ticket ID. In one of the many winning scenarios in the Superbowl lottery, a winning pair of tickets is: Concatenation of the two ticket IDs in the pair, in any order, contains each digit from 0 to 9 at least once. For example, if there are 2 distinct tickets with ticket ID 129300455 and 56789, (129300455, 56789) is a winning pair.

Monday, March 11, 2024 | 6 minutes Read
Hero Image
Leetcode 142: Linked List Cycle II

NOTE: The problem 141: “Linked List Cycle” is a subproblem of this problem, so the solution can be slightly modified to solve that too. Problem statement Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail’s next pointer is connected to (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.

Monday, March 4, 2024 | 4 minutes Read
Hero Image
Codeforces: Contest 1918, Problem A

Problem statement time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output A brick is a strip of size 1 × k, placed horizontally or vertically, where k can be an arbitrary number that is at least 2 (k ≥ 2). A brick wall of size n × m is such a way to place several bricks inside a rectangle n × m, that all bricks lie either horizontally or vertically in the cells, do not cross the border of the rectangle, and that each cell of the n × m rectangle belongs to exactly one brick. Here n is the height of the rectangle n × m and m is the width. Note that there can be bricks with different values of k in the same brick wall.

Monday, February 26, 2024 | 3 minutes Read
Hero Image
Hackerrank: Balanced Brackets

Problem statement A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and ().

Sunday, February 18, 2024 | 6 minutes Read
Hero Image
Leetcode 58: Length of Last Word

Problem statement Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1 Input: s = "Hello World" Output: 5 Explanation: The last word is "World" with length 5. Example 2 Input: s = " fly me to the moon " Output: 4 Explanation: The last word is "moon" with length 4.

Sunday, February 11, 2024 | 3 minutes Read
Hero Image
Hackerrank: Queen's Attack II

Problem statement You will be given a square chess board with one queen and a number of obstacles placed on it. Determine how many squares the queen can attack. A queen is standing on an n×nn \times nn×n chessboard. The chess board’s rows are numbered from 111 to nnn, going from bottom to top. Its columns are numbered from 111 to nnn, going from left to right. Each square is referenced by a tuple, (r,c)(r, c)(r,c), describing the row, rrr, and column, ccc, where the square is located.

Thursday, November 2, 2023 | 9 minutes Read
Hero Image
Classify The Roman Numerals

This problem is from ICPC competition that one of my followers participated (and asked for explanation) on October 22, 2023. Problem statement Your task is to determine the number of symmetry axis of the given Roman Numeral. The following table from Wikipedia displays how the Roman Numerals are written: Individual decimal places Thousands Hundreds Tens Units 1 M C X I 2 MM CC XX II 3 MMM CCC XXX III 4 CD XL IV 5 D L V 6 DC LX VI 7 DCC LXX VII 8 DCCC LXXX VIII 9 CM XC IX Note that:

Saturday, October 28, 2023 | 8 minutes Read
Hero Image
Eolymp 4036: Pre-Order Traversal of a Tree & 4038: Post-Order Traversal of a Tree

Problem statement These are two identical problems: Eolymp 4036 and 4038. The following problem statement is that of 4038, but explanation covers both problems. Given an array of integers. Create a Binary Search Tree from these numbers. If the inserted value equals to the current node, insert it to the right subtree. Write method PostOrder that makes Post-Order traversal of a tree. In this traversal method the left subtree is visited first, then the right subtree and finally the root node.

Friday, October 13, 2023 | 4 minutes Read
Hero Image
Eolymp 325: Dangerous route

Problem statement In one country there are n cities, some of which are connected by two-way routes. Cities are numbered by integers from 1 to n. In times of financial crisis the level of the crime in a state rose and the crime groups are organized. The most dangerous of these was “Timur and his gang” led by a notorious criminal circles by Timur, that commit robberies on most of the roads. As a result, some roads became dangerous to drive.

Wednesday, October 11, 2023 | 6 minutes Read
Hero Image
Karl Coder

This problem is from ICPC competition that I participated in on 7th of October, 2023. Problem statement Karl is an aspiring C programmer, and is excited by the risks and rewards of low-level manual memory management. In the program he currently develops, he stores a string containing N non-zero bytes into a buffer named “buf”. By mistake he accidentally made the buffer 2N bytes in size. The last bytes N of the buffer consists of only zero-bytes.

Monday, October 9, 2023 | 5 minutes Read
Hero Image
Leetcode 2: Add Two numbers

Problem statement You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example 1 Input: l1 = [2,4,3], l2 = [5,6,4]

Saturday, October 7, 2023 | 3 minutes Read
  • ««
  • «
  • 1
  • 2
  • »
  • »»
Navigation
  • About
  • Skills
  • Experiences
  • Education
  • Projects
  • Publications
  • Recent Posts
Contact me:
  • miradil.zeynalli@gmail.com
  • mmzeynalli
  • Miradil Zeynalli
  • @mmzeynalli
  • Miradil Zeynalli
  • @mmzeynalli

Toha Theme Logo Toha
© 2024 Copyright.
Powered by Hugo Logo