Skip to content

Commit

Permalink
[leetcode-2119] A Number After a Double Reversal
Browse files Browse the repository at this point in the history
Signed-off-by: carlos <carlos.wei.hk@gmail.com>
Change-Id: Ifc338c845096339549cc7427716af9f3459fae63
  • Loading branch information
carloscn committed Sep 12, 2023
1 parent e7e746c commit 4c7d077
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ C语言无法像是高级计算机语言对基础数据结构有一部分的实
* [leetcode1518:换水问题(water-bottles)](https://github.com/carloscn/structstudy/issues/238) [2023-06-01]
* [leetcode1837: Sum of Digits in Base K](https://github.com/carloscn/structstudy/issues/294) [2023-08-03]
* [leetcode1876: Substrings of Size Three with Distinct Characters](https://github.com/carloscn/structstudy/issues/300) [2023-08-09]
* [leetcode2119: A Number After a Double Reversal](https://github.com/carloscn/structstudy/issues/342) [2023-09-13]
## [二叉树](https://github.com/carloscn/structstudy/tree/master/c_programming/tree)
* [二叉树的层次/前序/中序/后续遍历](https://github.com/carloscn/structstudy/issues/22)
* [二叉树展开为链表(leetcode-114)](https://github.com/carloscn/structstudy/issues/23)
Expand Down
31 changes: 31 additions & 0 deletions c_programming/common/n19_a_number_after_a_double_reversal_2119.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#include "utils.h"

bool is_same_after_reversals(int32_t num)
{
return (num % 10 != 0) || (num < 9);
}

int32_t main(void)
{
bool ret = false;

ret = is_same_after_reversals(526);
assert(ret == true);

ret = is_same_after_reversals(1800);
assert(ret == false);

ret = is_same_after_reversals(0);
assert(ret == true);

LOG("All tests have passed!\n");

finish:
return 0;
}

0 comments on commit 4c7d077

Please sign in to comment.