Skip to content

Code Says

C code. C code run. Run code run… please!

  • Home
  • Cracking the Coding Interview
  • Codility
  • Jobdu OJ
  • LeetCode
  • Privacy Policy
  • Contact Me
  • Home
  • Cracking the Coding Interview
  • Codility
  • Jobdu OJ
  • LeetCode
  • Privacy Policy
  • Contact Me

Author Archives: Sheng

Solution to Tape-Equilibrium by codility

16 Jan

Question: http://codility.com/demo/take-sample-test/tape_equilibrium Question Name: TapeEquilibrium The variable of head stores the sum of the heading part of the tape. And the variable of tail stores the sum of tailing part. Then, we move the index from 2nd position to the … Read More »

Codility, Python codility, python 75 Comments

Solution to Perm-Missing-Elem by codility

16 Jan

Question: http://codility.com/demo/take-sample-test/perm_missing_elem Question Name: PermMissingElem or PermMissingElement The main challenge of this question is the XOR operations: X^X=0, and 0^X=X. Logically, the addition and subtraction operations also are able to do this work. But taking the overflow in computer into … Read More »

Codility, Python codility, python 123 Comments

Solution to Frog-Jmp by codility

15 Jan

Question: https://codility.com/demo/take-sample-test/frog_jmp Question Name: FrogJmp This is a very easy question. If with C, one statement is enought. UPDATE on 2017/11/29: Codility changed Python from 2.X to 3.X. So the integer division needs to be updated to “//” from “/”. … Read More »

Codility, Python codility, python 39 Comments

Set Up a Private Airfare Watchdog by Your Own

11 Nov

There are some public airfare watchdogs online. But we still have tons of reasons to set up a private one. For example, we do not want to share our email address, considering privacy and/or spam. Additionally, private watchdog has quicker … Read More »

Python python, Utility Leave a comment

Unofficial C Solution to Problem 3.4 in Cracking the Coding Interview (5th Edition)

13 Oct

Before solving this problem, we introduce a simple library of stack with integers. Many following questions need an integer stack. Not to reinvent the wheel in our following solutions, we make a standalone integer stack library. Actually, we should do … Read More »

C/C++, Solutions-CTCI C, CTCI Leave a comment

Unofficial C Solution to Problem 3.3 in Cracking the Coding Interview (5th Edition)

10 Oct

The first part of this question is easy: use a set of stacks to mimic a single stack. In the second part, we need to implement a new method as popAt(int index) to make a pop operation on a specific … Read More »

C/C++, Solutions-CTCI C, CTCI Leave a comment

Unofficial C Solution to Problem 3.2 in Cracking the Coding Interview (5th Edition)

31 Jul

In my solution, I used a structure with two traditional stacks. One of them is used to store the original elements. The other is used to store the latest minimum elements. At any time, the top element in the second … Read More »

C/C++, Solutions-CTCI C, CTCI Leave a comment

Unofficial C Solution to Problem 3.1 in Cracking the Coding Interview (5th Edition)

19 Jul

I used a different solution from the ones in the original book. In the first official solution in the book, one stack might be full while another is empty. The space utilization is bad. In the second official solution, once … Read More »

C/C++, Solutions-CTCI C, CTCI Leave a comment

Unofficial C Solution to Problem 2.7 in Cracking the Coding Interview (5th Edition)

11 May

There is a similar and easier question: how to check if an array is a palindrome? Or equivalently, how to check if a double linked list is a palindrome? The three solutions in the original question work well for these … Read More »

C/C++, Solutions-CTCI C, CTCI 2 Comments

Unofficial C Solution to Problem 2.6 in Cracking the Coding Interview (5th Edition)

10 May

There is a follow up question: how to determine whether two linked lists, to say list1 and list2, intersect each other. Two solutions are available for this problem. On one hand, we could link the end of list1 to the … Read More »

C/C++, Solutions-CTCI C, CTCI Leave a comment

Posts navigation

← 1 … 31 32 33 34 35 →

Guideline for Comments

tl;dr: Please put your code into a <pre>YOUR CODE</pre> section.

Hello everyone!

If you want to ask a question about the solution. DO READ the post and comments firstly.

If you had some troubles in debugging your solution, please try to ask for help on StackOverflow, instead of here.

If you want to post some comments with code or symbol, here is the guidline.

1. To post your code, please add the code inside a <pre> </pre> section (preferred), or <code> </code>. And inside the pre or code section, you do not need to escape < > and &, e.g. no need to use &lt; instead of <.

2. To use special symbols < and > outside the pre block, please use "&lt;" and "&gt;" instead.

3. If you have a comment with lots of < and >, you could add the major part of your comment into a <pre class="decode:true crayon-inline "> YOUR COMMENTS </pre> section.

Finally, if you are posting the first comment here, it usually needs moderation. Please be patient and stay tuned. Thanks!

CodeSays.com Admin

Recent Comments

  • Jay Bariya January 18, 2023 at 3:54 pm on Solution to Triangle by codilityI initially solved it using how Sheng did to just find the mere existence of a trianglular. My code can be modified to find all...
  • Jay Bariya January 17, 2023 at 1:23 am on Solution to Max-Product-Of-Three by codility100% Python solution. Hi @Sheng, I tried solving it without using sorting. Just min and max. I believe my complexity is O(N), but Codility shows...
  • Jay Bariya January 16, 2023 at 9:15 pm on Solution to Distinct by codilityUse a dictionary or just use a set. def solution(A): unique_dict = {} for int_val in A: unique_dict[int_val] = 0 return len(unique_dict.keys())
  • Jay Bariya January 8, 2023 at 10:34 pm on Solution to Min-Avg-Two-Slice by codilityPython solution- 100%. Detected time complexity - O(N). Even before looking at the solution, the proof that global minimum average lies in slices with 2...
  • Jay Bariya January 6, 2023 at 4:57 am on Solution to Genomic-Range-Query by codilityPretty neat and easy to understand solution. Thanks.
  • Jay Bariya January 3, 2023 at 1:02 am on Solution to Count-Div by codilityPython 100%. Time Complexity O(1). def solution(A,B,K): # solution for case K = 1 if K == 1: return B-A + 1 # solution for...
  • Jay Bariya January 2, 2023 at 10:55 pm on Solution to Passing-Cars by codilityPython solution - 100%. O(N) def solution(A): n_pairs= 0 to_east = 0 # iterate over directions for direction in A: # if direction is east,...
  • Jay Bariya December 31, 2022 at 11:53 pm on Solution to Missing-Integer by codility100% on correctness and performance. Detected Time Complexity - O(N) or O(NlogN). I've explained my code with comments. def solution(A): # sort the list A.sort()...
  • Jay Bariya December 30, 2022 at 7:05 pm on Solution to Max-Counters by codilityTime Complexity - O(N+M). 100%. List comprehension in the last step instead of directly applying max() inspired from one of the other comments on Python....

Categories

  • Announcement
  • C/C++
  • Codility
  • Interview Questions
  • Java
  • Jobdu OJ
  • LeetCode
  • Linux
  • Others
  • Python
  • Solutions-CTCI
  • SQL

Tags

algorithm AppFog C codility Crawler CTCI Hash Set Interview Linux LMR pcapy PHP python rotation shuffle Utility WordPress

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2023 Code Says
Powered by WordPress / Theme by Design Lab
  • Contact Me
  • About Me
  • Privacy Policy